pygit2:version: add 'pygit2.__version__' for easy access from client software.

Moved the hardcoded version from setup.py to pygit2/version.py so
client software can figure out which version of pygit2 it's using.
Having setup.py import pygit2.version.__version__ removes duplication,
and also means that setup.py will always use the local version (and
not the version of a previously installed pygit2).
This commit is contained in:
W. Trevor King 2012-09-13 07:52:22 -04:00
parent bc0c0e17a8
commit f10d2b7b3f
3 changed files with 33 additions and 1 deletions

@ -25,5 +25,6 @@
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
from .version import __version__
from _pygit2 import *
import pygit2.utils

26
pygit2/version.py Normal file

@ -0,0 +1,26 @@
# Copyright 2012 The pygit2 contributors
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2,
# as published by the Free Software Foundation.
#
# In addition to the permissions in the GNU General Public License,
# the authors give you unlimited permission to link the compiled
# version of this file into combinations with other programs,
# and to distribute those combinations without any restriction
# coming from the use of this file. (The General Public License
# restrictions do apply in other respects; for example, they cover
# modification of the file, and distribution when not linked into
# a combined executable.)
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
__version__ = '0.17.2'

@ -38,6 +38,11 @@ from distutils.command.build import build
from distutils.command.sdist import sdist
from distutils import log
# read version from local pygit2/version.py without pulling in
# pygit2/__init__.py
sys.path.insert(0, 'pygit2')
from version import __version__
# Use environment variable LIBGIT2 to set your own libgit2 configuration.
libgit2_path = os.getenv("LIBGIT2")
@ -163,7 +168,7 @@ with open('README.rst') as readme:
setup(name='pygit2',
description='Python bindings for libgit2.',
keywords='git',
version='0.17.2',
version=__version__,
url='http://github.com/libgit2/pygit2',
classifiers=classifiers,
license='GPLv2',