You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
poetry export and poetry install have the following identical arguments and documentation:
--without: The dependency groups to ignore. (multiple values allowed)
--with: The optional dependency groups to include. (multiple values allowed)
The way that poetry install works is as such: if you run poetry install without any additional parameters, it installs dependencies from the default group (under [tool.poetry.dependencies]) and all mandatory groups (I use the word mandatory in this post to specify groups that are not optional). You can customize this behaviour by excluding mandatory groups using --without or including optional groups using --with. This is intuitive, and is compatible with what the documentation for --with and --without parameters imply. However, this is not how poetry export works.
poetry export only exports dependencies from the default group (under [tool.poetry.dependencies]) and their sub-dependencies. Dependencies in optional AND mandatory groups are excluded from export, unless they are explicitly included using --with. There is no utility for --without, because all groups are excluded by default. This in incompatible with the documentation, inconsistent with other poetry commands especially poetry install, and counter-intuitive. I believe poetry export's behaviour should be changed to match that of poetry install.
Here is an example showing the issue. I have explicitly defined one of the groups as mandatory, but that is not strictly necessary. Groups that are not defined as optional are mandatory by default.
# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
[[package]]
name = "bottle"version = "0.12.25"description = "Fast and simple WSGI-framework for small web-applications."optional = falsepython-versions = "*"files = [
{file = "bottle-0.12.25-py3-none-any.whl", hash = "sha256:d6f15f9d422670b7c073d63bd8d287b135388da187a0f3e3c19293626ce034ea"},
{file = "bottle-0.12.25.tar.gz", hash = "sha256:e1a9c94970ae6d710b3fb4526294dfeb86f2cb4a81eff3a4b98dc40fb0e5e021"},
]
[[package]]
name = "colorama"version = "0.4.6"description = "Cross-platform colored terminal text."optional = falsepython-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"files = [
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
]
[[package]]
name = "multipart"version = "0.2.4"description = "Parser for multipart/form-data."optional = falsepython-versions = "*"files = [
{file = "multipart-0.2.4-py3-none-any.whl", hash = "sha256:5aec990820b8a9e94f9c164fbeb58cf118cfbde2854865b67a9a730edd1fb9d1"},
{file = "multipart-0.2.4.tar.gz", hash = "sha256:06ba205360bc7096fefe618e4f1e9b2cdb890b4f2157053a81f386912a2522cb"},
]
[metadata]
lock-version = "2.0"python-versions = "^3.11"content-hash = "5f9c8003cc21f00ff4bda58eceedf883f970eae295a97350bc93d2d6721815ea"
Now if I poetry install without any additional arguments, bottle and colorama are installed—the former is a default dependency and the latter is in a mandatory group. However, multipart—which is in an optional group—is not installed unless explicitly included using --with.
$ poetry install
Installing dependencies from lock file
Package operations: 2 installs, 0 updates, 0 removals
• Installing bottle (0.12.25)
• Installing colorama (0.4.6)
Installing the current project: poetry_export_groups (0.1.0)
However, when I try exporting requirements, mandatory dependencies (in our case colorama, which is in a mandatory group) are not included in the export by default. Contrary to what the documentation says, --with is required for optional AND mandatory groups, making it inconsistent with other poetry commands and its behaviour counter-intuitive.
I am using Poetry 1.7.1 and poetry-plugin-export 1.6.0
The text was updated successfully, but these errors were encountered:
hoorzad
changed the title
Non-optional dependencies are not exported by default
Dependencies in mandatory groups are not exported by default
Jan 12, 2024
poetry export
andpoetry install
have the following identical arguments and documentation:--without
: The dependency groups to ignore. (multiple values allowed)--with
: The optional dependency groups to include. (multiple values allowed)The way that
poetry install
works is as such: if you runpoetry install
without any additional parameters, it installs dependencies from the default group (under[tool.poetry.dependencies]
) and all mandatory groups (I use the word mandatory in this post to specify groups that are not optional). You can customize this behaviour by excluding mandatory groups using--without
or including optional groups using--with
. This is intuitive, and is compatible with what the documentation for--with
and--without
parameters imply. However, this is not howpoetry export
works.poetry export
only exports dependencies from the default group (under[tool.poetry.dependencies]
) and their sub-dependencies. Dependencies in optional AND mandatory groups are excluded from export, unless they are explicitly included using--with
. There is no utility for--without
, because all groups are excluded by default. This in incompatible with the documentation, inconsistent with other poetry commands especiallypoetry install
, and counter-intuitive. I believepoetry export
's behaviour should be changed to match that ofpoetry install
.Here is an example showing the issue. I have explicitly defined one of the groups as mandatory, but that is not strictly necessary. Groups that are not defined as optional are mandatory by default.
pyproject.toml:
I run
poetry lock
to create poetry.lock:Now if I
poetry install
without any additional arguments,bottle
andcolorama
are installed—the former is a default dependency and the latter is in a mandatory group. However,multipart
—which is in an optional group—is not installed unless explicitly included using--with
.However, when I try exporting requirements, mandatory dependencies (in our case
colorama
, which is in a mandatory group) are not included in the export by default. Contrary to what the documentation says,--with
is required for optional AND mandatory groups, making it inconsistent with other poetry commands and its behaviour counter-intuitive.I am using Poetry 1.7.1 and poetry-plugin-export 1.6.0
The text was updated successfully, but these errors were encountered: