From 765f9ae2875a2ef4439470fb4cf4adefdda2ed67 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sun, 14 Oct 2018 15:59:49 +0200 Subject: [PATCH] Add python pip packaging Fixes mnauw/git-remote-hg#13 --- Makefile | 12 +++++++++++- setup.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 setup.py diff --git a/Makefile b/Makefile index c654faf..841d261 100644 --- a/Makefile +++ b/Makefile @@ -26,4 +26,14 @@ install-doc: doc install -d -m 755 $(D)$(mandir)/ install -m 644 doc/git-remote-hg.1 $(D)$(mandir)/git-remote-hg.1 -.PHONY: all test install install-doc clean +pypi: + -rm -rf dist build + python setup.py sdist bdist_wheel + +pypi-upload: + twine upload dist/* + +pypi-test: + twine upload --repository-url https://test.pypi.org/legacy/ dist/* + +.PHONY: all test install install-doc clean pypy pypy-upload diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..26afd17 --- /dev/null +++ b/setup.py @@ -0,0 +1,53 @@ +# git-remote-hg setuptools script + +import setuptools +import subprocess +import sys +import os + +# derive version from git repo +cmd = ["git", "describe", "--tags"] +commit = os.environ.get('REV', None) +if commit: + cmd.append(commit) +process = subprocess.Popen(cmd, stdout=subprocess.PIPE) +version = process.communicate()[0].strip() +# strip leading v +version = version[1:] + +# check for released version +assert (len(version) > 0) +assert (version.find('-') < 0) + +long_description = \ +""" +'git-remote-hg' is a gitremote protocol helper for Mercurial. +It allows you to clone, fetch and push to and from Mercurial repositories as if +they were Git ones using a hg::some-url URL. + +See the homepage for much more explanation. +""" + +CLASSIFIERS = [ + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "License :: OSI Approved", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", +] + +setuptools.setup(name="git-remote-hg", + version=version, + author="Mark Nauwelaerts", + author_email="mnauw@users.sourceforge.net", + url="http://github.com/mnauw/git-remote-hg", + description="access hg repositories as git remotes", + long_description=long_description, + license="GPLv2", + keywords="git hg mercurial", + scripts=["git-remote-hg", "git-hg-helper"], + classifiers=CLASSIFIERS + ) +