# HG changeset patch # User Dan Villiom Podlaski Christiansen <danchr@gmail.com> # Date 1620055197 -7200 # Mon May 03 17:19:57 2021 +0200 # Node ID 7b52dc1baba119702e5b358fbc7d887256e66585 # Parent 24c32a1d06676b0e6141f49d1c483500569679d5 setup: use setup.cfg & setuptools_scm diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -1,3 +1,6 @@ +syntax: re +^hggit/__version__\.py$ + syntax: glob *.pyc tests/*.err diff --git a/hggit/__init__.py b/hggit/__init__.py --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -150,6 +150,8 @@ from . import schemes from . import templates +import dulwich + from mercurial import ( demandimport, exthelper, @@ -160,8 +162,6 @@ b'collections', } -__version__ = b'0.11.0dev' - testedwith = (b'5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0') minimumhgversion = b'5.2' buglink = b'https://foss.heptapod.net/mercurial/hg-git/issues' @@ -194,6 +194,28 @@ def getversion(): """return version with dependencies for hg --version -v""" - import dulwich - dulver = b'.'.join(pycompat.sysbytes(str(i)) for i in dulwich.__version__) - return __version__ + (b" (dulwich %s)" % dulver) + # first, try to get a built version + try: + from .__version__ import version + except ImportError: + version = None + + # if that fails, try to determine the version from the checkout + if version is None: + try: + from setuptools_scm import get_version + + version = get_version( + root='..', + relative_to=__file__, + version_scheme="release-branch-semver", + ) + except: + # something went wrong, but we need to provide something + version = "unknown" + + # include the dulwich version, as it's fairly important for the + # level of functionality + dulver = '.'.join(map(str, dulwich.__version__)) + + return pycompat.sysbytes("%s (dulwich %s)" % (version, dulver)) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,11 @@ +[build-system] +requires = [ + "setuptools >= 42", + "setuptools_scm[toml]>=6.0", + "wheel", +] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "hggit/__version__.py" +version_scheme = "release-branch-semver" diff --git a/setup.cfg b/setup.cfg --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,25 @@ +[metadata] +name = hg-git +author = Scott Chacon, Augie Fackler, Kevin Bullock and others +maintainer = The hg-git maintainers +maintainer_email = hg-git@googlegroups.com +url = http://foss.heptapod.net/mercurial/hg-git +description = push to and pull from a Git repository using Mercurial +long_description = file:README.rst +keywords = hg git mercurial +license = GPLv2 + +[options] +include_package_data=True +zip_safe=False +python_requires = >=3.6 +packages = hggit +install_requires= + dulwich>=0.19.3 + +[options.package_data] +* = *.txt, *.rst + [flake8] # E,W will ignore all pep8 ignore=E129 diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1,42 +1,9 @@ -from __future__ import generator_stop - -from os.path import dirname, join +import setuptools try: - from setuptools import setup -except: - from distutils.core import setup - - -def get_file(relpath): - root = dirname(__file__) - with open(join(root, relpath)) as fp: - return fp.read().strip() - - -def get_version(relpath): - for line in get_file(relpath).splitlines(): - line = line - if '__version__' in line: - return line.split("'")[1] - + import setuptools_scm + assert setuptools_scm # silence pyflakes +except ImportError: + pass -setup( - name='hg-git', - version=get_version('hggit/__init__.py'), - author='The hg-git Authors', - maintainer='Kevin Bullock', - maintainer_email='kbullock+mercurial@ringworld.org', - url='http://foss.heptapod.net/mercurial/hg-git', - description='push to and pull from a Git repository using Mercurial', - long_description=get_file("README.rst"), - keywords='hg git mercurial', - license='GPLv2', - packages=['hggit'], - include_package_data=True, - zip_safe=True, - python_requires='>=3.6', - install_requires=[ - 'dulwich>=0.19.3', - ], -) +setuptools.setup()