regro / rever

Releaser of Versions
https://regro.github.io/rever-docs/
BSD 3-Clause "New" or "Revised" License
75 stars 33 forks source link

add --version flag to argparse #187

Closed msarahan closed 5 years ago

msarahan commented 5 years ago

Would it be of interest to add something to read the version from git? versioneer or otherwise? I find it helpful to capture dev state. That's sort of orthogonal to this PR, but let me know.

scopatz commented 5 years ago

Thanks @msarahan!

Would it be of interest to add something to read the version from git?

Yeah, for sure! I think versioneer is a bit heavyweight. The way xonsh does this is in the setup.py file. However, we don't have a custom install activity, so it is probably a bit much to ask. Is there a way to make is so that versioneer isn't imported at run time?

msarahan commented 5 years ago

what do you mean at runtime? Versioneer never runs at runtime as I understand it. That would indeed be very slow. It runs when setup.py runs, and from there the version is "baked" and things are fast.

Are there any other options that you would prefer? setuptools_scm?

scopatz commented 5 years ago

Sorry for not being clear, I was refering to the fact that versioneer has you import the _version.py file in __init__.py. For example, what this file looks like for conda-build right now is:

import json

version_json = '''
{
 "date": "2019-01-26T21:02:48-0600",
 "dirty": false,
 "error": null,
 "full-revisionid": "5da509d13764d96c02c80f24b54ab87d652b2538",
 "version": "3.17.8"
}
'''  # END VERSION_JSON

def get_versions():
    return json.loads(version_json)

The thing I don't understand is why it imports json and calling a function rather than just having the dictionary, or better yet, just replacing the version string somewhere in the code base. There has got to be some justification for this level of indirection, but I don't understand it so it has always seemed a bit much for projects that don't otherwise import JSON.

Anyway, I am not really an expert on all of the tooling here. I'll look up what setuptools_scm does.

msarahan commented 5 years ago

I see what you mean, and I totally agree. That is a bizarre design.

scopatz commented 5 years ago

It seems that setuptools_scm uses pkg_resources, so that is a hard pass :man_facepalming: versioneer it is. For rever startup time doesn't matter so much, so it isn't a huge issue.