Switch to setuptools_scm.#18971
Conversation
|
So the only downside to this approach is that for development installs, the version only updates when Matplotlib is different since it has compiled code and |
This can easily be fixed: in
We already hook the build_ext command to customize it, it's "probably" not too hard to customize it further to ensure it updates |
|
Would it be reasonable to update the version in a dev-install at runtime if setuptools_scm is available? - I assume performance-wise that's the same as versioneer currently. |
|
Yes (that's basically the alternative I propose above). |
|
Then I'd go with that. Feels more correct. We can always introduce an environment variable to deactivate the lookup should the need arise to do so. |
|
One point I forgot to ask is: do we want to add a runtime dependency on setuptools_scm (for what is a fairly rare use case)? or we can also just silently ignore the case of editable installs with setuptools_scm not present (unfortunately, I don't think "runtime dependency only for editable installs" is a thing). |
|
|
|
No, setup_requires are not available at runtime (they're only temporarily made present in the build environment via python -mvenv /tmp/testenv
source /tmp/testenv/bin/activate
mkdir /tmp/foo; cd /tmp/foo
echo 'from setuptools import setup; setup(name="foo", use_scm_version=True, setup_requires=["setuptools_scm>=4"])' > setup.py
git init . && git add . && git commit -m "Initial commit." && git tag v0.0
pip install -ve .
pip list
|
d61e6dd to
5e36700
Compare
|
Discussed on call today. Decision:
|
b1d250d to
5d9a362
Compare
| `versioneer <https://github.com/warner/python-versioneer>`__ | ||
| which uses a format string in | ||
| .. [#] The tarball that is provided by GitHub is produced using `git archive`_. | ||
| We use setuptools_scm_ which uses a format string in |
There was a problem hiding this comment.
| We use setuptools_scm_ which uses a format string in | |
| We use `setuptools_scm`_ which uses a format string in |
There was a problem hiding this comment.
A quick test shows this isn't needed in rst?
There was a problem hiding this comment.
☑️ I've learned something new.
While the Sphinx reStructuredText Primer only mentions the variant with backticks, the specification indeed allows to leave them out. (Could somebody donate a tiny bit of CSS to the docutils folks? - The no-CSS style of the specs is quite unreadable, which is why I try to avoid going there.)
594ad02 to
5ba072b
Compare
5ba072b to
be52811
Compare
|
@anntzer I took the liberty of rebasing. |
|
@tacaswell Is there a reason that you did not merge? |
|
@timhoffm I think I approved, did the rebase, and then did not come back to it when CI passed. I'll rebase again and keep an eye on it this time! |
A few noteworthy points: - The contents in the sdist now exactly match what `git archive` would include; this avoids having to additionally keep track of things in MANIFEST.in (as noted in contributing.rst). - The `__version__` of an editable install is no longer recomputed at each import (as was done with `versioneer`, but only whenever the project is (re)installed; this can actually save quite a bit of time when working with many editable installs as each version recomputation requires shelling out a subprocess. (If really wanted we could keep the old behavior by optionally adding a runtime dependency on setuptools_scm and calling `setuptools_scm.get_version` in `matplotlib/__init__.py`.)
be52811 to
14bbff2
Compare
|
Hello. I see that this is merged but |
Per yesterday's dev call.
A few noteworthy points:
The contents in the sdist now exactly match what
git archivewouldinclude; this avoids having to additionally keep track of things in
MANIFEST.in (as noted in contributing.rst).
The
__version__of an editable install is no longer recomputed ateach import (as was done with
versioneer, but only whenever theproject is (re)installed; this can actually save quite a bit of time
when working with many editable installs as each version recomputation
requires shelling out a subprocess. (If really wanted we could
keep the old behavior by optionally adding a runtime dependency
on setuptools_scm and calling
setuptools_scm.get_versioninmatplotlib/__init__.py.)Also note that I don't personally use the tarballs auto-created by github
or setuptools_scm_git_archive, so I'm not sure I got the config correct
on that side, I just copied what the docs say...
attn @tacaswell
Feel free to push to this PR; I'm mostly just posting an old patch I had...
PR Summary
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).