Skip to content

Commit

Permalink
Support the [project] section (PEP 621)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed May 19, 2024
1 parent 983f69f commit d25a4ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
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"),
original=poetry.local_config["version"],
pyproject=poetry.pyproject.data,
pyproject_path=_get_pyproject_path_from_poetry(poetry.pyproject),
Expand Down

0 comments on commit d25a4ac

Please sign in to comment.