Skip to content

Commit

Permalink
Refactor version handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Darius Morawiec committed Mar 23, 2017
1 parent 8d6e157 commit 06ec7ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
16 changes: 10 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
from setuptools import setup, find_packages


fname = os.path.join('.', 'sklearn_porter', '__version__.txt')
version = open(fname).readlines().pop()
path = os.path.abspath(os.path.dirname(__file__))

# Version:
version_path = str(os.path.join(path, 'sklearn_porter', '__version__.txt'))
version = open(version_path).readlines().pop()
if isinstance(version, bytes):
version = version.decode('utf-8')
version = str(version).strip()

path = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(path, 'requirements.txt')) as f:
# Requirements:
requirements_path = os.path.join(path, 'requirements.txt')
with open(requirements_path) as f:
all_reqs = f.read().split('\n')
install_requires = [x.strip() for x in all_reqs if 'git+' not in x]
requirements = [x.strip() for x in all_reqs if 'git+' not in x]

setup(
name='sklearn-porter',
Expand All @@ -34,7 +38,7 @@
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
install_requires=install_requires,
install_requires=requirements,
keywords=['sklearn', 'scikit-learn'],
license='MIT',
)
9 changes: 8 additions & 1 deletion sklearn_porter/Porter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@


class Porter:
__version__ = '0.4.0'

# Version:
_version_path = str(os.path.join(os.path.dirname(__file__),
'__version__.txt'))
_version = open(_version_path).readlines().pop()
if isinstance(_version, bytes):
_version = _version.decode('utf-8')
__version__ = str(_version).strip()

def __init__(self, model, language='java', method='predict', **kwargs):
"""
Expand Down

0 comments on commit 06ec7ab

Please sign in to comment.