Skip to content

Commit

Permalink
remove circular dependency on export plugin (python-poetry#5980)
Browse files Browse the repository at this point in the history
Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com>
  • Loading branch information
dimbleby and radoering authored Oct 5, 2024
1 parent 739cbb8 commit 09d2e50
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 117 deletions.
40 changes: 28 additions & 12 deletions .github/workflows/.tests-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 pytest -v

- 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
9 changes: 0 additions & 9 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -771,22 +771,28 @@ 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
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.
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 %}}

Expand Down
19 changes: 2 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions src/poetry/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ class Config:
"solver": {
"lazy-wheel": True,
},
"warnings": {
"export": True,
},
"keyring": {
"enabled": True,
},
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
21 changes: 0 additions & 21 deletions src/poetry/console/commands/export.py

This file was deleted.

6 changes: 0 additions & 6 deletions tests/console/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions tests/console/commands/test_export.py

This file was deleted.

0 comments on commit 09d2e50

Please sign in to comment.