diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9664ac2..0000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -numpy==1.15.4 -matplotlib=3.3.1 -six=1.15.0 -scipy=1.5.1 diff --git a/requirements/requirements.txt b/requirements/requirements.txt new file mode 100644 index 0000000..f94762e --- /dev/null +++ b/requirements/requirements.txt @@ -0,0 +1,5 @@ +# file contains the list of required libraries for pip build +numpy +matplotlib +six +scipy diff --git a/setup.py b/setup.py index 989fd7a..8d1af97 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,32 @@ import setuptools +import os from distutils.core import setup +PACKAGE_DIR = os.path.abspath(os.path.dirname(__file__)) with open("README.md", "r") as fh: long_description = fh.read() +def pip_requirements(*args): + requirements = [] + for name in args: + fname = os.path.join( + PACKAGE_DIR, "requirements", "{}.txt".format(name) + ) + if not os.path.exists(fname): + emsg = ( + f"Unable to find the {name!r} requirements file at {fname!r}." + ) + raise RuntimeError(emsg) + with open(fname, "r") as fh: + for line in fh: + line = line.strip() + if not line or line.startswith("#"): + continue + requirements.append(line) + return requirements + setup(name='mo-catnip', version='0.0.2', @@ -19,11 +40,7 @@ packages=setuptools.find_packages(where='lib'), package_dir={"": "lib"}, python_requires='>=3.6', - install_requires=['numpy', - 'matplotlib', - 'six', - 'scipy' - ], + install_requires=pip_requirements("requirements"), keywords = ["cmip", "climate", "analysis", "rcp"], classifiers=[ "Programming Language :: Python :: 3", diff --git a/test.py b/test.py new file mode 100644 index 0000000..b7ab3f9 --- /dev/null +++ b/test.py @@ -0,0 +1,32 @@ +import os + + + +PACKAGE_DIR = os.path.abspath(os.path.dirname(__file__)) + + + + + +def pip_requirements(*args): + requirements = [] + for name in args: + fname = os.path.join( + PACKAGE_DIR, "requirements", "{}.txt".format(name) + ) + if not os.path.exists(fname): + emsg = ( + f"Unable to find the {name!r} requirements file at {fname!r}." + ) + raise RuntimeError(emsg) + with open(fname, "r") as fh: + for line in fh: + line = line.strip() + if not line or line.startswith("#"): + continue + requirements.append(line) + return requirements + + +req = pip_requirements("requirements") +print(req)