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

Support the [project] section (PEP 621) #181

Merged
merged 11 commits into from
Jun 17, 2024
5 changes: 4 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
poetry-version: '1.7.1'
- python-version: '3.7'
poetry-version: '1.8.1'
include:
- python-version: '3.11'
poetry-version: 'git+https://github.com/radoering/poetry.git@pep621-support'
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -52,7 +55,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- run: |
pip install pipx
pipx install poetry==${{ matrix.poetry-version }}
pipx install ${{ startsWith(matrix.poetry-version, 'git') && matrix.poetry-version || format('poetry=={0}', matrix.poetry-version) }}
pipx install invoke
poetry install --extras plugin
Expand Down
6 changes: 2 additions & 4 deletions poetry_dynamic_versioning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def _substitute_version_in_text(version: str, content: str, patterns: Sequence[_


def _apply_version(
version: str, instance: Version, config: _Config, pyproject_path: Path, retain: bool = False
name: str, version: str, instance: Version, config: _Config, pyproject_path: Path, retain: bool = False
) -> None:
pyproject = tomlkit.parse(pyproject_path.read_bytes().decode("utf-8"))

Expand All @@ -604,8 +604,6 @@ def _apply_version(

pyproject_path.write_bytes(tomlkit.dumps(pyproject).encode("utf-8"))

name = pyproject["tool"]["poetry"]["name"] # type: ignore

for file_name, file_info in config["files"].items():
full_file = pyproject_path.parent.joinpath(file_name)

Expand Down Expand Up @@ -678,7 +676,7 @@ def _get_and_apply_version(
if name is not None and original is not None:
_state.projects[name] = _ProjectState(pyproject_path, original, version)
if io:
_apply_version(version, instance, config, pyproject_path, retain)
_apply_version(name, version, instance, config, pyproject_path, retain)

return name

Expand Down
3 changes: 2 additions & 1 deletion poetry_dynamic_versioning/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ def _apply_version_via_plugin(
io: bool = True
# fmt: on
) -> None:
project_section = poetry.pyproject.data.get("project", {})
name = _get_and_apply_version(
name=poetry.local_config["name"],
name=project_section.get("name") or poetry.local_config("name"),
mtkennerly marked this conversation as resolved.
Show resolved Hide resolved
original=poetry.local_config["version"],
pyproject=poetry.pyproject.data,
pyproject_path=_get_pyproject_path_from_poetry(poetry.pyproject),
Expand Down
Loading