From bcde0dc9c1e013dc885c604b86cb705a41cbd948 Mon Sep 17 00:00:00 2001 From: Paul Wildenhain Date: Mon, 30 Mar 2020 13:21:20 -0400 Subject: [PATCH 1/3] :pencil2: Implement static versioning Fixes #87 --- redcap/__init__.py | 1 - redcap/version.py | 8 -------- setup.py | 10 +--------- 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 redcap/version.py diff --git a/redcap/__init__.py b/redcap/__init__.py index 39c209b..ea9255f 100644 --- a/redcap/__init__.py +++ b/redcap/__init__.py @@ -18,4 +18,3 @@ class with the URL to your REDCap system along with an API key, probably from .project import Project from .request import RCRequest, RCAPIError, RedcapError -from .version import VERSION as __version__ diff --git a/redcap/version.py b/redcap/version.py deleted file mode 100644 index a98c726..0000000 --- a/redcap/version.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -__author__ = 'Scott Burns ' -__license__ = 'MIT' -__copyright__ = '2014, Vanderbilt University' - -VERSION = '1.0.2' diff --git a/setup.py b/setup.py index cece97d..f0e7ca4 100644 --- a/setup.py +++ b/setup.py @@ -12,14 +12,6 @@ except ImportError: from distutils.core import setup - -def get_version(): - base = os.path.dirname(__file__) - with open(os.path.join(base, 'redcap/version.py')) as f: - VERSION = None - exec(f.read()) - return VERSION - required = [ 'requests>=1.0.0', 'semantic-version>=2.3.1' @@ -37,7 +29,7 @@ def get_version(): description="""PyCap: Python interface to REDCap""", license='MIT', url='http://sburns.github.com/PyCap', - version=get_version(), + version='1.0.2', download_url='http://sburns.github.com/PyCap', long_description=long_desc, packages=['redcap'], From 7a48e2c11c1aec626eaee13816f4acd0aaaa8e83 Mon Sep 17 00:00:00 2001 From: Paul Wildenhain Date: Mon, 30 Mar 2020 17:03:07 -0400 Subject: [PATCH 2/3] :memo: Add version in __init__.py --- redcap/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/redcap/__init__.py b/redcap/__init__.py index ea9255f..f4df935 100644 --- a/redcap/__init__.py +++ b/redcap/__init__.py @@ -4,6 +4,7 @@ __author__ = 'Scott Burns ' __license__ = 'MIT' __copyright__ = '2014, Vanderbilt University' +__version__ = '1.0.2' """ This module exposes the REDCap API through the Project class. Instantiate the From 96c92f8d8234d00a2207b9c95fbe15b7e415b008 Mon Sep 17 00:00:00 2001 From: Paul Wildenhain Date: Fri, 8 May 2020 14:30:59 -0400 Subject: [PATCH 3/3] :moneybag: Swipe code from vulture setup.py for better versioning Tested this locally and it sucessfully recognized the version. :bowing_man: many thanks to `vulture` --- setup.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f0e7ca4..dbe302b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,24 @@ __license__ = 'MIT' __copyright__ = '2014, Vanderbilt University' +import codecs import os +import re + +# Taken from vulture setup.py: https://github.com/jendrikseipp/vulture/blob/master/setup.py +def read(*parts): + here = os.path.abspath(os.path.dirname(__file__)) + with codecs.open(os.path.join(here, *parts), "r") as f: + return f.read() + +def find_version(*file_parts): + version_file = read(*file_parts) + version_match = re.search( + r"^__version__ = ['\"]([^'\"]*)['\"]$", version_file, re.M + ) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") try: from setuptools import setup @@ -29,7 +46,7 @@ description="""PyCap: Python interface to REDCap""", license='MIT', url='http://sburns.github.com/PyCap', - version='1.0.2', + version=find_version("redcap", "__init__.py"), download_url='http://sburns.github.com/PyCap', long_description=long_desc, packages=['redcap'],