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

Doc example of pyproject.toml file for adding extras mismatches with behavior of poetry add <package> -E <extra> #1339

Closed
1 task done
esciara opened this issue Aug 29, 2019 · 3 comments

Comments

@esciara
Copy link

esciara commented Aug 29, 2019

  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

The extras section in the pyproject.toml file's doc page seem incorrect.

It states:

[tool.poetry.dependencies]
# These packages are mandatory and form the core of this package’s distribution.
mandatory = "^1.0"

# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
psycopg2 = { version = "^2.7", optional = true }
mysqlclient = { version = "^1.3", optional = true }

[tool.poetry.extras]
mysql = ["mysqlclient"]
pgsql = ["psycopg2"]

But when performing a poetry add psycopg2 -E pgsql and poetry add mysqlclient -E mysql to recreate this example, it actually generates the following in the pyproject.toml file:

[tool.poetry.dependencies]
# These packages are mandatory and form the core of this package’s distribution.
mandatory = "^1.0"

# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
psycopg2 = {version = "^2.7", extras = ["pgsql"]}
mysqlclient = {version = "^1.3", extras = ["mysql"]}

# No [tool.poetry.extras] section

If one adds manually the extras as stated in the doc, then poetry install -E psycopg2 will not work and will throw the message:

[ValueError]
Extra [psycopg2] is not specified.

Can create a PR for this if the problem is confirmed.

@esciara esciara changed the title Example of pyproject.toml file for adding extras is incorrect Doc example of pyproject.toml file for adding extras mismatches with behavior of poetry add <package> -E <extra> Aug 29, 2019
@esciara
Copy link
Author

esciara commented Aug 29, 2019

Looks like the doc might be correct and poetry add <package> -E <extra> does not work properly. See #1340 (comment).

@esciara
Copy link
Author

esciara commented Aug 29, 2019

Closing as -E defines the extras to activate for the dependency, not to declare an extra for the package. There is no option on the cli to do that. Ongoing discussion to eventually create one.

See #1145 (comment).

@esciara esciara closed this as completed Aug 29, 2019
Copy link

github-actions bot commented Mar 3, 2024

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 Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant