source: CMIP6dreq/tags/01.beta.35/setup.py @ 738

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq/tags/01.beta.35/setup.py@753
Revision 738, 2.9 KB checked in by mjuckes, 4 years ago (diff)

for python3

Line 
1import codecs
2import os, sys
3import re
4
5from setuptools import setup, find_packages
6
7####################################################################
8
9NAME = "dreqPy"
10python2 = True
11if sys.version_info[0] == 3:
12  PACKAGES = find_packages(exclude=["tests*","dreqPy.utilP2"])
13  python2 = False
14else:
15  PACKAGES = find_packages(exclude=["tests*"])
16
17META_PATH = os.path.join("dreqPy", "packageConfig.py")
18KEYWORDS = ["CMIP6"]
19CLASSIFIERS = [
20    "Development Status :: 4 - Beta",
21    "Intended Audience :: Developers",
22    "Natural Language :: English",
23    "License :: OSI Approved :: MIT License",
24    "Operating System :: OS Independent",
25    "Programming Language :: Python",
26    "Programming Language :: Python :: 2",
27    "Programming Language :: Python :: 2.7",
28    "Programming Language :: Python :: 3",
29    "Topic :: Software Development :: Libraries :: Python Modules",
30]
31INSTALL_REQUIRES = []
32
33###################################################################
34
35HERE = os.path.abspath(os.path.dirname(__file__))
36
37
38def read(*parts):
39    """
40    Build an absolute path from *parts* and and return the contents of the
41    resulting file.  Assume UTF-8 encoding.
42    """
43    with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f:
44        return f.read()
45
46
47META_FILE = read(META_PATH)
48
49def find_meta(meta):
50    """
51    Extract __*meta*__ from META_FILE.
52    """
53    import dreqPy.packageConfig as pcfg
54    if '__%s__' % meta in pcfg.__dict__:
55      return pcfg.__dict__[ '__%s__' % meta ]
56
57    raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
58
59def find_meta0(meta):
60    """
61    Extract __*meta*__ from META_FILE.
62    """
63    meta_match = re.search(
64        r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta),
65        META_FILE, re.M
66    )
67    if meta_match:
68        return meta_match.group(1)
69    raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
70
71class test(object):
72  def __init__(self):
73    for v in ['license','uri','version']:
74      print ( '%s: %s' % (v,find_meta(v) ) )
75      assert os.path.isfile( 'LICENSE' ), 'License file not found'
76      assert os.path.isfile( 'README.txt' ), 'README file not found'
77
78if __name__ == "__main__":
79   if len(sys.argv) > 1 and sys.argv[1] == '-t':
80      t = test()
81   else:
82      setup(
83        name=NAME,
84        description=find_meta("description"),
85        license=find_meta("license"),
86        url=find_meta("uri"),
87        version=find_meta("version"),
88        author=find_meta("author"),
89        author_email=find_meta("email"),
90        maintainer=find_meta("author"),
91        maintainer_email=find_meta("email"),
92        keywords=KEYWORDS,
93        include_package_data=True,
94        long_description=read("README.txt"),
95        packages=PACKAGES,
96        zip_safe=False,
97        classifiers=CLASSIFIERS,
98        install_requires=INSTALL_REQUIRES,
99        data_files = [("", ["LICENSE"])],
100        entry_points= {
101        'console_scripts': ['drq = dreqPy.dreqCmdl:main_entry'],
102        },
103    )
Note: See TracBrowser for help on using the repository browser.