-
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
Teach FawltyDeps to automatically discover Python environments inside the project #326
Conversation
626aa6c
to
b3d8bef
Compare
f8b8261
to
b6aa14e
Compare
b3d8bef
to
598c293
Compare
b6aa14e
to
935cf82
Compare
598c293
to
36a78ab
Compare
935cf82
to
6f455b1
Compare
🎉 All dependencies have been resolved ! |
76d61c8
to
12fadc0
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.
As usual Johan, your PRs are elegant, well written and are a great contribution to the project <3
I am posting a comment, not approval for now, as I have to go through tests and documentation. The comments are mostly nits or me making sure that I follow your line of thoughts :)
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 think this is good to go 🚀 🎸
In addition to finding/creating CodeSource and DepsSource objects in traverse_project.find_sources(), we now also add support for PyEnvSource objects. Each of these objects encapsulate a single directory within a Python environment where we expect to find Python packages installed. In addition to validating the settings.pyenvs paths (similar to what the LocalPackageResolver constructor already does), this also adds the logic to find new Python environments within the directories being traversed. That is, until now we have only supported entries in settings.pyenvs pointing directly to (a directory within) a Python environment, but with this commit we can also start finding Python environments beneath a given directory. In others words: given a project containing a ".venv" subdir, we previously needed 'pyenvs' to point directly at ".venv" in order to find this Python environment, but with this commit we can soon support 'pyenvs' pointing at the project root and still be able to automatically find ".venv" inside the project. Nothing of this is user-visible yet, as we still require the high-level business logic in fawltydeps.main to actually request, and use the new PyEnvSource objects created in this commit. Based on the recent additions to test_sample_projects and sample_projects, we add a bunch of tests to verify that we are able to both precisely specify which Python environments should be included in our analysis, as well as being able to automatically find and use many different Python environments given a more general specification.
This starts requesting PyEnvSource objects when we call traverse_project.find_sources(), and pass the paths from these object on to resolve_dependencies(). In other words, this commit is when we first start actually using the new traversal logic for Python environments in FawltyDeps. On the test side, we can finally remove the overly explicit specification needed to correctly traverse/parse the pyenv_galore sample project. Instead, this project is now successfully handled with default settings: - pyenvs set to the project root is able to auto-detect all the Python environments found within. - As a result, there is no code, nor any deps files found (since the project consists of Python environments only).
Update README.md to reflect that we're now using the _current_ Python environment (i.e. 'sys.path') only as an ultimate fallback when (a) `--pyenv` is not used, and (b) we're unable to find Python environments under 'basepath'. Update the related FAQs accordingly. Also update the --help text to reflect that `basepath` now also affect Python environment calculation.
Add descriptions of each instance member in our new *Source classes. Suggested-by: Maria Knorps <[email protected]>
The --code/--deps/--pyenv options was documented as defaulting to the current directory (which is only true when basepaths is not used), and basepaths was NOT documented as defaulting to the current directory. The correct way to document this (which reflects the actual logic in the code) is that --code/--deps/--pyenv all default to basepaths when not given, and that basepaths default to the current directory when not given. With this change, a casual reader might have to follow the reference from --code/--deps/--pyenv to basepaths to discover that the _ultimate_ default for these options is indeed the current directory. But at least the relationships involving basepaths are now _correctly_ reflected in out documentation. Suggested-by: Maria Knorps <[email protected]>
Suggested-by: Nour El Mawass <[email protected]>
488cf80
to
92f3f0d
Compare
This is a rather embarrasing omission from PR #326 (Teach FawltyDeps to automatically discover Python environments inside the project): Although that PR did include code to traverse within a given --pyenv path to find Python environments, the PR "forgot" to actually switch the _default_ behavior of --pyenv: The default value of settings.pyenvs remained an empty set, and there were no changes to have basepath influence the value of settings.pyenvs. This commit fixes that: - When neither --pyenv nor basepath is given, settings.pyenvs should default to the current directory. - When --pyenv is not given, but basepath is given, basepath should override the default settings.pyenvs. - When --pyenv is given, it overrides basepath. In short settings.pyenvs should behave exactly like .code and .deps.
This is a rather embarrasing omission from PR #326 (Teach FawltyDeps to automatically discover Python environments inside the project): Although that PR did include code to traverse within a given --pyenv path to find Python environments, the PR "forgot" to actually switch the _default_ behavior of --pyenv: The default value of settings.pyenvs remained an empty set, and there were no changes to have basepath influence the value of settings.pyenvs. This commit fixes that: - When neither --pyenv nor basepath is given, settings.pyenvs should default to the current directory. - When --pyenv is not given, but basepath is given, basepath should override the default settings.pyenvs. - When --pyenv is given, it overrides basepath. In short settings.pyenvs should behave exactly like .code and .deps.
(Depends on #325)
This is at the heart of solving #249, and IMHO one of the major pieces remaining in the Mapping Strategy milestone.
With this, FawltyDeps is able to:
basepath
).code
and.deps
Commits:
traverse_project
: Add support for finding/validating Python environmentsmain
: UsePyEnvSource
objects when resolving dependencies