source: dreqML/trunk/setup.py @ 453

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/dreqML/trunk/setup.py@453
Revision 453, 2.9 KB checked in by mjuckes, 4 years ago (diff)

dreqML

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