-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Include type information by default #4021
Conversation
I'm not sure where to add tests because the tests that test functionality most similar to this seem to lie in _distutils (test_sdist.py has a test_add_defaults). Should this feature be in distutils instead? |
Thank you very much @Danie-1 for the contribution ❤️ 💚 The errors with the docs are probably caused by the breaking changes in sphinx 7.2. I updated the main branch to temporarily cap at sphinx 7.1.2 while we fix the problems in a separated PR. You can rebase if you want to get rid of the CI errors.
I just would like to align expectations in relation to the PR title and changelog entry: It seems to me that what the PR does is to add But these files may not necessarily end-up on the wheel (I think that will depend on other factors like (I was suggesting something very similar in #3136 (comment), however upon further thought, I think both approaches would have the same shortcomings). If you are OK with this behaviour, I think we can go ahead, but probably we will have to change the changelog entry to make this more explicit, so the other users don't create further expectations.
I think these could be added to
I don't think so. I think that the Some of the edge cases that I am not sure will not automatically add
|
Thank you very much for the detailed comments.
My intention with this was to make the files be included on the wheel by default (but I'll be completely honest and admit I have very little knowledge about python packaging and I don't know what the sdist is so I'll try to look into that). So at least at the moment, I would prefer to try to keep working on this until we can confirm that files are included in the wheel. In my pull request I should have said that this was intended to be work in progress (I have now marked it as draft). About the experimental testing to confirm the behaviour, do you have any advice about how to go about this (are there any nice sources of small example packages to test with)? The way I tested these changes was to install my modified setuptools code into a venv and run
I'll try to add some tests there. Would
I've tested this and the files were not included, so I will try to address that. I should have the time to have a go at all these things as I'm a student with a lot of free time, but I will soon be going on a holiday until September, so I won't be working on it during that time but I intend to work some more after that. |
Hi @Danie-1, thank you very much for the comments and all the effort.
Yeah, Please feel free to iterate over the draft as much as you want, you can ping me if you need any advice. Once you think it is good to go, I can do a review.
If you want to make sure that a specific behaviour is observed, I recommend adding a test that captures that behaviour, so you can implement the change and check if the test passes. If you want just to investigate the existing behaviour, you can also create a separated set of scripts. For example, this is an experiment I did 2 years ago: https://github.com/abravalheri/experiment-setuptools-package-data
This is one way of using your modified version of setuptools with both python3.9 -m venv .venv # creating a virtual environment to work as a sandbox
.venv/bin/python -m pip install -U pip wheel build # let's update pip, wheel and build
.venv/bin/python -m pip install -e ./modified_setuptools # install the working copy of setuptools
# If we disable isolation, both `pip`/`build` will use the version of setuptools
# that is currently installed in the virtual environment
.venv/bin/python -m build ./dummy_project --no-isolation
.venv/bin/python -m pip install ./dummy_project --no-build-isolation
# You can use `unzip -Z1` to list the contents of the wheel file
# and `tar tf` to list the contents of the sdist
unzip -Z1 dummy_project/dist/*.whl
tar tf dummy_project/dist/*.tar.gz
No problems @Danie-1, it is very kind of you to be working on this and offering your contributions to the project. Please feel free to do it in your time. Footnotes
|
I've now added some tests and an implementation that passes the tests. I think it addresses the things that were mentioned previously:
Thanks for linking your repo explaining how data files get added and showing the I spent a while considering adding something like this in if self.packages:
self.build_packages()
self.build_package_data()
self.build_type_information() # new but I was slightly hesitant because this would mean that type information files would be no longer treated as data files. I wasn't sure if this could break some things, and also I wasn't sure if this would make it harder to exclude type information files (if you really wanted). So the main thing I'd like to ask @abravalheri is whether you think it's worth doing the method I outlined above, or do you think the current implementation is sufficient? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @Danie-1, sorry for the delay in reviewing this.
So the main thing I'd like to ask @abravalheri is whether you think it's worth doing the method I outlined above, or do you think the current implementation is sufficient?
Probably both proposals have their merit (thank you very much for investigating them). I believe that build_type_information
would the most "semantically elegant" because it stops considering type information files as "data-files". However, as you mentioned the inclusion of the files would start to be non-optional... Therefore the approach with data-files
seems to be the one that leaves a escape hatch for users to opt-out (and it is "backwards compatible" with the way users have been approaching the problem historically in setuptools).
We can give it a try to the implementation you have already submitted and see how it goes. In the first stage we can make sure the feature is documented as "beta" (both in the docs and in the changelog), after some months of experimentation we can promote out of beta. What do you think?
Regarding the CI errors, I believe you can simply rebase in the latest |
I've pushed a commit to fix the tests on windows. |
I think this is good enough for trying out. @Danie-1 please let me know if you want to do any other changes, otherwise I think we can merge, so it can be included in the next release (not sure if it is going to happen next week, maybe in the beginning of November). |
That sounds like a good plan to me. I don't have any suggestions for changes, other than a typo fix that I've just pushed. |
Thank you very much @Danie-1. |
We just ran into the issue that .pyi files are not added to our packages by default. It would be relatively easy to handle on our side, but I'm glad to see this has already been solved out of the box (and looks like right on time for us). Thank you for this. Do you have an idea when this will be released? |
Hi @zhegata please have a look on the comment above: #4021 (comment) |
Summary of changes
When getting source files, include py.typed and *.pyi as well as py files.
Closes #3136
Pull Request Checklist
newsfragments/
.(See documentation for details)