-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add Support for Dynamic Dependencies in pyproject.toml #351
Add Support for Dynamic Dependencies in pyproject.toml #351
Conversation
37d1889
to
222443f
Compare
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.
(Not a full review, but I had some free minutes, and wanted to take a quick look...)
I love how this is coming together, and how little code you have to change to make this work. 😃
One question:
Should we check/require the project.dynamic
directive before looking at the tool.setuptools.dynamic
? I'm looking at https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html to understand how this should work, and it seems to me that tool.setuptools.dynamic
should not be looked at when the corrsponding key in project.dynamic
is missing?
@jherland Thanks for the review!
Yes I've also spotted this issue. What I was thinking is that it takes the "same" effort to look at either |
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.
Looks good so far! I think the tests will help us see better if anything is missing.
As I said offline, being able to add these requirements files to the traversal object would have been a neat solution but we unfortunately don't have a direct way to append to the list of dependencies files to traverse from this function.
I believe we should look at
I agree that we currently do not have a good way to feed this information back into the traversal. But I don't know if it would be very useful to update the traversal, since the traversal phase is already done/finished before we parse this Currently, since we don't parse files during the traversal phase, we would not expect these extra requirements files to show up in the If we really want them to show up in |
@jherland, I don't think it's worth the hassle really (i.e. parsing pyproject.toml in the traversal stage). On principle, yes, I think these requirements files should appear in the sources. You're getting the requirements in these files by parsing them, and not directly from pyproject.toml so I would argue they are a direct source. But I don't think this is worth spending any time on. |
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.
I'd just like to say I really admire the way you've been able to get up and running on the test suite!
Great work!
I've left a couple of comments. Some are nitpicky (and I flagged them as such) but others would need more consideration.
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.
As @Nour-Mws already said: Great work, and I'm also impressed by how quickly you're getting up to speed with everything here. 😄
There's still some way to go before all the corner cases have been covered, I think, and adding more test cases is IMHO the key to getting there. Therefore I'm not too worried about spending some time/discussion to get the basic test infrastructure right. It is clear that you have uncovered some missing pieces in the fake_project
fixture, and I think getting those parts right will make it much easier to add more tests.
With PR #354 merged, the CI should now pass once this is rebased on main. |
72aa2cd
to
4242069
Compare
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.
There's one discussion where I just posted a comment, and left unresolved. Except for that, I think all other comments have been resolved, and I'm very happy to see this merged. 😄 Great work!
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.
This is ready to be merged!
…ing-build-by-setuptools
* Parse tool.setuptools.dynamic section in pyprojecttoml * Fix lint line-too-long * Fix format * Add unit tests for dynamic dependencies * Check if dynamic is in "[poject]" first in pyproject.toml * Apply reviews * Put codes in a separate helper parse_dynamic_pyproject_contents * Parse dynamic fields after parsing pep621 pyproject contents * Remove is_dynamic in create_one_fake_project and hardcoding in tests * Add tests for parsing regular and dynamic sources from pyprojecttoml * Fix logic of parsing pep621 and dynamic codes and update tests * Add two more tests for parsing dynamic deps and opt deps
Closes #347
Description
This PR introduces support for dynamic dependencies declared in the
pyproject.toml
file undertool.setuptools.dynamic
section.In the past, our project had a feature where it did not recurse into subdirectories under the project root (
.
) to detect requirements files. This PR enables our project to detect requirements files located in any directory as long as they are declared undertool.setuptools.dynamic
section.Changes
Usage
In your project's
pyproject.toml
file, define dynamic dependencies under thetool.setuptools.dynamic
section viasetuptools
orsetuptools-scm
. For example:Run
fawltydeps
under your project as usual. The PR introduces support for dynamic dependencies, and they will be automatically detected and processed.Testing
Adding unit tests is still WIP.