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

remove circular dependency on export plugin #5980

Merged
merged 4 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading