19
19
20
20
21
21
# 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"
23
23
nox .options .error_on_missing_interpreters = True
24
24
nox .options .reuse_existing_virtualenvs = True # this can be done using -r
25
25
# if platform.system() == "Windows": >> always use this for better control
@@ -208,11 +208,9 @@ def publish(session):
208
208
# session.run2('codecov -t %s -f %s' % (codecov_token, Folders.coverage_xml))
209
209
210
210
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" ])
216
214
217
215
# Get current tag using setuptools_scm and make sure this is not a dirty/dev one
218
216
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):
222
220
def my_scheme (version_ ):
223
221
version .append (version_ )
224
222
return guess_next_dev_version (version_ )
223
+
225
224
current_tag = get_version ("." , version_scheme = my_scheme )
226
225
227
226
# create the package
228
227
rm_folder (Folders .dist )
228
+
229
229
session .run ("python" , "setup.py" , "sdist" , "bdist_wheel" )
230
230
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
+
231
257
if version [0 ].dirty or not version [0 ].exact :
232
258
raise ValueError ("You need to execute this action on a clean tag version with no local changes." )
233
259
0 commit comments