python-poetry / python-poetry/poetry
System site packages is not seen as a Python package
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
- Poetry version: Poetry master branch
- Python version: 3.8.10
- OS version and name: Pop!_OS 22.04 LTS
- pyproject.toml: toml file
- I am on the latest stable Poetry version, installed using a recommended method.
I am not because I want to use the patch introduced in commit 237dff088d348e110839367416ca659e85a691af - 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 (
-vvvoption) and have included the output below.
Issue
My poetry install consistently fails with the error
Directory /usr/local/lib/python3.8/dist-packages for torch does not seem to be a Python package
Here is the gist that shows the verbose output of the failure. None of the packages get installed
I am using an NVIDIA Pytorch container that has torch configured as I need it. I would like to use Poetry to manage my project. Ideally, I would like Poetry to handle everything except my torch and torchvision dependencies.
In order to achieve this, I am always sure to:
- run
poetry config virtualenvs.options.system-site-packages true - pin
torch = { version = "1.14.0a0+410ce96", allow-prereleases = true}in mypyproject.toml
When I run poetry lock, this is what the seection for torch looks like
...
[[package]]
name = "torch"
version = "1.14.0a0+410ce96"
description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration"
optional = false
python-versions = "*"
files = []
develop = false
[package.source]
type = "directory"
url = "../../usr/local/lib/python3.8/dist-packages"
...
This comment in in PR #8359 caught my eye.
IMO, it would be nice to have a test in
test_installed_repository.pythat checks that a package from system site packages does not havesource_type == "directory".
If a system site package was to be seen as a directory, would that mean this patch would fail?
I've tried to remove [package.source in the lock file and poetry install still fails. Here is the verbose output.
Removing just the source so that the lock file looks like:
[package.source]
url = "../../usr/local/lib/python3.8/dist-packages"
gives the same result.
Ultimately, I would like to pin my torch package in my toml file, use system-site-packages in my venv, not mess with the lock file, and have poetry accept my installation as a Python package that already exists and doesn't need to be updated/reinstalled
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with test_installed_repository.py and reproduce the issue using the provided pyproject.toml, system-site-packages setting, and poetry install -vvv. Trace how the system-installed torch path is represented in the lock file and installation checks. Done means Poetry accepts the existing torch and torchvision packages without requiring lock-file edits or reinstalling them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100