Skip to content

Commit 714fe1f

Browse files
author
Sylvain MARIE
committed
Fixed release issue and added a build session so as to detect it earlier
1 parent 6fd4c3c commit 714fe1f

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

.github/workflows/base.yml

+3
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ jobs:
183183
uses: codecov/[email protected]
184184
with:
185185
files: ./docs/reports/coverage/coverage.xml
186+
- name: \[not on TAG\] Build wheel and sdist
187+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads')
188+
run: nox -s build
186189

187190
# -------------- only on Ubuntu + TAG PUSH (no pull request) -----------
188191

docs/changelog.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Changelog
22

3-
### 1.15.5 - compatibility fix
3+
### 1.15.6 - compatibility fix
44

55
- Fixed issue with legacy python 2.7 and 3.5. Fixes [#110](https://github.com/smarie/python-makefun/issues/110)
66

7+
### 1.15.5 - yanked version
8+
9+
- This version was yanked as the fix declared in the changelog was not actually active on the version deployed on PyPi
10+
711
### 1.15.4 - Python 3.13 official support
812

913
- Python 3.13 is now supported. PR [#108](https://github.com/smarie/python-makefun/pull/108) and PR

noxfile.py

+32-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
# set the default activated sessions, minimal for CI
22-
nox.options.sessions = ["tests", "flake8", "docs"] # , "docs", "gh_pages"
22+
nox.options.sessions = ["tests", "flake8", "docs", "build"] # , "docs", "gh_pages"
2323
nox.options.error_on_missing_interpreters = True
2424
nox.options.reuse_existing_virtualenvs = True # this can be done using -r
2525
# if platform.system() == "Windows": >> always use this for better control
@@ -208,11 +208,9 @@ def publish(session):
208208
# session.run2('codecov -t %s -f %s' % (codecov_token, Folders.coverage_xml))
209209

210210

211-
@nox.session(python=PY39)
212-
def release(session):
213-
"""Create a release on github corresponding to the latest tag"""
214-
215-
install_reqs(session, phase="setup.py#dist", phase_reqs=["setuptools_scm"])
211+
def _build(session):
212+
"""Common code used by build and release sessions"""
213+
install_reqs(session, setup=True, phase="setup.py#dist", phase_reqs=["setuptools_scm"])
216214

217215
# Get current tag using setuptools_scm and make sure this is not a dirty/dev one
218216
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):
222220
def my_scheme(version_):
223221
version.append(version_)
224222
return guess_next_dev_version(version_)
223+
225224
current_tag = get_version(".", version_scheme=my_scheme)
226225

227226
# create the package
228227
rm_folder(Folders.dist)
228+
229229
session.run("python", "setup.py", "sdist", "bdist_wheel")
230230

231+
# Make sure that the generated _version.py file exists and is compliant with python 2.7
232+
version_py = Path(f"src/{pkg_name}/_version.py")
233+
if not version_py.exists():
234+
raise ValueError("Error with setuptools_scm: _version.py file not generated")
235+
236+
if ":" in version_py.read_text():
237+
raise ValueError("Error with setuptools_scm: _version.py file contains annotations")
238+
239+
return current_tag, version
240+
241+
242+
@nox.session(python=PY39)
243+
def build(session):
244+
"""Same as release but just builds"""
245+
246+
current_tag, version = _build(session)
247+
print(f"current tag: {current_tag}")
248+
print(f"version: {version}")
249+
250+
251+
@nox.session(python=PY39)
252+
def release(session):
253+
"""Create a release on github corresponding to the latest tag"""
254+
255+
current_tag, version = _build(session)
256+
231257
if version[0].dirty or not version[0].exact:
232258
raise ValueError("You need to execute this action on a clean tag version with no local changes.")
233259

setup.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@
3636
# Use the 'version_file_template' directive if possible to avoid type hints and annotations (python <3.8)
3737
from packaging.version import Version
3838
setuptools_scm_version = pkg_resources.get_distribution("setuptools_scm").version
39-
if Version(setuptools_scm_version) >= Version('8.1.0'):
39+
if Version(setuptools_scm_version) >= Version('6'):
40+
# template_arg_name = "version_file_template" if Version(setuptools_scm_version) >= Version('8.1') else "write_to_template"
41+
# print(Version(setuptools_scm_version))
42+
# print(template_arg_name)
43+
4044
# Note that it was named 'write_to_template' earlier. But at that time it was not generating annotations so no need.
41-
args["version_file_template"] = """# file generated by setuptools_scm
45+
args["write_to_template"] = """# file generated by setuptools_scm and customized
4246
# don't change, don't track in version control
4347
__version__ = version = '{version}'
4448
__version_tuple__ = version_tuple = {version_tuple}

0 commit comments

Comments
 (0)