Skip to content

refactor the non_host part for not injecting to custom env#346

Merged
gaborbernat merged 3 commits intotox-dev:mainfrom
xiacunshun:fix_non_host_env
Apr 10, 2024
Merged

refactor the non_host part for not injecting to custom env#346
gaborbernat merged 3 commits intotox-dev:mainfrom
xiacunshun:fix_non_host_env

Conversation

@xiacunshun
Copy link
Copy Markdown
Collaborator

fix: #343

We can get the sitepackages directory from the given interpreter directly instead of running our code again with it.

@xiacunshun
Copy link
Copy Markdown
Collaborator Author

I think the result of this method is the same with the original one. Please take a look if you have time. @kemzeb

gaborbernat
gaborbernat previously approved these changes Apr 6, 2024
Copy link
Copy Markdown
Collaborator

@kemzeb kemzeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I noticed that when we're using a venv that has system site packages enabled (i.e. I did python -m venv --system-site-packages venv), running the following:

pipdeptree --python path/to/python --local-only

...would cause us to hit the else branch (since I am not running in a virtual environment). We don't want this since we will use paths to metadata from the entire environment.

I think what we need to do here is if --python and --local are given, we should grab the result of:

"str(py_path), "-c", "import sys, site; print(site.getsitepackages([sys.prefix]))"

...and pass it to distributions(). Otherwise, use sys.path.

@xiacunshun
Copy link
Copy Markdown
Collaborator Author

Hmm, I noticed that when we're using a venv that has system site packages enabled (i.e. I did python -m venv --system-site-packages venv), running the following:

pipdeptree --python path/to/python --local-only

...would cause us to hit the else branch (since I am not running in a virtual environment). We don't want this since we will use paths to metadata from the entire environment.

I think what we need to do here is if --python and --local are given, we should grab the result of:

"str(py_path), "-c", "import sys, site; print(site.getsitepackages([sys.prefix]))"

...and pass it to distributions(). Otherwise, use sys.path.

That's a really good situation which I didn't notice. I will add some tests to cover this too.

@xiacunshun xiacunshun force-pushed the fix_non_host_env branch 3 times, most recently from acbf7af to 8c54c10 Compare April 7, 2024 01:35
@xiacunshun xiacunshun force-pushed the fix_non_host_env branch 4 times, most recently from a1b013d to 76ff513 Compare April 8, 2024 13:12
@kemzeb
Copy link
Copy Markdown
Collaborator

kemzeb commented Apr 8, 2024

FYI once we merge this I'll make a 2.18.0 release.

@xiacunshun xiacunshun force-pushed the fix_non_host_env branch 2 times, most recently from d11e5e2 to 6432873 Compare April 9, 2024 02:57
@kemzeb
Copy link
Copy Markdown
Collaborator

kemzeb commented Apr 9, 2024

Can't see any other issues, so it looks like this is good to go. Will release 2.18.0 after merging

kemzeb
kemzeb previously approved these changes Apr 9, 2024
@kemzeb
Copy link
Copy Markdown
Collaborator

kemzeb commented Apr 10, 2024

Looks like we're good to go, releasing 2.18.0

@xiacunshun xiacunshun deleted the fix_non_host_env branch April 10, 2024 17:02
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.

test_custom_interpreter fails

3 participants