From 73c90887e8b3fad8d6db738432c7597430b1d6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 4 May 2018 09:59:31 +0200 Subject: [PATCH] Fix pip installation --- setup.py | 29 +++++++++++++++-------------- soil/VERSION | 1 + soil/__init__.py | 2 +- soil/version.py | 20 ++++++++++++++++++++ 4 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 soil/VERSION create mode 100644 soil/version.py diff --git a/setup.py b/setup.py index 0530f48..ff729e3 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,21 @@ -import pip +import os from setuptools import setup -# parse_requirements() returns generator of pip.req.InstallRequirement objects -from pip.req import parse_requirements -from soil import __version__ -try: - install_reqs = parse_requirements( - "requirements.txt", session=pip.download.PipSession()) - test_reqs = parse_requirements( - "test-requirements.txt", session=pip.download.PipSession()) -except AttributeError: - install_reqs = parse_requirements("requirements.txt") - test_reqs = parse_requirements("test-requirements.txt") -install_reqs = [str(ir.req) for ir in install_reqs] -test_reqs = [str(ir.req) for ir in test_reqs] +with open(os.path.join('soil', 'VERSION')) as f: + __version__ = f.read().strip() + assert __version__ + + +def parse_requirements(filename): + """ load requirements from a pip requirements file """ + with open(filename, 'r') as f: + lineiter = list(line.strip() for line in f) + return [line for line in lineiter if line and not line.startswith("#")] + + +install_reqs = parse_requirements("requirements.txt") +test_reqs = parse_requirements("test-requirements.txt") setup( diff --git a/soil/VERSION b/soil/VERSION new file mode 100644 index 0000000..42624f3 --- /dev/null +++ b/soil/VERSION @@ -0,0 +1 @@ +0.10.2 \ No newline at end of file diff --git a/soil/__init__.py b/soil/__init__.py index 80572f0..a9b92c9 100644 --- a/soil/__init__.py +++ b/soil/__init__.py @@ -4,7 +4,7 @@ import os import pdb import logging -__version__ = "0.10.1" +from .version import __version__ try: basestring diff --git a/soil/version.py b/soil/version.py new file mode 100644 index 0000000..ea5b40a --- /dev/null +++ b/soil/version.py @@ -0,0 +1,20 @@ +import os +import logging + +logger = logging.getLogger(__name__) + +ROOT = os.path.dirname(__file__) +DEFAULT_FILE = os.path.join(ROOT, 'VERSION') + + +def read_version(versionfile=DEFAULT_FILE): + try: + with open(versionfile) as f: + return f.read().strip() + except IOError: # pragma: no cover + logger.error(('Running an unknown version of {}.' + 'Be careful!.').format(__name__)) + return '0.0' + + +__version__ = read_version()