Skip to content

Commit

Permalink
Merge pull request #181 from MetOffice/feature_setuppy_i174
Browse files Browse the repository at this point in the history
add requirements directory and setup.py now use requirement.txt #174
  • Loading branch information
zmaalick authored Feb 1, 2021
2 parents 6ec0dc1 + cd9c5b0 commit 3f84129
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

5 changes: 5 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# file contains the list of required libraries for pip build
numpy
matplotlib
six
scipy
27 changes: 22 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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",
Expand Down
32 changes: 32 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 3f84129

Please sign in to comment.