python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
30.46k stars 2.23k forks source link

Dependency aliasing #1715

Open blaggacao opened 4 years ago

blaggacao commented 4 years ago

Feature Request

Therefore, add [tool.poetry.dev-alternates] with exactly the same syntax as [tool.poetry.dependencies] yet with an optional aliases field on the dep object, to inform which production package's namespace is provided through this package during dev. If aliases is not specified, it shall be inferred by the dep name itself.

Example covering both cases:

[tool.poetry.dependencies]
python = "^3.7"
dodoo = "^2.0"
psycopg2 = "^2.8"

[tool.poetry.dev-alternates]
psycopg2-binary = {aliases = psycopg2, version = "^2.8"}
dodoo = {path = "../dodoo"}

Further considerations

toml file API

Merge strategy

I should be precise in that, it shall be expected to do a true merge of the objects, so -- strictly -- psycopg2-binary = {aliases = psycopg2, version = "^2.8"} could be written as just psycopg2-binary = {aliases = psycopg2}

CLI UX

From a UX perspectve, maybe the install --develop=DEVELOP has almost a 90% overlap in semantics with the requested feature. It would be an acceptable modification to current behaviour, if:


This FR collects a few FR in the issue catalogue, please reference them as you see fit.

blaggacao commented 4 years ago

Collects (at least):

rdozier-work commented 3 weeks ago

+1 on this, not sure why it hasn't been implemented yet

skewty commented 1 week ago

The psycopg2 example is indirectly solved / closed. This issue affects many other packages.

Here is another:

pip install nats-py
import nats
nc = await nats.connect("tls://demo.nats.io:4443")
[tool.poetry.dependencies]
nats-py = { version = "~2.8.0" }

https://github.com/nats-io/nats.py https://pypi.org/project/nats-py/

clintonroy commented 1 week ago

Please see the recent discussion around package variants on the python channels, once such an option is available in the wider eco system, poetry will be able to support it.