-
Notifications
You must be signed in to change notification settings - Fork 255
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
fix: do not ignore dynamic project dependencies via tool.poetry.dependencies
if project.optional-dependencies
are defined
#811
Merged
radoering
merged 2 commits into
python-poetry:main
from
radoering:optional-and-dynamic-deps
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
My Package | ||
========== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
[project] | ||
name = "my-package" | ||
version = "1.2.3" | ||
description = "Some description." | ||
readme = "README.rst" | ||
requires-python = ">=3.6" | ||
license = { text = "MIT" } | ||
keywords = ["packaging", "dependency", "poetry"] | ||
authors = [ | ||
{ name = "Sébastien Eustace", email = "[email protected]" } | ||
] | ||
maintainers = [ | ||
{ name = "Sébastien Eustace", email = "[email protected]" } | ||
] | ||
dynamic = [ "version", "readme", "dependencies", "classifiers" ] | ||
|
||
[project.optional-dependencies] | ||
db = [ | ||
"orator ~=0.9" | ||
] | ||
network = [ | ||
"requests[security] ~=2.18" | ||
] | ||
|
||
[project.urls] | ||
homepage = "https://python-poetry.org" | ||
repository = "https://github.com/python-poetry/poetry" | ||
documentation = "https://python-poetry.org/docs" | ||
|
||
[project.scripts] | ||
my-script = "my_package:main" | ||
|
||
[tool.poetry] | ||
version = "1.2.3" | ||
readme = "README.rst" | ||
classifiers = [ | ||
"Topic :: Software Development :: Build Tools", | ||
"Topic :: Software Development :: Libraries :: Python Modules" | ||
] | ||
|
||
# Requirements | ||
[tool.poetry.dependencies] | ||
python = ">=3.6" | ||
cleo = "^0.6" | ||
pendulum = { git = "https://github.com/sdispater/pendulum.git", branch = "2.0" } | ||
tomlkit = { git = "https://github.com/sdispater/tomlkit.git", rev = "3bff550", develop = true } | ||
pathlib2 = { version = "^2.2", python = "~2.7" } | ||
|
||
# File dependency | ||
demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" } | ||
|
||
# Dir dependency with setup.py | ||
my-package = { path = "../project_with_setup/" } | ||
|
||
# Dir dependency with pyproject.toml | ||
simple-project = { path = "../simple_project/" } | ||
|
||
# Dependency with markers | ||
functools32 = { version = "^3.2.3", markers = "python_version ~= '2.7' and sys_platform == 'win32' or python_version in '3.4 3.5'" } | ||
|
||
# Dependency with python constraint | ||
dataclasses = { version = "^0.7", python = ">=3.6.1,<3.7" } | ||
|
||
|
||
# Non-regression test for https://github.com/python-poetry/poetry-core/pull/492. | ||
# The underlying issue occurred because `tomlkit` can either return a TOML table as `Table` instance or an | ||
# `OutOfOrderProxy` one, if a table is discontinuous and multiple sections of a table are separated by a non-related | ||
# table, but we were too strict in our type check assertions. | ||
# So adding `tool.black` here ensure that we have discontinuous tables, so that we don't re-introduce the issue caused | ||
# by the type check assertion that ended up being reverted. | ||
[tool.black] | ||
preview = true | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "~3.4" | ||
|
||
|
||
[tool.poetry.scripts] | ||
my-script = "my_package:main" | ||
|
||
|
||
[tool.poetry.plugins."blogtool.parsers"] | ||
".rst" = "some_module::SomeClass" |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2018 Sébastien Eustace | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
My Package | ||
========== |
3 changes: 3 additions & 0 deletions
3
tests/masonry/builders/fixtures/complete_dynamic/bin/script.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Hello World!" |
1 change: 1 addition & 0 deletions
1
tests/masonry/builders/fixtures/complete_dynamic/my_package/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "1.2.3" |
1 change: 1 addition & 0 deletions
1
tests/masonry/builders/fixtures/complete_dynamic/my_package/data1/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg2/data2/data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Empty file.
62 changes: 62 additions & 0 deletions
62
tests/masonry/builders/fixtures/complete_dynamic/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[project] | ||
name = "my-package" | ||
version = "1.2.3" | ||
description = "Some description." | ||
requires-python = ">=3.6,<4.0" | ||
license = { "text" = "MIT" } | ||
authors = [ | ||
{ "name" = "Sébastien Eustace", "email" = "[email protected]" } | ||
] | ||
maintainers = [ | ||
{ name = "People Everywhere", email = "[email protected]" } | ||
] | ||
keywords = ["packaging", "dependency", "poetry"] | ||
dynamic = [ "version", "classifiers", "readme", "dependencies" ] | ||
|
||
[project.optional-dependencies] | ||
time = [ "pendulum>=1.4,<2.0 ; python_version ~= '2.7' and sys_platform == 'win32' or python_version in '3.4 3.5'" ] | ||
|
||
[project.urls] | ||
homepage = "https://python-poetry.org/" | ||
repository = "https://github.com/python-poetry/poetry" | ||
documentation = "https://python-poetry.org/docs" | ||
"Issue Tracker" = "https://github.com/python-poetry/poetry/issues" | ||
|
||
[project.scripts] | ||
my-script = "my_package:main" | ||
my-2nd-script = "my_package:main2" | ||
extra-script = "my_package.extra:main" | ||
|
||
[project.entry-points."poetry.application.plugin"] | ||
my-command = "my_package.plugins:MyApplicationPlugin" | ||
|
||
|
||
[tool.poetry] | ||
version = "1.2.3" | ||
readme = "README.rst" | ||
|
||
classifiers = [ | ||
"Topic :: Software Development :: Build Tools", | ||
"Topic :: Software Development :: Libraries :: Python Modules" | ||
] | ||
|
||
exclude = [ | ||
"does-not-exist", | ||
"**/*.xml" | ||
] | ||
|
||
# Requirements | ||
[tool.poetry.dependencies] | ||
cleo = "^0.6" | ||
cachy = { version = "^0.2.0", extras = ["msgpack"] } | ||
|
||
[tool.poetry.dependencies.pendulum] | ||
version = "^1.4" | ||
markers = 'python_version ~= "2.7" and sys_platform == "win32" or python_version in "3.4 3.5"' | ||
optional = true | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "~3.4" | ||
|
||
[tool.poetry.scripts] | ||
file-script = { reference = "bin/script.sh", type = "file" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I understood what's going on here 💪 And it looks like it should work.
As far as I see, we don't take into account the
dynamic
key of theproject
section anywhere in our codebase. Instead we are doing educated guesses. Wouldn't it be easier to rely on this field?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first, I thought it is redundant. However, there is at least one use case where it is necessary:
Projects that do not have any mandatory dependencies but optional dependencies and use
tool.poetry.dependencies
to define sources for these optional dependencies. Without takingproject.dynamic
into account the dependencies intool.poetry.dependencies
would have been considered mandatory dependencies in this case.I added a second commit that takes
project.dynamic
into account to fix this use case.