From c6cd8735552c402a7734104641a637e29ae67592 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Thu, 26 Sep 2024 13:20:23 +0200 Subject: [PATCH 1/3] Fixed GHA issues by using compliant version of makefun for legacy distributions. --- docs/changelog.md | 4 ++++ noxfile.py | 6 +++--- setup.py | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 6e16ec7..b67db83 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Changelog +### 1.15.5 - compatibility fix + +- Fixed issue with legacy python 2.7 and 3.5. Fixes [#110](https://github.com/smarie/python-makefun/issues/110) + ### 1.15.4 - Python 3.13 official support - Python 3.13 is now supported. PR [#108](https://github.com/smarie/python-makefun/pull/108) and PR diff --git a/noxfile.py b/noxfile.py index de817d8..e05ced4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -136,7 +136,7 @@ def tests(session, coverage, pkg_specs): "-m", "pytest", "--cache-clear", f"--junitxml={Folders.test_xml}", f"--html={Folders.test_html}", "-v", "tests/") - session.run("coverage", "report") + session.run("coverage", "report") # this shows in terminal + fails under XX%, same as --cov-report term --cov-fail-under=70 # noqa session.run("coverage", "xml", "-o", f"{Folders.coverage_xml}") session.run("coverage", "html", "-d", f"{Folders.coverage_reports}") # delete this intermediate file, it is not needed anymore @@ -154,7 +154,7 @@ def flake8(session): """Launch flake8 qualimetry.""" session.install("-r", str(Folders.ci_tools / "flake8-requirements.txt")) - session.run("pip", "install", ".") + session.install(".") rm_folder(Folders.flake8_reports) Folders.flake8_reports.mkdir(parents=True, exist_ok=True) @@ -285,7 +285,7 @@ def gha_list(session): out = session.run("nox", "-l", "--json", "-s", "tests", external=True, silent=True) sessions_list = [{"python": s["python"], "session": s["session"]} for s in json.loads(out)] - # TODO filter + # TODO filter ? # print the list so that it can be caught by GHA. # Note that json.dumps is optional since this is a list of string. diff --git a/setup.py b/setup.py index 96dae2b..bd4eceb 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,12 @@ setup( download_url=DOWNLOAD_URL, use_scm_version={ - "write_to": "src/makefun/_version.py" + "write_to": "src/makefun/_version.py", + # Custom template to avoid type hints and annotations (python <3.8) + "version_file_template": """# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '{version}' +__version_tuple__ = version_tuple = {version_tuple} +""" }, # we can't put `use_scm_version` in setup.cfg yet unfortunately ) From 7f70bbb0510fb9e45b0161d8aea33ed6d5706c51 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Thu, 26 Sep 2024 13:24:47 +0200 Subject: [PATCH 2/3] Fixed GHA issues --- .github/workflows/base.yml | 2 +- noxfile-requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 3ba416a..b6cbd0f 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -194,7 +194,7 @@ jobs: # 8) Publish the wheel on PyPi - name: \[TAG only\] Deploy on PyPi if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.8.11 + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/noxfile-requirements.txt b/noxfile-requirements.txt index 3b4ab32..e32b00f 100644 --- a/noxfile-requirements.txt +++ b/noxfile-requirements.txt @@ -1,6 +1,6 @@ virtualenv nox toml -makefun +setuptools<72 # later versions do not read 'tests_require' from setup.cfg anymore setuptools_scm # used in 'release' keyring # used in 'release' From e61cd0f0dbd42cfe6be47745f42fc5fa0e2858be Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Thu, 26 Sep 2024 13:52:28 +0200 Subject: [PATCH 3/3] Fixed setuptools_scm issue with legacy python versions --- setup.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index bd4eceb..7f8d239 100644 --- a/setup.py +++ b/setup.py @@ -29,16 +29,22 @@ DOWNLOAD_URL = URL + "/tarball/" + get_version() -# (3) Call setup() with as little args as possible -setup( - download_url=DOWNLOAD_URL, - use_scm_version={ - "write_to": "src/makefun/_version.py", - # Custom template to avoid type hints and annotations (python <3.8) - "version_file_template": """# file generated by setuptools_scm +# Setuptools_scm target version file to generate +args = { + "write_to": "src/makefun/_version.py", +} +# Use the 'version_file_template' directive if possible to avoid type hints and annotations (python <3.8) +from packaging.version import Version +setuptools_scm_version = pkg_resources.get_distribution("setuptools_scm").version +if Version(setuptools_scm_version) >= Version('8.1.0'): + # Note that it was named 'write_to_template' earlier. But at that time it was not generating annotations so no need. + args["version_file_template"] = """# file generated by setuptools_scm # don't change, don't track in version control __version__ = version = '{version}' __version_tuple__ = version_tuple = {version_tuple} """ - }, # we can't put `use_scm_version` in setup.cfg yet unfortunately +# (3) Call setup() with as little args as possible +setup( + download_url=DOWNLOAD_URL, + use_scm_version=args )