-
Notifications
You must be signed in to change notification settings - Fork 17
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
Using _multiple_ Python environments to resolve deps -> packages -> imports? #249
Comments
I've just tried and it works. 👍
|
|
The remainder of this issue remains open, but will not be tackled in time for the current Mapping strategy milestone. |
The basic question here is: How can we maximize FawltyDeps' chances of finding a relevant
Package
that provides a useful dep name -> import names mapping, and minimize the cases where we fall back to the identity mapping?Currently we take one
--pyenv
option (or default to packages found viasys.path
, i.e. the environment where FD is installed).Ideas/tasks:
--pyenv
values (like we recently did for--code
anddeps
), to allow multiple environments to be queried. 1 This is being implemented in Prepare for supporting multiple--pyenv
options #313 and Support multiple--pyenv
options #321.--pyenv
s is not very friendly. We could instead walk the directory structure of the project (limited bybasepaths
and/or--pyenv
) and automatically discover all Python environments within, and add them to our analysis. 2 This is being implemented in Teach FawltyDeps to automatically discover Python environments inside the project #326.$PYTHONPATH
. Experiments reveal that$PYTHONPATH
is automatically reflected insys.path
(it is inserted before the system search paths, but after the current directory which shows up at the start ofsys.path
). As of now, the plan is for--pyenv
(and for auto-discovered pyenvs in the above point) to override the use ofsys.path
, in other words,sys.path
is only used as an ultimate fallback when no other Python environments are found, either via--pyenv
, or underbasepath
. The question then becomes whether we want to usesys.path
in addition to Python environments from--pyenv
/basepath
, and - if so - whether this should be automatic, or controlled by a user-visible option.pip install --user
places packages in a user-specific directory (e.g. under$HOME/.local/
)$HOME/.cache/pypoetry/virtualenvs/
pipx
places virtualenvs under$HOME/.local/pipx
.pip
, or by the distro./usr/lib/python?.*/site-packages
/usr/local/...
Where do we stop? How much is too much?
Rather, what are the disadvantages of adding more places to look for packages?
Footnotes
We can fairly straightforwardly extend our
resolve_dependencies()
to have a stack of multipleLocalPackageLookup
objects, one for each environment, and then query them in order until one of them returns a matchingPackage
object. The identity mapping can then be represented as aIdentityPackageLookup
object automatically placed at the bottom of this stack. The wayLocalPackageLookup
is currently written, we delay enumerating packages (i.e. walking the filesystem) until we actually need to look something up. Therefore, as long we put the most relevant virtualenvs near the top of the stack, we can probably avoid enumerating packages for the lower levels of the stack, and we can then have a fairly deep stack without necessarily paying the cost (in terms of enumerating less relevant virtualenvs). ↩If we auto-discover virtualenvs while walking the project directories, we should consider removing these from the
code
anddeps
, as they should probably not be considered part of the project itself, and thus shouldn't be scanned for imports/deps by FD. ↩The text was updated successfully, but these errors were encountered: