Skip to content

Fix env duplication on merged-usr systems #200

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

elprans
Copy link
Contributor

@elprans elprans commented Mar 13, 2025

On modern (merged-usr) Linux systems, /bin, /sbin and /usr/sbin
are symlinks to /usr/bin. There is no point in reporting the same
Python installation four times, so canonicalize search paths before
searching.

Before:

Breakdown for finding Environments:
-----------------------------------
GlobalVirtualEnvs    : 17.412201ms
Locators             : 225.284494ms
Path                 : 433.162905ms
Workspaces           : 2.161556ms

Environments (41):
------------------
GlobalPaths          : 14
LinuxGlobal          : 16
VirtualEnvWrapper    : 11

After:

Breakdown for finding Environments:
-----------------------------------
GlobalVirtualEnvs    : 16.595382ms
Locators             : 223.759511ms
Path                 : 313.276036ms
Workspaces           : 1.418024ms

Environments (21):
------------------
GlobalPaths          : 2
LinuxGlobal          : 8
VirtualEnvWrapper    : 11

On modern (merged-usr) Linux systems, `/bin`, `/sbin` and `/usr/sbin`
are symlinks to `/usr/bin`.  There is no point in reporting the same
Python installation four times, so canonicalize search paths before
searching.

Before:

	Breakdown for finding Environments:
	-----------------------------------
	GlobalVirtualEnvs    : 17.412201ms
	Locators             : 225.284494ms
	Path                 : 433.162905ms
	Workspaces           : 2.161556ms

	Environments (41):
	------------------
	GlobalPaths          : 14
	LinuxGlobal          : 16
	VirtualEnvWrapper    : 11

After:

	Breakdown for finding Environments:
	-----------------------------------
	GlobalVirtualEnvs    : 16.595382ms
	Locators             : 223.759511ms
	Path                 : 313.276036ms
	Workspaces           : 1.418024ms

	Environments (21):
	------------------
	GlobalPaths          : 2
	LinuxGlobal          : 8
	VirtualEnvWrapper    : 11
@DonJayamanne
Copy link
Collaborator

@elprans
FYI, some test failures.

@elprans
Copy link
Contributor Author

elprans commented Mar 26, 2025

@elprans FYI, some test failures.

@DonJayamanne, the verify_python_in_jupyter_contaner test fails because in that container /home/codespace/.python/current is a symlink to /usr/local/python/current which is itself a symlink to /usr/local/python/3.10.13. Canonicalization made it return the latter whereas the test expects the former two.

Technically, symlinked Python prefixes aren't real distinct installations (which is the point of this PR), but if it's important to return an uncanonicalized executable path for some reason, we can narrow the scope of this change to just canonicalize /bin, /usr/bin and friends.

@elprans
Copy link
Contributor Author

elprans commented Apr 8, 2025

@DonJayamanne, any feedback on the above? I've modified the tests to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants