From 48522a1d9bb9ff2b729b0c34c32d288b0518c633 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 10 May 2017 15:07:09 -0400 Subject: Implement RELIC --- .gitignore | 3 +- .gitmodules | 3 ++ MANIFEST.in | 1 + purge_path/extern/__init__.py | 0 purge_path/extern/version.py | 114 ------------------------------------------ purge_path/version.py | 1 - relic | 1 + setup.py | 27 ++++------ 8 files changed, 18 insertions(+), 132 deletions(-) create mode 100644 .gitmodules delete mode 100644 purge_path/extern/__init__.py delete mode 100644 purge_path/extern/version.py delete mode 100644 purge_path/version.py create mode 160000 relic diff --git a/.gitignore b/.gitignore index eb39413..1aab4ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ +RELIC-INFO +*/version.py *__pycache__* *.swp *.egg-info dist/ build/ -RELEASE-VERSION diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6d623ae --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "relic"] + path = relic + url = https://github.com/jhunkeler/relic.git diff --git a/MANIFEST.in b/MANIFEST.in index 466cd00..7d626c2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ +include RELIC-INFO include RELEASE-VERSION diff --git a/purge_path/extern/__init__.py b/purge_path/extern/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/purge_path/extern/version.py b/purge_path/extern/version.py deleted file mode 100644 index 8e775c6..0000000 --- a/purge_path/extern/version.py +++ /dev/null @@ -1,114 +0,0 @@ -# -*- coding: utf-8 -*- -# Author: Douglas Creager -# This file is placed into the public domain. - -# Calculates the current version number. If possible, this is the -# output of “git describe”, modified to conform to the versioning -# scheme that setuptools uses. If “git describe” returns an error -# (most likely because we're in an unpacked copy of a release tarball, -# rather than in a git working copy), then we fall back on reading the -# contents of the RELEASE-VERSION file. -# -# To use this script, simply import it your setup.py file, and use the -# results of get_git_version() as your package version: -# -# from version import * -# -# setup( -# version=get_git_version(), -# . -# . -# . -# ) -# -# This will automatically update the RELEASE-VERSION file, if -# necessary. Note that the RELEASE-VERSION file should *not* be -# checked into git; please add it to your top-level .gitignore file. -# -# You'll probably want to distribute the RELEASE-VERSION file in your -# sdist tarballs; to do this, just create a MANIFEST.in file that -# contains the following line: -# -# include RELEASE-VERSION -from __future__ import print_function -from subprocess import Popen, PIPE -import sys - -__all__ = ("get_git_version") - -PY3 = sys.version_info[0] == 3 - - -def call_git_describe(abbrev=4): - line = '' - try: - p = Popen(['git', 'describe', '--abbrev=%d' % abbrev], - stdout=PIPE, stderr=PIPE) - p.stderr.close() - if PY3: - line = p.stdout.readlines()[0].decode() - else: - line = p.stdout.readlines()[0] - return line.strip() - - except: - return None - - -def read_release_version(): - try: - f = open("RELEASE-VERSION", "r") - - try: - if PY3: - version = f.readlines()[0].decode() - else: - version = f.readlines()[0] - return version.strip() - - finally: - f.close() - - except: - return None - - -def write_release_version(version): - f = open("RELEASE-VERSION", "w") - f.write("%s\n" % version) - f.close() - - -def get_git_version(abbrev=4): - # Read in the version that's currently in RELEASE-VERSION. - - release_version = read_release_version() - - # First try to get the current version using “git describe”. - - version = call_git_describe(abbrev) - - # If that doesn't work, fall back on the value that's in - # RELEASE-VERSION. - - if version is None: - version = release_version - - # If we still don't have anything, that's an error. - - if version is None: - raise ValueError("Cannot find the version number!") - - # If the current version is different from what's in the - # RELEASE-VERSION file, update the file to be current. - - if version != release_version: - write_release_version(version) - - # Finally, return the current version. - - return version - - -if __name__ == "__main__": - print(get_git_version()) diff --git a/purge_path/version.py b/purge_path/version.py deleted file mode 100644 index 6849410..0000000 --- a/purge_path/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "1.1.0" diff --git a/relic b/relic new file mode 160000 index 0000000..30fe110 --- /dev/null +++ b/relic @@ -0,0 +1 @@ +Subproject commit 30fe110b1085362ff479543c12dfe6627af3a0b8 diff --git a/setup.py b/setup.py index 6b3927c..1f855b6 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,14 @@ import os +import sys from setuptools import setup, find_packages -from purge_path.extern.version import get_git_version +sys.path.insert(1, 'relic') + +import relic.release +from setuptools import setup + +NAME = 'purge_path' +version = relic.release.get_info() +relic.release.write_template(version, NAME) entry_points = {} package_data = {} @@ -10,29 +18,16 @@ entry_points['console_scripts'] = [ ] package_data[''] = ['*.txt', '*.md'] -version_py = os.path.join('purge_path', 'version.py') - -#Omit git hash and let setuptools add a valid build number -git_version = get_git_version() -if git_version.rfind('-') != -1: - git_version = git_version[:git_version.rfind('-')] -with open(version_py, 'w+') as version_data: - version_data.write('__version__ = "{0}"\n'.format(git_version)) - -NAME = 'purge_path' -VERSION = git_version - setup( name=NAME, - version=VERSION, + version=version.pep386, description='A small PATH manipulator', - provides=[NAME], author='Joseph Hunkeler', author_email='jhunk@stsci.edu', license='BSD', - url='http://bitbucket.org/jhunkeler/purge_path', + url='http://github.com/jhunkeler/purge_path', download_url='', use_2to3=True, packages=find_packages(), -- cgit