-
Notifications
You must be signed in to change notification settings - Fork 16
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
Support multiple --pyenv
options
#321
Conversation
654103d
to
1b5204a
Compare
517775d
to
a10e43a
Compare
🎉 All dependencies have been resolved ! |
1b5204a
to
5c10aa5
Compare
5c10aa5
to
1c60455
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.
Looks great as usual!
There's nothing that blocks this PR per se. Just a couple small questions that I hope will be straightforward. I am also fine either way for the suggestions I made.
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.
Approving 🎉
I added comments to two conversations and resolved them.
This adds the core logic for FawltyDeps to become able to handle multiple --pyenv arguments. Instead of taking an optional 'pyenv_path', we now take a 'pyenv_paths' set of paths; the new behavior is an extension of the old: - An empty set (corresponds to pyenv_path == None) implies that we use sys.path to look up packages. - A single-element set (corresponds to pyenv_path != None) will use the Python environment found at that path instead. - A multi-element set (new in this commit) causes packages to be looked up in _all_ the given Python environments. For packages that occur in more than one of these environments, the resulting Package object will _merge_ all the imports found among the various copies of this package (similar to how we deal with the same package occurring across multiple user-defined mappings).
ed8b82a
to
4f26b83
Compare
This makes the support for multiple Python environment that was added to LocalPackageResolver in the previous commit available to the rest of FawltyDeps: - resolve_dependencies() now takes a pyenv_paths set instead of the previous optional pyenv_path. - Settings now has a 'pyenvs: Set[Path]' member instead of the previous 'pyenv: Optional[Path]' member. - The CLI parser now accepts _multiple_ --pyenv argument values and collects them all into the 'pyenvs' set, similar to what we already do for --code and --deps. - A new paragraph in README.md explains that multiple --pyenv options are accepted, and how they are merged into one coherent package-to- import-names mapping. - The list of configuration directives updates the description for 'pyenv' into 'pyenvs' accordingly.
In our --json output, we customize pydantic's JSON encoder to represent sets as sorted lists (thus yielding stable output). Do the same for when we generate TOML config output (which goes via a JSON encoding step, and thus is subject to the same issue with how sets are encoded). This was discovered while attempting to test how multiple 'pyenvs' were represented in our TOML output.
4f26b83
to
af07e8e
Compare
These are the commits that were originally part of #313, but now split into this PR.
Commits:
LocalPackageResolver
: Accept multiple pyenvs--pyenv
optionssettings.print_toml_config()
: Represent sets as sorted lists