44# Note: To use the 'upload' functionality of this file, you must:
55# $ pip install twine
66
7- import io
7+ import io , json
88import os
99import sys
1010from shutil import rmtree
1111
1212from setuptools import find_packages , setup , Command
1313
14- # Package meta-data.
15- NAME = 'caltechdata_api'
16- DESCRIPTION = "Python wrapper for the CaltechDATA API."
17- URL = 'https://github.com/caltechlibrary/caltechdata_api'
18- 19- AUTHOR = 'Tom Morrell'
14+ def read (fname ):
15+ with open (fname , mode = "r" , encoding = "utf-8" ) as f :
16+ src = f .read ()
17+ return src
18+
19+ codemeta_json = "codemeta.json"
20+
21+ # Let's pickup as much metadata as we need from codemeta.json
22+ with open (codemeta_json , mode = "r" , encoding = "utf-8" ) as f :
23+ src = f .read ()
24+ meta = json .loads (src )
25+
26+ # Let's make our symvar string
27+ version = meta ["version" ]
28+
29+ # Now we need to pull and format our author, author_email strings.
30+ author = ""
31+ author_email = ""
32+ for obj in meta ["author" ]:
33+ given = obj ["givenName" ]
34+ family = obj ["familyName" ]
35+ email = obj ["email" ]
36+ if len (author ) == 0 :
37+ author = given + " " + family
38+ else :
39+ author = author + ", " + given + " " + family
40+ if len (author_email ) == 0 :
41+ author_email = email
42+ else :
43+ author_email = author_email + ", " + email
44+ description = meta ['description' ]
45+ url = meta ['codeRepository' ]
46+ download = meta ['downloadUrl' ]
47+ license = meta ['license' ]
48+ name = meta ['name' ]
49+
2050REQUIRES_PYTHON = '>=3.7.0'
21- VERSION = '0.1.0'
2251
2352# What packages are required for this module to be executed?
2453REQUIRED = [
4372 with io .open (os .path .join (here , 'README.md' ), encoding = 'utf-8' ) as f :
4473 long_description = '\n ' + f .read ()
4574except FileNotFoundError :
46- long_description = DESCRIPTION
75+ long_description = description
4776
4877# Load the package's __version__.py module as a dictionary.
4978about = {}
50- if not VERSION :
79+ if not version :
5180 with open (os .path .join (here , NAME , '__version__.py' )) as f :
5281 exec (f .read (), about )
5382else :
54- about ['__version__' ] = VERSION
83+ about ['__version__' ] = version
5584
5685
5786class UploadCommand (Command ):
@@ -89,15 +118,15 @@ def run(self):
89118
90119# Where the magic happens:
91120setup (
92- name = NAME ,
121+ name = name ,
93122 version = about ['__version__' ],
94- description = DESCRIPTION ,
123+ description = description ,
95124 long_description = long_description ,
96125 long_description_content_type = 'text/markdown' ,
97- author = AUTHOR ,
98- author_email = EMAIL ,
126+ author = author ,
127+ author_email = author_email ,
99128 python_requires = REQUIRES_PYTHON ,
100- url = URL ,
129+ url = url ,
101130 packages = find_packages (exclude = ('tests' ,)),
102131 # If your package is a single module, use this instead of 'packages':
103132 # py_modules=['mypackage'],
@@ -108,7 +137,7 @@ def run(self):
108137 install_requires = REQUIRED ,
109138 extras_require = EXTRAS ,
110139 include_package_data = True ,
111- license = 'BSD' ,
140+ license = license ,
112141 classifiers = [
113142 # Trove classifiers
114143 # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
0 commit comments