-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Document how setuptools_scm works #143
Comments
@cdeil thanks for bringing those points that need clarification to attention,
this is similar to how
setuptools_scm has an optional tool that allows to write the version to text/python files using the albeit badly documented write_to argument by default setuptools_scm does not write to any files, it only sets the version attribute of the distribution object used by setuptools/distutils im using it with virtually all of my packges, - pytest-xdist, iniconfig, sentaku are just a few examples |
another user was introduced by borgbackup/borg#161 :) |
Another point missing clarification is package data files. It seems that setuptools-scm makes git-tracked file inside python modules get installed (if |
@hobarrera the surrounding breakage was setuptools ignoring sdist metadata in a major release, there is nothing we can do about that |
Right, I wasn't complaining about the breakage per se, just pointing out that the entire feature is mostly undocumented on setuptool-scm's side, so I wasn't sure if the previous behaviour was expected, or the current one was (eg: maybe I was just relying on a bug). While we're on that topic though (slight OT for this thread though): this should be fixed in future by setuptools? |
@hobarrera the setuptools bug will be fixed by setuptools, btw, the file finders are mentionend in the readme, its not really comprehensible that way unfortunately i rarely find the time to work on documentation atm |
It took me some experimenting to figure out how to use the keywords instead of the default
|
@RonnyPfannschmidt Would you consider enabling wiki with community access? |
Another thing I don't understand, along these lines. I'm using setuptools_scm just fine, somehow miraculously, since I never installed it. After searching a bit more, it seems that the Surely I'm missing something here. I'm used to installing the software I use to do a build up-front. That allows me to use the build software to find out what would be built, and, in this case, what version would be given to the package that is built. It also allows the Can you document how to use setuptools_scm without requiring the use of setup_requires? |
as soon as setuptools_scm is available in the local workingset it will no longer try to install it in .eggs |
the general goal here is to slowly get people to use PEP-517/518 and let pip sort it out with a ephemeral env |
I tried Couldn't figure out how to get a version number into the release sdist. I have a git tag "v0.1" but apparently it's not found by Looking through the docs of 😞
|
UUse setuptools ... |
#343 (comment) was merged as a starting point, we still need more |
I was definitely confused at first as well about exactly when write_to gets invoked, especially since I put Another bit missing from the docs is recommendations for what to do when using a package that's installed in editable mode ( Currently I came up with something like: try:
from ._version import version as __version__
except ImportError:
# Possibly running in the git repository
try:
import setuptools_scm
__version__ = setuptools_scm.get_version()
del setuptools_scm
except Exception:
warnings.warn(f'could not determine {__name__} package version')
__version__ = '0.0.0' This seems to work, and under a "normal", non-development installation the In any case thanks @RonnyPfannschmidt for continuing to maintain this package! I haven't used it in many many years and it's evolved tremendously since I last did. Even despite these confusions it implements I think exactly what my colleagues are clamoring for and saved me a ton of time in not having to roll my own. |
@embray thans for those encouraging words, currently there is no concept of editable install aware versioning, as setuptools doesn't provide the tooling to actually update metadata (aka the package metadata will be incorrect until the next refresh) i wonder if perhaps a install-able post-commit/checkout hook could be used to update the package metadata on git usage in a reliable manner |
I'm not sure that would fully solve the problem; for example it wouldn't detect when the repository is dirty. I think solutions similar to the one I posted above, where There are some corner cases where this is "dangerous", like if some source code gets copied into a different git repo (maybe I extract a source tarball into some miscellaneous repo and then install it, for example). This is mitigated somewhat by first looking for the I've also mitigated this kind of issue before by looking for a special canary file that would only possibly exist in my project's repo. For example: with open(os.path.join(os.path.dirname(__file__), '..', '.canary')) as fobj:
in_my_project_repo = fobj.read() == '<some hard-coded randomly generated string>' Maybe overkill in most cases, but I've found this pattern useful in the past when I want to be really sure that my code is running out of the correct repository. |
I don't think so. Commands are constructed with the distribution object, so the dependency works in the other direction. Also, a distribution is theoretically a more abstract concept -- it's meant to exist independent of any command that executes on it. |
I am also trying to implement a way to get the runtime version if editable and the install version otherwise. I initially thought we could try to read from the generated
but this file is also created in editable installs. Is it viable for the |
@GDYendell please open a new issue for this topic Currently there is no reasonable way to tell the difference between editable installs and normal install Im inclined to rather supplement a git hook that updates the files /package metadatas rather than a error prone hackish file with magical version extraction |
closing this as complete with the merge of #880 adding more documentation |
I've been reading through your docs https://github.com/pypa/setuptools_scm/blob/master/README.rst and I'm having a hard time to figure out how
setuptools_scm
works.Question 1:
I see an option
use_scm_version
is passed tosetuptools.setup
.Looking at the docs for setuptools https://setuptools.readthedocs.io/en/latest/ I can't find this option!? (might have missed it, unfortunately those docs don't have the normal Sphinx search field!?)
Is this option to
setuptools.setup
somehow an extension that's provided by thesetuptools_scm
package itself?Question 2:
Does
setuptools_scm
ever generate a file with a version number?The docs mention
PKG-INFO
under:https://github.com/pypa/setuptools_scm/blob/master/README.rst#builtin-mechanisms-for-obtaining-version-numbers
Does
setuptools_scm
compute or directly store a version number inPKG-INFO
or some other file?Please consider this issue as a documentation request for people like me, that would like to understand how setuptools and setuptools_scm work and for which of my projects I should consider using
setuptools_scm
. (I guess all Python / git projects?)Some extra sentences and links to relevant info (e.g. https://www.python.org/dev/peps/pep-0314/) would help.
Links to a few packages using setuptools_scm as "working examples" that I can look at and play around with before trying to modify my existing packages would also be very useful.
The text was updated successfully, but these errors were encountered: