From 4daea47b498638ccec22d4490ce07dda9ff7e671 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 17 Sep 2023 13:39:11 +0100 Subject: [PATCH 1/4] Remove circular dependency on export plugin --- .github/workflows/.tests-matrix.yaml | 40 +++++++++++++++++++--------- .pre-commit-hooks.yaml | 9 ------- poetry.lock | 19 ++----------- pyproject.toml | 1 - 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/.tests-matrix.yaml b/.github/workflows/.tests-matrix.yaml index 9a9bae65d01..87718ee886c 100644 --- a/.github/workflows/.tests-matrix.yaml +++ b/.github/workflows/.tests-matrix.yaml @@ -78,25 +78,41 @@ jobs: if: inputs.run-pytest-export steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - - uses: ./.github/actions/bootstrap-poetry with: - python-version: ${{ inputs.python-version }} + path: poetry - - uses: ./.github/actions/poetry-install + - uses: ./poetry/.github/actions/bootstrap-poetry with: - args: --with github-actions + python-version: ${{ inputs.python-version }} - - run: poetry run pip list --format json | jq -r '.[] | "\(.name)=\(.version)"' >> $GITHUB_OUTPUT - id: package-versions + - name: Get poetry-plugin-export version + run: | + PLUGIN_VERSION=$(curl -s https://pypi.org/pypi/poetry-plugin-export/json | jq -r ".info.version") + echo "Found version ${PLUGIN_VERSION}" + echo version=${PLUGIN_VERSION} >> $GITHUB_OUTPUT + id: poetry-plugin-export-version - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - name: Check out poetry-plugin-export + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: path: poetry-plugin-export repository: python-poetry/poetry-plugin-export - ref: refs/tags/${{ steps.package-versions.outputs.poetry-plugin-export }} + ref: refs/tags/${{ steps.poetry-plugin-export-version.outputs.version }} + + - name: Use local poetry + working-directory: poetry-plugin-export + run: poetry add --lock --group dev ../poetry + + - name: Install + working-directory: poetry-plugin-export + run: poetry install - - run: poetry run -C .. pytest -v - working-directory: ./poetry-plugin-export + - name: Run tests + working-directory: poetry-plugin-export + run: poetry run python -m pytest -p no:sugar -q tests - - run: git -C poetry-plugin-export diff --exit-code --stat HEAD + - name: Check for clean working tree + working-directory: poetry-plugin-export + run: | + git checkout -- pyproject.toml poetry.lock + git diff --exit-code --stat HEAD diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 6d060fa1cf7..bdacdbdf659 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -14,15 +14,6 @@ pass_filenames: false files: ^(.*/)?(poetry\.lock|pyproject\.toml)$ -- id: poetry-export - name: poetry-export - description: run poetry export to sync lock file with requirements.txt - entry: poetry export - language: python - pass_filenames: false - files: ^(.*/)?poetry\.lock$ - args: ["-f", "requirements.txt", "-o", "requirements.txt"] - - id: poetry-install name: poetry-install description: run poetry install to install dependencies from the lock file diff --git a/poetry.lock b/poetry.lock index 4e99899317c..484af427d5f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -989,21 +989,6 @@ url = "https://github.com/python-poetry/poetry-core.git" reference = "main" resolved_reference = "beb93b1aba6ad47667c05721a74c8f3961402046" -[[package]] -name = "poetry-plugin-export" -version = "1.8.0" -description = "Poetry plugin to export the dependencies to various formats" -optional = false -python-versions = "<4.0,>=3.8" -files = [ - {file = "poetry_plugin_export-1.8.0-py3-none-any.whl", hash = "sha256:adbe232cfa0cc04991ea3680c865cf748bff27593b9abcb1f35fb50ed7ba2c22"}, - {file = "poetry_plugin_export-1.8.0.tar.gz", hash = "sha256:1fa6168a85d59395d835ca564bc19862a7c76061e60c3e7dfaec70d50937fc61"}, -] - -[package.dependencies] -poetry = ">=1.8.0,<3.0.0" -poetry-core = ">=1.7.0,<3.0.0" - [[package]] name = "pre-commit" version = "3.5.0" @@ -1027,7 +1012,7 @@ name = "psutil" version = "6.0.0" description = "Cross-platform lib for process and system monitoring in Python." optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" files = [ {file = "psutil-6.0.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a021da3e881cd935e64a3d0a20983bda0bb4cf80e4f74fa9bfcb1bc5785360c6"}, {file = "psutil-6.0.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:1287c2b95f1c0a364d23bc6f2ea2365a8d4d9b726a3be7294296ff7ba97c17f0"}, @@ -1630,4 +1615,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "816bcb3532fd7484005946146373ddb848e7405a72f10a8dc345b9e4596427f7" +content-hash = "441837efd1e7f3926ede309d5d5f71a7b25d86ca01a91e96afe0ae63851bfbb8" diff --git a/pyproject.toml b/pyproject.toml index 30cbc165f93..30d4c958623 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ Changelog = "https://python-poetry.org/history/" python = "^3.8" poetry-core = { git = "https://github.com/python-poetry/poetry-core.git", branch = "main" } -poetry-plugin-export = "^1.8.0" build = "^1.2.1" cachecontrol = { version = "^0.14.0", extras = ["filecache"] } cleo = "^2.1.0" From 7ed3b60ad85c63b9e993d9873dc26d04ce58e7b2 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 11 Nov 2023 13:42:01 +0000 Subject: [PATCH 2/4] Complete the removal of poetry-export --- docs/cli.md | 12 ++--------- src/poetry/config/config.py | 4 ---- src/poetry/console/application.py | 6 ------ src/poetry/console/commands/config.py | 1 - src/poetry/console/commands/export.py | 21 ------------------ tests/console/commands/test_config.py | 6 ------ tests/console/commands/test_export.py | 31 --------------------------- 7 files changed, 2 insertions(+), 79 deletions(-) delete mode 100644 src/poetry/console/commands/export.py delete mode 100644 tests/console/commands/test_export.py diff --git a/docs/cli.md b/docs/cli.md index c5ba541b138..d53a6dd0f64 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -777,17 +777,9 @@ This command exports the lock file to other formats. poetry export -f requirements.txt --output requirements.txt ``` -{{% warning %}} -This command is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export). -In a future version of Poetry this plugin will not be installed by default anymore. -In order to avoid a breaking change and make your automation forward-compatible, -please install poetry-plugin-export explicitly. -See [Using plugins]({{< relref "plugins#using-plugins" >}}) for details on how to install a plugin. -{{% /warning %}} - {{% note %}} -This command is also available as a pre-commit hook. -See [pre-commit hooks]({{< relref "pre-commit-hooks#poetry-export" >}}) for more information. +This command is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export) +and is also available as a pre-commit hook. See [pre-commit hooks]({{< relref "pre-commit-hooks#poetry-export" >}}) for more information. {{% /note %}} {{% note %}} diff --git a/src/poetry/config/config.py b/src/poetry/config/config.py index bf2f0948d03..e16ead0a912 100644 --- a/src/poetry/config/config.py +++ b/src/poetry/config/config.py @@ -134,9 +134,6 @@ class Config: "solver": { "lazy-wheel": True, }, - "warnings": { - "export": True, - }, "keyring": { "enabled": True, }, @@ -305,7 +302,6 @@ def _get_normalizer(name: str) -> Callable[[str], Any]: "experimental.system-git-client", "installer.parallel", "solver.lazy-wheel", - "warnings.export", "keyring.enabled", }: return boolean_normalizer diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index c81103f10a9..a10b41a309e 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -340,12 +340,6 @@ def _load_plugins(self, io: IO | None = None) -> None: manager.load_plugins() manager.activate(self) - # We have to override the command from poetry-plugin-export - # with the wrapper. - if self.command_loader.has("export"): - del self.command_loader._factories["export"] - self.command_loader._factories["export"] = load_command("export") - self._plugins_loaded = True @property diff --git a/src/poetry/console/commands/config.py b/src/poetry/console/commands/config.py index 1a8a8e1307c..2495ed0aa4a 100644 --- a/src/poetry/console/commands/config.py +++ b/src/poetry/console/commands/config.py @@ -82,7 +82,6 @@ def unique_config_values(self) -> dict[str, tuple[Any, Any]]: PackageFilterPolicy.normalize, ), "solver.lazy-wheel": (boolean_validator, boolean_normalizer), - "warnings.export": (boolean_validator, boolean_normalizer), "keyring.enabled": (boolean_validator, boolean_normalizer), } diff --git a/src/poetry/console/commands/export.py b/src/poetry/console/commands/export.py deleted file mode 100644 index cf18e279deb..00000000000 --- a/src/poetry/console/commands/export.py +++ /dev/null @@ -1,21 +0,0 @@ -from __future__ import annotations - -from poetry_plugin_export.command import ( # type: ignore[import-untyped] - ExportCommand as BaseExportCommand, -) - - -class ExportCommand(BaseExportCommand): # type: ignore[misc] - def handle(self) -> int: - if self.poetry.config.get("warnings.export"): - self.line_error( - "Warning: poetry-plugin-export will not be installed by default in a" - " future version of Poetry.\n" - "In order to avoid a breaking change and make your automation" - " forward-compatible, please install poetry-plugin-export explicitly." - " See https://python-poetry.org/docs/plugins/#using-plugins for details" - " on how to install a plugin.\n" - "To disable this warning run 'poetry config warnings.export false'.", - style="warning", - ) - return super().handle() # type: ignore[no-any-return] diff --git a/tests/console/commands/test_config.py b/tests/console/commands/test_config.py index 0572c2c12a7..55d42daaba6 100644 --- a/tests/console/commands/test_config.py +++ b/tests/console/commands/test_config.py @@ -70,7 +70,6 @@ def test_list_displays_default_value_if_not_set( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert tester.io.fetch_output() == expected @@ -102,7 +101,6 @@ def test_list_displays_set_get_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 0 # type: ignore[attr-defined] @@ -155,7 +153,6 @@ def test_unset_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 0 # type: ignore[attr-defined] assert tester.io.fetch_output() == expected @@ -186,7 +183,6 @@ def test_unset_repo_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 0 # type: ignore[attr-defined] assert tester.io.fetch_output() == expected @@ -315,7 +311,6 @@ def test_list_displays_set_get_local_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 1 # type: ignore[attr-defined] @@ -355,7 +350,6 @@ def test_list_must_not_display_sources_from_pyproject_toml( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert tester.io.fetch_output() == expected diff --git a/tests/console/commands/test_export.py b/tests/console/commands/test_export.py deleted file mode 100644 index 962c2c8c151..00000000000 --- a/tests/console/commands/test_export.py +++ /dev/null @@ -1,31 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING - -import pytest - - -if TYPE_CHECKING: - from cleo.testers.command_tester import CommandTester - - from tests.conftest import Config - from tests.types import CommandTesterFactory - - -@pytest.fixture -def tester(command_tester_factory: CommandTesterFactory) -> CommandTester: - return command_tester_factory("export") - - -def test_export_prints_warning(tester: CommandTester) -> None: - tester.execute("") - assert ( - "Warning: poetry-plugin-export will not be installed by default" - in tester.io.fetch_error() - ) - - -def test_disable_export_warning(tester: CommandTester, config: Config) -> None: - config.config["warnings"]["export"] = False - tester.execute("") - assert "poetry-plugin-export" not in tester.io.fetch_error() From f3e3f10092761e49b74fd60f306fbcd957133388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:02:14 +0200 Subject: [PATCH 3/4] call pytest like in other tests --- .github/workflows/.tests-matrix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.tests-matrix.yaml b/.github/workflows/.tests-matrix.yaml index 87718ee886c..ef1fe8764c9 100644 --- a/.github/workflows/.tests-matrix.yaml +++ b/.github/workflows/.tests-matrix.yaml @@ -109,7 +109,7 @@ jobs: - name: Run tests working-directory: poetry-plugin-export - run: poetry run python -m pytest -p no:sugar -q tests + run: poetry run pytest -v - name: Check for clean working tree working-directory: poetry-plugin-export From 7ff92844451c8a727b5afd691b4ce7b138dfa799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:16:21 +0200 Subject: [PATCH 4/4] change note to warning and add more information --- docs/cli.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index d53a6dd0f64..cda2bd9a4d0 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -771,6 +771,20 @@ The option `--next-phase` allows the increment of prerelease phase versions. ## export +{{% warning %}} +This command is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export). +The plugin is no longer installed by default with Poetry 2.0. + +See [Using plugins]({{< relref "plugins#using-plugins" >}}) for information on how to install a plugin. +As described in [Project plugins]({{< relref "plugins#project-plugins" >}}), +you can also define in your `pyproject.toml` that the plugin is required for the development of your project: + +```toml +[tool.poetry.requires-plugins] +poetry-plugin-export = ">1.8" +``` +{{% /warning %}} + This command exports the lock file to other formats. ```bash @@ -778,8 +792,8 @@ poetry export -f requirements.txt --output requirements.txt ``` {{% note %}} -This command is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export) -and is also available as a pre-commit hook. See [pre-commit hooks]({{< relref "pre-commit-hooks#poetry-export" >}}) for more information. +The `export` command is also available as a pre-commit hook. +See [pre-commit hooks]({{< relref "pre-commit-hooks#poetry-export" >}}) for more information. {{% /note %}} {{% note %}}