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

PoC: automatically create a pinned extra with dependencies pinned from the lock file #9428

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

radoering
Copy link
Member

@radoering radoering commented May 20, 2024

Pull Request Check List

Related-to: #7990
Requires: #9427

  • Added tests for changed code.
  • Updated documentation for changed code.

⚠️ This is a bit hacky and just a demonstration what's possible with #9427. I'm not even sure if we want such a feature or if it is better suited for a plugin...

It requires a lock file created with #9427 (which is included in this PR).

When running poetry build, an extra named pinned is automatically created1. This extra requires the exact version of all locked dependencies from the main group. Since #9427 writes the resulting markers into the lock file, we can add the correct markers for each extra dependency.

Example core metadata generated for Poetry itself:

core metadata of Poetry with `pinned` extra
...
Provides-Extra: pinned
Requires-Dist: build (==1.2.1) ; extra == "pinned"
Requires-Dist: build (>=1.2.1,<2.0.0)
Requires-Dist: cachecontrol (==0.14.0) ; extra == "pinned"
Requires-Dist: cachecontrol[filecache] (>=0.14.0,<0.15.0)
Requires-Dist: certifi (==2024.2.2) ; extra == "pinned"
Requires-Dist: cffi (==1.16.0) ; extra == "pinned" and (sys_platform == "linux" and platform_python_implementation != "PyPy" or sys_platform == "darwin")
Requires-Dist: charset-normalizer (==3.3.2) ; extra == "pinned"
Requires-Dist: cleo (==2.1.0) ; extra == "pinned"
Requires-Dist: cleo (>=2.1.0,<3.0.0)
Requires-Dist: colorama (==0.4.6) ; extra == "pinned" and os_name == "nt"
Requires-Dist: crashtest (==0.4.1) ; extra == "pinned"
Requires-Dist: cryptography (==42.0.3) ; extra == "pinned" and sys_platform == "linux"
Requires-Dist: distlib (==0.3.8) ; extra == "pinned"
Requires-Dist: dulwich (==0.21.7) ; extra == "pinned"
Requires-Dist: dulwich (>=0.21.2,<0.22.0)
Requires-Dist: fastjsonschema (==2.19.1) ; extra == "pinned"
Requires-Dist: fastjsonschema (>=2.18.0,<3.0.0)
Requires-Dist: filelock (==3.13.1) ; extra == "pinned"
Requires-Dist: idna (==3.6) ; extra == "pinned"
Requires-Dist: importlib-metadata (==7.0.1) ; extra == "pinned" and python_version < "3.12"
Requires-Dist: importlib-metadata (>=4.4) ; python_version < "3.10"
Requires-Dist: importlib-resources (==6.1.1) ; extra == "pinned" and python_version < "3.9"
Requires-Dist: installer (==0.7.0) ; extra == "pinned"
Requires-Dist: installer (>=0.7.0,<0.8.0)
Requires-Dist: jaraco-classes (==3.3.1) ; extra == "pinned"
Requires-Dist: jeepney (==0.8.0) ; extra == "pinned" and sys_platform == "linux"
Requires-Dist: keyring (==24.3.1) ; extra == "pinned"
Requires-Dist: keyring (>=24.3.1,<25.0.0)
Requires-Dist: more-itertools (==10.2.0) ; extra == "pinned"
Requires-Dist: msgpack (==1.0.7) ; extra == "pinned"
Requires-Dist: packaging (==24.0) ; extra == "pinned"
Requires-Dist: packaging (>=24.0)
Requires-Dist: pexpect (==4.9.0) ; extra == "pinned"
Requires-Dist: pexpect (>=4.7.0,<5.0.0)
Requires-Dist: pkginfo (==1.10.0) ; extra == "pinned"
Requires-Dist: pkginfo (>=1.10,<2.0)
Requires-Dist: platformdirs (==4.2.0) ; extra == "pinned"
Requires-Dist: platformdirs (>=3.0.0,<5)
Requires-Dist: poetry-core @ git+https://github.com/radoering/poetry-core.git@markers/reduce-by-python-constraint
Requires-Dist: poetry-core @ git+https://github.com/radoering/poetry-core.git@markers/reduce-by-python-constraint ; extra == "pinned"
Requires-Dist: poetry-plugin-export (==1.8.0) ; extra == "pinned"
Requires-Dist: poetry-plugin-export (>=1.8.0,<2.0.0)
Requires-Dist: ptyprocess (==0.7.0) ; extra == "pinned"
Requires-Dist: pycparser (==2.21) ; extra == "pinned" and (sys_platform == "linux" and platform_python_implementation != "PyPy" or sys_platform == "darwin")
Requires-Dist: pyproject-hooks (==1.0.0) ; extra == "pinned"
Requires-Dist: pyproject-hooks (>=1.0.0,<2.0.0)
Requires-Dist: pywin32-ctypes (==0.2.2) ; extra == "pinned" and sys_platform == "win32"
Requires-Dist: rapidfuzz (==3.6.1) ; extra == "pinned"
Requires-Dist: requests (==2.31.0) ; extra == "pinned"
Requires-Dist: requests (>=2.26,<3.0)
Requires-Dist: requests-toolbelt (==1.0.0) ; extra == "pinned"
Requires-Dist: requests-toolbelt (>=1.0.0,<2.0.0)
Requires-Dist: secretstorage (==3.3.3) ; extra == "pinned" and sys_platform == "linux"
Requires-Dist: shellingham (==1.5.4) ; extra == "pinned"
Requires-Dist: shellingham (>=1.5,<2.0)
Requires-Dist: tomli (==2.0.1) ; extra == "pinned" and python_version < "3.11"
Requires-Dist: tomli (>=2.0.1,<3.0.0) ; python_version < "3.11"
Requires-Dist: tomlkit (==0.12.3) ; extra == "pinned"
Requires-Dist: tomlkit (>=0.11.4,<1.0.0)
Requires-Dist: trove-classifiers (==2024.1.31) ; extra == "pinned"
Requires-Dist: trove-classifiers (>=2022.5.19)
Requires-Dist: urllib3 (==2.2.0) ; extra == "pinned"
Requires-Dist: virtualenv (==20.25.0) ; extra == "pinned"
Requires-Dist: virtualenv (>=20.23.0,<21.0.0)
Requires-Dist: xattr (==1.1.0) ; extra == "pinned" and sys_platform == "darwin"
Requires-Dist: xattr (>=1.0.0,<2.0.0) ; sys_platform == "darwin"
Requires-Dist: zipp (==3.17.0) ; extra == "pinned" and python_version < "3.12"
...

1 For the PoC, the extra is always created. If we decide to add this feature, we should introduce a flag, which is disabled by default.

…ting locked markers) (python-poetry#9427)

- introduce "installer.re-resolve" config option (default: True)
- if the config option is set to False and the lock file is at least version 2.1, the installer will not re-resolve but evaluate locked markers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant