2 # Generic setup script for single-module Python projects
3 # by Thomas Perl <thp.io/about>
5 from distutils
.core
import setup
10 SCRIPT_FILE
= PACKAGE
+ '.py'
12 main_py
= open(SCRIPT_FILE
).read()
13 metadata
= dict(re
.findall("__([a-z]+)__ = '([^']+)'", main_py
))
14 docstrings
= re
.findall('"""(.*?)"""', main_py
, re
.DOTALL
)
16 # List the modules that need to be installed/packaged
21 # Metadata fields extracted from SCRIPT_FILE
22 AUTHOR_EMAIL
= metadata
['author']
23 VERSION
= metadata
['version']
24 WEBSITE
= metadata
['website']
25 LICENSE
= metadata
['license']
26 DESCRIPTION
= docstrings
[0].strip()
27 if '\n\n' in DESCRIPTION
:
28 DESCRIPTION
, LONG_DESCRIPTION
= DESCRIPTION
.split('\n\n', 1)
30 LONG_DESCRIPTION
= None
32 # Extract name and e-mail ("Firstname Lastname <mail@example.org>")
33 AUTHOR
, EMAIL
= re
.match(r
'(.*) <(.*)>', AUTHOR_EMAIL
).groups()
37 description
=DESCRIPTION
,
38 long_description
=LONG_DESCRIPTION
,
44 download_url
=WEBSITE
+PACKAGE
+'-'+VERSION
+'.tar.gz')