Skip to content
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

virtualenvs.options.system-site-packages doesn't work as expected #8493

Closed
4 tasks done
niniack opened this issue Oct 1, 2023 · 3 comments
Closed
4 tasks done

virtualenvs.options.system-site-packages doesn't work as expected #8493

niniack opened this issue Oct 1, 2023 · 3 comments
Labels
kind/bug Something isn't working as expected

Comments

@niniack
Copy link

niniack commented Oct 1, 2023

  • Poetry version: Poetry (version 1.7.0.dev0) and Poetry (version 1.6.1)
  • Python version: 3.8.10
  • OS version and name: Pop!_OS 22.04 LTS
  • pyproject.toml:
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

To reproduce

Create a Dockerfile

# Start from the NVIDIA PyTorch image
FROM nvcr.io/nvidia/pytorch:22.12-py3

ENV DEBIAN_FRONTEND=noninteractive

# Set Poetry variables
# The system site packages are important because we are using docker to give 
# us torch!
ENV POETRY_NO_INTERACTION=1 \
    POETRY_VIRTUALENVS_IN_PROJECT=1 \
    POETRY_VIRTUALENVS_CREATE=1 \
    POETRY_CACHE_DIR=/tmp/poetry_cache \
    POETRY_HOME=/opt/poetry \
    POETRY_VIRTUALENVS_OPTIONS_SYSTEM_SITE_PACKAGES=1

WORKDIR /library

# Install poetry with pinned version
RUN pip install git+https://github.com/python-poetry/poetry.git@master
ENV PATH="$PATH:$POETRY_HOME/bin"

Build and run docker container

docker build -t library .
docker run -it -v "$(pwd):/library" library

Verify that poetry system-site-packages is set to true

root@5c60f989a2c5:/library# poetry config --list
cache-dir = "/root/.cache/pypoetry"  # /tmp/poetry_cache
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = true
virtualenvs.path = "{cache-dir}/virtualenvs"  # /tmp/poetry_cache/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"

Also check the config of virtualenv

root@5c60f989a2c5:/library# cat .venv/pyvenv.cfg 
home = /usr/bin
implementation = CPython
version_info = 3.8.10.final.0
virtualenv = 20.24.5
include-system-site-packages = false
base-prefix = /usr
base-exec-prefix = /usr
base-executable = /usr/bin/python3.8
prompt = continualutils-py3.8

Check python paths

root@5c60f989a2c5:/library# python -c "import sys; print(sys.path)"
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

root@5c60f989a2c5:/library# poetry run python -c "import sys; print(sys.path)"
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/library/.venv/lib/python3.8/site-packages']

Import torch

root@5c60f989a2c5:/library# python -c "import torch; print(torch.__version__)"
1.14.0a0+410ce96

root@5c60f989a2c5:/library# poetry run python -c "import torch; print(torch.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'

Issue

Hi,

I believe this is related to issue #6035, which has been closed by PR #8359. This is why I've tried this on both the 1.6.1 release as well as the master branch (1.7.0.dev0), but I get exactly the same results. Given that I have set POETRY_VIRTUALENVS_OPTIONS_SYSTEM_SITE_PACKAGES=1 and verified that virtualenvs.options.system-site-packages=true, I expect that:

  1. the output of poetry run python -c "import sys; print(sys.path)" should include /usr/local/lib/python3.8/dist-packages
  2. include-system-site-packages = false in pyenv.cfg should be true
  3. importing torch should work with poetry run python

However, when I go in and manually update pyenv.cfg include-system-site-packages = true, then

root@5c60f989a2c5:/library# poetry run python -c "import torch; print(torch.__version__)"
1.14.0a0+410ce96

works as expected. However, I feel like I shouldn't be touching that file, right? It seems like I'm doing something that could potentially have some issues?

@niniack niniack added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 1, 2023
@dimbleby
Copy link
Contributor

dimbleby commented Oct 1, 2023

duplicate #5906

@niniack
Copy link
Author

niniack commented Oct 1, 2023

Oh, thank you for the find, it seems like I did a poor job looking through past issues. I will try to configure it another way and see if the issue still persists. Although, toggling between 0 and 1 for POETRY_VIRTUALENVS_OPTIONS_SYSTEM_SITE_PACKAGES did change the output of poetry config --list

@niniack niniack closed this as completed Oct 1, 2023
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
@abn abn removed the status/triage This issue needs to be triaged label Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants