-
Notifications
You must be signed in to change notification settings - Fork 19
CI migration and refresh #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
closes #40 |
jamesp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I'm a little confused by the versioning system. Where is the version number actually stored/recalled?
| populate_script: | ||
| - conda-lock --mamba --platform linux-64 --file ${CIRRUS_WORKING_DIR}/requirements/py$(echo ${PY_VER} | tr -d ".").yml | ||
| - mamba create --name py${PY_VER} --quiet --file conda-linux-64.lock | ||
| - cp conda-linux-64.lock ${HOME}/mambaforge/envs/py${PY_VER} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, so you're caching the lock info in the CI 👍
| @@ -1,3 +1,4 @@ | |||
| _version.py | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this file and why explicitly ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used by scm and you do not place it under source code control.
It's like a scratch file that scm uses, as per your configuration, to dump its versioning metadata, see pyproject.toml:line+14.
This is then parsed by stratify.init:line+2
| fz_src_orig = list(fz_src_reshaped.shape) | ||
| shape = ( | ||
| int(np.product(fz_src_reshaped.shape[:len(bdims)])), | ||
| int(np.product(fz_src_reshaped.shape[: len(bdims)])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why space here? seems less readable to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is blacks doing, not me guv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| int(np.product(fz_src_reshaped.shape[: len(bdims)])), | ||
| fz_src_reshaped.shape[len(bdims)], | ||
| int(np.product(fz_src_reshaped.shape[len(bdims)+1:]))) | ||
| int(np.product(fz_src_reshaped.shape[len(bdims) + 1 :])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer [(len(bdims) + 1):], adding spaces around slice op is not idiomatic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these changes to the actual code are a result of black auto-fornatting. I trying not to touch the code, other than py2 migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yeah... what can I say 😱
|
The magic of versioning is handled by |
|
I'm going to push |
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [tool.setuptools_scm] | ||
| write_to = "stratify/_version.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell scm where to dump its metadata - this nominated file must not be kept under source code control
|
|
||
|
|
||
| __version__ = '0.2.dev0' | ||
| from ._version import version as __version__ # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configure scm
Now we can do python setup.py --version and also get stratify.__version__ as usual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so setuptools_scm is taking the version number from the latest tag and then applying logic to calculate a new one? Sorry, this is all new to me, I'm sure it makes sense once you've done it a couple of times but seems like magic! If I was to download the package without the .git repo, would it still be able to build/install from source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, you've essentially got it. This following section in the pyproject.toml file is like a nominated scratch area for setuptools-scm:
[tool.setuptools_scm]
write_to = "stratify/_version.py"
It can be anything that you want. Also, you can control how scm generates the offset from the latest tag to create your version string, but what you get out the box is good enough for me.
Note that, there is also this plugin setuptools-scm-git-archive which might address your question, but I think the use case having the source code outside git is a bit rare - particularly when it comes to packaging IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesp I actually stumbled across the actual answer to your question regarding the necessity to have access to the .git repo... as I had to jump through that hoop when attempting to build the conda-forge package for the 0.2.post0 release.
You do need access to a .git repo and the associated artifacts for setuptools-scm to do its job of fathoming out what the version of the package. However, if that's not possible, for example this is exactly the case when attempting to conda-build your package from a .tar.gz archive from GitHub, then you need to instead hit the associated PyPI URL for your package as this contain the necessary metadata for setuptools-scm to do it's job i.e., see https://github.com/conda-forge/python-stratify-feedstock/blob/master/recipe/meta.yaml#L9.
Bingo. Just works 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is the use-case I was thinking about. Good to see there is a reasonable workaround, although having conda-forge hanging off of pypi does seem a little Rube Goldberg!
Codecov Report
@@ Coverage Diff @@
## master #41 +/- ##
=========================================
Coverage ? 98.33%
=========================================
Files ? 5
Lines ? 480
Branches ? 0
=========================================
Hits ? 472
Misses ? 8
Partials ? 0 Continue to review full report at Codecov.
|
| cpdef public z_target, orig_shape, axis, _zp_reshaped, _fp_reshaped | ||
| cpdef public _result_working_shape, result_shape | ||
| cdef public z_target, orig_shape, axis, _zp_reshaped, _fp_reshaped | ||
| cdef public _result_working_shape, result_shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed these from cpdef to cdef to avoid cython future warnings, but functionally a nop change.
|
All approved, but I don't have write access to this repo! @bjlittle feel free to merge |
|
@jamesp Let me fix that for you... |
|
@jamesp You should now have write access to the repo 👍 |
|
@jamesp Awesome, thanks 🎉 |
This PR shows some much needed love to
python-stratify.Namely, it performs the following:
py2topy3travis-citocirrus-cilinuxandosxsetup.pyinto thesetup.cfgisortpre-commitgit hooks to primarily performblack,flake8,isortsetuptools-scmfor version management