|
1 | | -import setuptools,sys |
2 | 1 | from pkg_resources import parse_version |
3 | 2 | from configparser import ConfigParser |
4 | | -from distutils.cmd import Command |
5 | | - |
| 3 | +import setuptools,re,sys |
6 | 4 | assert parse_version(setuptools.__version__)>=parse_version('36.2') |
7 | 5 |
|
8 | 6 | # note: all settings are in settings.ini; edit there, not here |
|
15 | 13 | for o in expected: assert o in cfg, "missing expected setting: {}".format(o) |
16 | 14 | setup_cfg = {o:cfg[o] for o in cfg_keys} |
17 | 15 |
|
| 16 | +if len(sys.argv)>1 and sys.argv[1]=='version': |
| 17 | + print(setup_cfg['version']) |
| 18 | + exit() |
| 19 | + |
18 | 20 | licenses = { |
19 | 21 | 'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'), |
20 | 22 | } |
21 | 23 | statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha', |
22 | 24 | '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ] |
23 | 25 | py_versions = '2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8'.split() |
| 26 | +min_python = cfg['min_python'] |
| 27 | +lic = licenses[cfg['license']] |
24 | 28 |
|
25 | | -requirements = ['pip', 'packaging', 'wheel'] |
| 29 | +requirements = ['pip', 'packaging'] |
26 | 30 | if cfg.get('requirements'): requirements += cfg.get('requirements','').split() |
27 | 31 | if cfg.get('pip_requirements'): requirements += cfg.get('pip_requirements','').split() |
28 | 32 |
|
29 | | -dev_requirements = cfg.get('dev_requirements','').split() |
30 | | -lic = licenses[cfg['license']] |
31 | | -min_python = cfg['min_python'] |
32 | | - |
33 | | -if len(sys.argv)>1 and sys.argv[1]=='version': |
34 | | - print(setup_cfg['version']) |
35 | | - exit() |
| 33 | +long_description = open('README.md').read() |
| 34 | +#  |
| 35 | +for ext in ['png', 'svg']: |
| 36 | + long_description = re.sub(r'!\['+ext+'\]\((.*)\)', '+'/'+cfg['branch']+'/\\1)', long_description) |
| 37 | + long_description = re.sub(r'src=\"(.*)\.'+ext+'\"', 'src=\"https://raw.githubusercontent.com/{}/{}'.format(cfg['user'],cfg['lib_name'])+'/'+cfg['branch']+'/\\1.'+ext+'\"', long_description) |
36 | 38 |
|
37 | 39 | setuptools.setup( |
38 | 40 | name = cfg['lib_name'], |
|
43 | 45 | 'License :: ' + lic[1], |
44 | 46 | 'Natural Language :: ' + cfg['language'].title(), |
45 | 47 | ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]], |
46 | | - url = 'https://github.com/{}/{}'.format(cfg['user'],cfg['lib_name']), |
| 48 | + url = cfg['git_url'], |
47 | 49 | packages = setuptools.find_packages(), |
48 | 50 | include_package_data = True, |
49 | 51 | install_requires = requirements, |
50 | | - extras_require = { 'dev': dev_requirements }, |
51 | 52 | python_requires = '>=' + cfg['min_python'], |
52 | | - long_description = open('README.md').read(), |
| 53 | + long_description = long_description, |
53 | 54 | long_description_content_type = 'text/markdown', |
54 | 55 | zip_safe = False, |
55 | 56 | entry_points = { 'console_scripts': cfg.get('console_scripts','').split() }, |
|
0 commit comments