-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
poetry export -f requirements.txt adds extras to the extras. #1313
Comments
in #1293 @tommilligan mentioned that the issue was introduced somewhere between 442ff52 and e987f01. |
Looking at the changes, it might be because of the changes in #1277 |
This following patch adds a failing test against Can be run with diff --git a/tests/utils/test_exporter.py b/tests/utils/test_exporter.py
index 0ca7b1a..04b25ed 100644
--- a/tests/utils/test_exporter.py
+++ b/tests/utils/test_exporter.py
@@ -309,6 +309,58 @@ foo==1.2.3 \\
assert expected == content
+def test_exporter_exports_requirements_txt_with_extras(tmp_dir, poetry):
+ poetry.locker.mock_lock_data(
+ {
+ "package": [
+ {
+ "name": "foo",
+ "version": "1.2.3",
+ "category": "main",
+ "optional": False,
+ "python-versions": "*",
+ "extras": {"feature_bar": ["bar (>=4.5.0)"]},
+ "dependencies": {
+ "bar": {"optional": True, "version": ">=4.5.0"}
+ },
+ },
+ {
+ "name": "bar",
+ "version": "4.5.6",
+ "category": "main",
+ "optional": False,
+ "python-versions": "*",
+ "marker": "extra == \"bar\""
+ },
+ ],
+ "metadata": {
+ "python-versions": "*",
+ "content-hash": "123456789",
+ "hashes": {"foo": ["12345"], "bar": ["67890"]},
+ },
+ }
+ )
+ exporter = Exporter(poetry)
+
+ exporter.export(
+ "requirements.txt",
+ Path(tmp_dir),
+ "requirements.txt",
+ dev=False,
+ )
+
+ with (Path(tmp_dir) / "requirements.txt").open(encoding="utf-8") as f:
+ content = f.read()
+
+ expected = """\
+bar==4.5.6 \\
+ --hash=sha256:67890
+foo==1.2.3 \\
+ --hash=sha256:12345
+"""
+
+ assert expected == content
+
def test_exporter_can_export_requirements_txt_with_git_packages(tmp_dir, poetry):
poetry.locker.mock_lock_data( |
Seeing your test made me think about the lock file:
So maybe the bug is that the lock file has the extra marker there for the thing that is the extra instead of the package where is was given? |
Bit sad that 1.0.0b2 still didn't fix the extra marker on the extra in the lock file. (talikng about the The marker is for the original package, not for the package that gets installed because of it. |
FWIW, this still appears to be an issue in 1.0.0b3 |
I did a lot of thinking on this. The extras are just there to tell the package which other optional dependencies to install and let the package decide on the versions. But when installing from the lock file or exported requirements.txt it should be ignored because those optional dependencies are already resolved and added, so the extra's should just be removed. As a fix for now I moved those extra dependencies to my own pyproject.toml file, but this means I need to manage those myself when the main package updates. |
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. |
-vvv
option).Issue
When you have a dependency with extra's in your pyproject.toml and you export it to a requirements.txt file the extras argument get's added to the dependency itself:
pyproject.toml
Then when I do a poetry export -f requirements.txt the output is:
Which then when I try to pip install it results in:
This does not happen in 1.0.0a5, so I reverted back for now.
The text was updated successfully, but these errors were encountered: