Skip to main content

minimal versioning tool

Project description

Miniver

license: CC0-1.0 PyPI version

Like versioneer, but smaller

Miniver is a minimal versioning tool that serves the same purpose as Versioneer, except that it is not designed to be cross platform, and only works with Git.

Why would I use this?

If you are developing a Python package inside a Git repository and want to get the version directly from Git tags, rather than hard-coding version strings everywhere.

This is the same problem that Versioneer solves, but Miniver is less than 200 lines of code, whereas Versioneer is over 2000. The tradeoff is that Miniver only works with Git and Python 3.5 (or above), and has only been tested on Debian Linux and Mac OSX (so far).

Support for Python 2 is not a goal, as Python 2 is fast approaching its end of life (2020), and we want to encourage people to use Python 3! That being said, Christian Marquardt has a fork that also works with Python 2

Usage

The simplest way to use Miniver is to run the following in your project root:

curl https://raw.githubusercontent.com/jbweston/miniver/master/install-miniver | python - <your_package_directory>

This will grab the latest files from GitHub and set up Miniver for your project.

I don't want to type that URL every time I use this

You can pip install miniver, which will give you the install-miniver script. Then you can simply run the following from your project root to use Miniver:

install-miniver <your_package_directory>

Can I use this without executing random code from the internet?

Sure! Copy miniver/_version.py and miniver/_static_version.py from this repository into your package directory, then copy the following snippets into the appropriate files:

# Your package's __init__.py
from ._version import __version__
del _version
# Your project's setup.py

# Loads _version.py module without importing the whole package.
def get_version_and_cmdclass(package_name):
    import os
    from importlib.util import module_from_spec, spec_from_file_location
    spec = spec_from_file_location('version',
                                   os.path.join(package_name, '_version.py'))
    module = module_from_spec(spec)
    spec.loader.exec_module(module)
    return module.__version__, module.cmdclass


version, cmdclass = get_version_and_cmdclass('my_package')

setup(
    name='my_package',
    version=version,
    cmdclass=cmdclass,
)
# Your project's .gitattributes
my_package/_static_version.py export-subst

replacing 'my_package' in the above with the name of your package (this should be the same as the name of the directory into which you copied the contents of miniver).

That's it!

License

Miniver is in the public domain under a CC0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

miniver-0.3.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

miniver-0.3.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file miniver-0.3.1.tar.gz.

File metadata

  • Download URL: miniver-0.3.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for miniver-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2886ecf3d5c39e8bf3c566db654cbc022e4f852a8686886b3b48f0e7f1c7783d
MD5 fa5394ae2fdf35638872754295c92708
BLAKE2b-256 7361a7506cd80195b2ae177399da3b0898f5da48525312bddc5b190ff4a71bf2

See more details on using hashes here.

File details

Details for the file miniver-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for miniver-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5d00407b9a48b4c34897e0294be43be0989d136e7abe0a530a548e64960dd8c
MD5 ccd1339c9cf0b8a8e23158f5899bd1df
BLAKE2b-256 a0efcd8295314a9e842d8285525f4a643c50486ed72aae52cfcf02dc316bb010

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page