-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
- Poetry version: 1.5.1
- Python version: 3.10.12
- OS version and name: MacOS 12.6.8
- 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 (
-vvvoption) and have included the output below. N/A
Issue
When I started writing this, I thought the issue was different - now I think I see what's happening.
In a clean project for which poetry.lock has never been run before, poetry works as expected.
However, the results of poetry lock seem to be influenced by poetry's cache (somehow), since in an existing project, where poetry has successfully done lock before, it does not seem to be possible to tell poetry to limit where it looks for a given dependency.
Let's say we have the following pyproject.toml in a clean, new project, and that my_dep is only available in private repo privaterepo:
[tool.poetry]
name = "my-project"
version = "0.1.0"
description = ""
authors = ["Jeff Lerman <[email protected]>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10.0"
my-dep = {version = "^0.8.2", source = "PyPI"}
[[tool.poetry.source]]
name = "private_repo"
url = "https://repo.shared.privaterepo.com/repository/pypi-privaterepo/simple"
priority = "explicit"
[[tool.poetry.source]]
name = "PyPI"
priority = "supplemental"
[build-system]
requires = ["poetry-core>=1.4.0"]
build-backend = "poetry.core.masonry.api"
poetry lock correctly tells us:
Because my-project depends on my-dep (^0.8.2) which doesn't match any versions, version solving failed.
But now if we:
- change the
pyproject.tomlto indicate the correct source (private_repo) - run
poetry lock(completes successfully) - run
poetry install(this is key!!) - change
pyproject.tomlback to the wrong source (PyPI) - run
poetry lock
Then there is no failure anymore. We get the following clause in the resulting poetry.lock:
[[package]]
name = "my-dep"
version = "0.8.3"
description = "this is a very private package"
optional = false
python-versions = "*"
files = []
So, poetry is seeing the dependency in its local cache (somehow), using that to decide that it's a valid package, but not getting any metadata for it except the version & description - and populating an awfully sparse-looking poetry.lock clause.
That means there's no way to tell poetry, once a package has been found and installed (presumably, from any repo) that now we want to install it from a specific private repo - also no way to ensure that we've completely locked down the source for packages that we want to only ever come from our private repo.
I noticed this when trying to upgrade existing projects to the new poetry 1.5.x style of specifying sources, and not getting failures when I should have been.