diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 33c577a..0f612b6 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -183,6 +183,9 @@ jobs: uses: codecov/codecov-action@v4.0.1 with: files: ./docs/reports/coverage/coverage.xml + - name: \[not on TAG\] Build wheel and sdist + if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') + run: nox -s build # -------------- only on Ubuntu + TAG PUSH (no pull request) ----------- diff --git a/docs/changelog.md b/docs/changelog.md index b67db83..fcc3a22 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,9 +1,13 @@ # Changelog -### 1.15.5 - compatibility fix +### 1.15.6 - compatibility fix - Fixed issue with legacy python 2.7 and 3.5. Fixes [#110](https://github.com/smarie/python-makefun/issues/110) +### 1.15.5 - yanked version + +- This version was yanked as the fix declared in the changelog was not actually active on the version deployed on PyPi + ### 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 e05ced4..20aff88 100644 --- a/noxfile.py +++ b/noxfile.py @@ -19,7 +19,7 @@ # set the default activated sessions, minimal for CI -nox.options.sessions = ["tests", "flake8", "docs"] # , "docs", "gh_pages" +nox.options.sessions = ["tests", "flake8", "docs", "build"] # , "docs", "gh_pages" nox.options.error_on_missing_interpreters = True nox.options.reuse_existing_virtualenvs = True # this can be done using -r # if platform.system() == "Windows": >> always use this for better control @@ -208,11 +208,9 @@ def publish(session): # session.run2('codecov -t %s -f %s' % (codecov_token, Folders.coverage_xml)) -@nox.session(python=PY39) -def release(session): - """Create a release on github corresponding to the latest tag""" - - install_reqs(session, phase="setup.py#dist", phase_reqs=["setuptools_scm"]) +def _build(session): + """Common code used by build and release sessions""" + install_reqs(session, setup=True, phase="setup.py#dist", phase_reqs=["setuptools_scm"]) # Get current tag using setuptools_scm and make sure this is not a dirty/dev one from setuptools_scm import get_version # (note that this import is not from the session env but the main nox env) @@ -222,12 +220,40 @@ def release(session): def my_scheme(version_): version.append(version_) return guess_next_dev_version(version_) + current_tag = get_version(".", version_scheme=my_scheme) # create the package rm_folder(Folders.dist) + session.run("python", "setup.py", "sdist", "bdist_wheel") + # Make sure that the generated _version.py file exists and is compliant with python 2.7 + version_py = Path(f"src/{pkg_name}/_version.py") + if not version_py.exists(): + raise ValueError("Error with setuptools_scm: _version.py file not generated") + + if ":" in version_py.read_text(): + raise ValueError("Error with setuptools_scm: _version.py file contains annotations") + + return current_tag, version + + +@nox.session(python=PY39) +def build(session): + """Same as release but just builds""" + + current_tag, version = _build(session) + print(f"current tag: {current_tag}") + print(f"version: {version}") + + +@nox.session(python=PY39) +def release(session): + """Create a release on github corresponding to the latest tag""" + + current_tag, version = _build(session) + if version[0].dirty or not version[0].exact: raise ValueError("You need to execute this action on a clean tag version with no local changes.") diff --git a/setup.py b/setup.py index 7f8d239..b05033e 100644 --- a/setup.py +++ b/setup.py @@ -36,9 +36,13 @@ # 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'): +if Version(setuptools_scm_version) >= Version('6'): + # template_arg_name = "version_file_template" if Version(setuptools_scm_version) >= Version('8.1') else "write_to_template" + # print(Version(setuptools_scm_version)) + # print(template_arg_name) + # 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 + args["write_to_template"] = """# file generated by setuptools_scm and customized # don't change, don't track in version control __version__ = version = '{version}' __version_tuple__ = version_tuple = {version_tuple}