Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdk-ipython: package ipython correctly #2471

Closed
wants to merge 15 commits into from

Conversation

murphp15
Copy link
Collaborator

@murphp15 murphp15 commented Jul 25, 2023

Why

There is a bug in the current release of vdk-ipython. It is not including the files at the root of the source folder.

What

Remove the line from the setup.py so files at the root are included.

How was this tested?

Packaged locally and all looks good
Steps:

  1. run python setup.py sdist --formats=gztar
  2. in the generated dist folder there will be a zipped file. uncompress this.
  3. In the uncompressed folder make sure the python file is present.

@antoniivanov
Copy link
Collaborator

The PR include changes not just in vdk-ipython. Maybe you need to rebase ?

Is there related Github issue to the PR ? Can you describe in a bit more details the bug?

@murphp15 murphp15 force-pushed the person/murphp15/package_ipython_correctly branch from 504a128 to e834930 Compare July 25, 2023 11:41
@murphp15
Copy link
Collaborator Author

@tozka rebased. sorry about that.

@@ -16,7 +16,6 @@
long_description_content_type="text/markdown",
install_requires=["vdk-core", "iPython"],
package_dir={"": "src"},
packages=setuptools.find_namespace_packages(where="src"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the fix. Removing it seems like bad idea. We keep sources in "src" folder so we use setuptools.find_namespace_packages to automatically find all the Python packages within the directory

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tozka there are no packages in that python project. There is just a single python file at the root of source.

Copy link
Collaborator

@antoniivanov antoniivanov Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's not following the plugin templates.

The source code should be in in "src" directory in package starting with vdk.plugin.<plugin-name>....

That's the structure of all other plugins . It's the one setup if a plugin is created using the cookiecutter - https://github.com/tozka/cookiecutter-vdk-plugin/tree/main

But I don't get the problems? Which files are not included? And why do we need them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vdk_ipython.py is at the root of the source folder. It is not in a package so if that line is in the setup.py then this file is dropped.

@duyguHsnHsn do you think we could put the plugin in a package or would it make it less usable for customers do you think?

Copy link
Collaborator

@antoniivanov antoniivanov Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I got the problem.

find_namespace_packages doesn't include files that are not in a directory (aka package), and those that are at the root level specified are ignored. I find this a bit strange to be honest. And slightly problematic. I would expect find_namespace_packages to assume root level files are in the global namespace/package.

The current approach you are doing would also have a namespace/package. If you unzip the tar you will see the file is inside a "src" folder . So a user would need to do

from src import vdk_ipython

you can test it yourself by installing pip install dist/vdk-ipython-0.1.0.tar.gz

The test pass because they assume "src" structure is kept and set src on the PythonPath and ignore setup.py

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favour of changing it to src/vdk/plugin/ipython.py

Then when the extension is loaded it would look like load_ext vdk.plugin.ipython

@murphp15
Copy link
Collaborator Author

@tozka there are no packages in that python project. There is just a single python file at the root of source.

@antoniivanov
Copy link
Collaborator

Packaged locally and all looks good

I favour automated tests? Why isn't our Gitlab CI not catching the issue.

But for any manual tests, please describe them in such a way that I (or anyone) can reproduce them. It's useful since
A) I sometimes reproduce them to verify they work in another environment
B) in the future looking at previous commits if there was a manual tests I can reuse it for similar change

@murphp15
Copy link
Collaborator Author

@duyguHsnHsn do you have tests on the juypter UI, why did they not catch this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants