Skip to main content

Robustly generate exact git hashes for python packages

Project description

Robustly generate exact git hashes for python packages

Installation

pip install pygitversion

Usage

The point of pygitversion is to enable you to robustly create your package with exact git version information, rather than just a simple version specifier.

It does not replace the semantic version specifier of your package, but rather complements it. pygitversion provides the tools necessary to always have git information available in a Python package (whether the actual repo is available or not).

To use in your package, follow these steps:

  1. If pyproject.toml does not exist in your package, create it.

  2. Add the key [build-system] to pyproject.toml, and add requires = ['pygitversion'] to the key.

  3. Ensure that __init__.py contains the correct semantic __version__ specifier.

  4. In setup.py, add the following:

    import pygitversion
    pygitversion.write_git_info_file(__name__)
  5. Ensure the package has a MANIFEST.in, and that it includes <package>/GIT_INFO.

  6. The git version of the module may then be accessed by doing:

    import pygitversion
    pygitversion.construct_version_info(<package_name>)
  7. It is recommended (but not necessary) that __init__.py contain:

    import pygitversion
    GIT_VERSION = pygitversion.construct_version_info(__name__)

Cases Addressed

There are various ways a package can be installed, and pygitversion attempts to ensure that in each case, the git version is available. The following assumes the above steps have been followed in your package.

  1. Package cloned and installed via pip install .: a GIT_INFO file is created and installed due to MANIFEST.in. That GIT_INFO file is found whenever the package is loaded.

  2. Package cloned and installed via pip install -e .: a GIT_INFO file is created in the repo, and sym-linked when the package is imported.

  3. Package installed directly from hosted source control via pip install git+git:...: Unsure?

  4. Package installed from PyPI (pip install <package>): the process of building the sdist and bdist to upload to PyPI inherently bundles the most current GIT_INFO file as part of the build, and this is installed with the package.

Development

To run the all tests run:

tox

Changelog

0.1.0 (2019-09-04)

  • First release on PyPI.

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

pygitversion-0.1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

pygitversion-0.1.1-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pygitversion-0.1.1.tar.gz.

File metadata

  • Download URL: pygitversion-0.1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4

File hashes

Hashes for pygitversion-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ba6053d9becfe6e16159707329dc51873775f02dcea0e71607c6959beb54fe38
MD5 7d5d52f602c4a9b824921dec5c2fbb31
BLAKE2b-256 efe2097920e74fec6437065653da450ec37d5f7964b875604af2a87207bf280d

See more details on using hashes here.

File details

Details for the file pygitversion-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pygitversion-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4

File hashes

Hashes for pygitversion-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9c9cda335b8c4d9f4ba32762d8c7ab390ebf241ed21e21bd88143b2fbb990ab3
MD5 4ce3a13001b904e0eb97ab0d3f52e20c
BLAKE2b-256 2fd489fc8057b824c4e50bce83ebf1af08dbaa64f58711f7dd0f25654e8f0154

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