Skip to content

Commit 5142fa8

Browse files
committed
[feature] Support Python projects using pyproject.toml #706
Added support for pyproject.toml as a package type indicator and version source for the releaser tool. Closes #706
1 parent ddf7024 commit 5142fa8

3 files changed

Lines changed: 4 additions & 14 deletions

File tree

openwisp_utils/releaser/config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ def _handle_python_version(config):
7171
if version_match:
7272
config["version_path"] = init_py_path
7373
try:
74-
version_tuple = ast.literal_eval(
75-
f"({version_match.group(1)})"
76-
)
74+
version_tuple = ast.literal_eval(f"({version_match.group(1)})")
7775
config["CURRENT_VERSION"] = list(version_tuple)
7876
except (ValueError, SyntaxError):
7977
config["CURRENT_VERSION"] = None

openwisp_utils/releaser/tests/test_config.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,7 @@ def test_no_package_type_detected(project_dir, create_changelog, init_git_repo):
426426
assert config["CURRENT_VERSION"] is None
427427

428428

429-
# pyproject.toml Package Tests
430-
def test_pyproject_toml_package_detection(
431-
project_dir, create_changelog, init_git_repo
432-
):
429+
def test_pyproject_toml_package_detection(project_dir, create_changelog, init_git_repo):
433430
"""Tests that python package type is detected when pyproject.toml exists."""
434431
(project_dir / "pyproject.toml").write_text(
435432
'[project]\nname = "my-package"\nversion = "1.2.3"\n'
@@ -442,9 +439,7 @@ def test_pyproject_toml_package_detection(
442439
assert config["CURRENT_VERSION"] == [1, 2, 3, "final"]
443440

444441

445-
def test_pyproject_toml_missing_version(
446-
project_dir, create_changelog, init_git_repo
447-
):
442+
def test_pyproject_toml_missing_version(project_dir, create_changelog, init_git_repo):
448443
"""Tests pyproject.toml without a version field."""
449444
(project_dir / "pyproject.toml").write_text('[project]\nname = "my-package"\n')
450445
create_changelog(project_dir)
@@ -454,9 +449,7 @@ def test_pyproject_toml_missing_version(
454449
assert config["CURRENT_VERSION"] is None
455450

456451

457-
def test_pyproject_toml_invalid_version(
458-
project_dir, create_changelog, init_git_repo
459-
):
452+
def test_pyproject_toml_invalid_version(project_dir, create_changelog, init_git_repo):
460453
"""Tests pyproject.toml with an invalid version format."""
461454
(project_dir / "pyproject.toml").write_text(
462455
'[project]\nname = "my-package"\nversion = "1.2"\n'

openwisp_utils/releaser/tests/test_version_bumping.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ def test_bump_version_openwrt():
370370
assert "1.2.4" in written_content
371371

372372

373-
# pyproject.toml Package Version Tests
374373
PYPROJECT_TOML_CONTENT = """[build-system]
375374
requires = ["setuptools"]
376375
build-backend = "setuptools.backends._legacy:_Backend"

0 commit comments

Comments
 (0)