| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
So the only downside to this approach is that for development installs, the version only updates when setup.py is re-run. On metpy, rather than have setuptools_scm write to a version file, I opted to try to use setuptools_scm to get the live version for dev installs fallback to use importlib.metadata to get the version for installed versions. Matplotlib is different since it has compiled code and setup.py is needed to be re-run more regularly--though I bet python setup.py build_ext --inplace doesn't update the version either. |
Sorry, something went wrong.
This can easily be fixed: in matplotlib/__init__.py, we can check if we are in a git repo ((Path(__file__).parent / "../../.git").exists()) and if so call setuptools_scm.get_version() instead of importing the version from _version.py. However, as described above, I have intentionally chosen against doing so: my normal Python working environment basically consists of a large number of personal projects all editably installed, and I found out that my script startup times were significantly slowed down by the large number of git describe that were run again and again every time I ran a script (also note that things are even worse on Windows, where subprocesses are even more costly to start). So nowadays I have chosen to accept the slightly out-of-syncness for my personal projects. For Matplotlib I'm fine either way.
We already hook the build_ext command to customize it, it's "probably" not too hard to customize it further to ensure it updates _version.py. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Yes (that's basically the alternative I propose above). |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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). |
Sorry, something went wrong.
|
setuptools_scm will become a build-time dependency anyway--which means it will be available for all useful editable installs. |
Sorry, something went wrong.
|
No, setup_requires are not available at runtime (they're only temporarily made present in the build environment via .eggs). This can easily be checked by installing something into a temporary environment: 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 listpip list shows that foo has been installed into the current environment, but not setuptools_scm (as can also be checked by trying to import it. |
Sorry, something went wrong.
|
Discussed on call today. Decision: Likely I won't do this in the 3.4 time frame. edit: actually that was easy :) |
Sorry, something went wrong.
| `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 |
Sorry, something went wrong.
There was a problem hiding this comment.
A quick test shows this isn't needed in rst?
Sorry, something went wrong.
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.)
Sorry, something went wrong.
|
@anntzer I took the liberty of rebasing. |
Sorry, something went wrong.
|
@tacaswell Is there a reason that you did not merge? |
Sorry, something went wrong.
|
@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! |
Sorry, something went wrong.
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`.)
|
Hello. I see that this is merged but astropy is still picking up git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib as 3.4.2.postN+gNNNNNN. Is this expected? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Per yesterday's dev call.
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.)
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