|
1 | | -from packaging.version import parse |
| 1 | +from pkg_resources import parse_version |
2 | 2 | from configparser import ConfigParser |
3 | | -import setuptools |
4 | | -assert parse(setuptools.__version__)>=parse('36.2') |
| 3 | +import setuptools,re,sys |
| 4 | +assert parse_version(setuptools.__version__)>=parse_version('36.2') |
5 | 5 |
|
6 | 6 | # note: all settings are in settings.ini; edit there, not here |
7 | 7 | config = ConfigParser(delimiters=['=']) |
|
13 | 13 | for o in expected: assert o in cfg, "missing expected setting: {}".format(o) |
14 | 14 | setup_cfg = {o:cfg[o] for o in cfg_keys} |
15 | 15 |
|
| 16 | +if len(sys.argv)>1 and sys.argv[1]=='version': |
| 17 | + print(setup_cfg['version']) |
| 18 | + exit() |
| 19 | + |
16 | 20 | licenses = { |
17 | 21 | 'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'), |
18 | 22 | } |
19 | 23 | statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha', |
20 | 24 | '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ] |
21 | | -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() |
22 | | - |
23 | | -requirements = cfg.get('requirements','').split() |
24 | | -lic = licenses[cfg['license']] |
| 25 | +py_versions = '3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13'.split() |
25 | 26 | min_python = cfg['min_python'] |
| 27 | +lic = licenses[cfg['license']] |
| 28 | + |
| 29 | +requirements = ['packaging'] |
| 30 | +if cfg.get('requirements'): requirements += cfg.get('requirements','').split() |
| 31 | +if cfg.get('pip_requirements'): requirements += cfg.get('pip_requirements','').split() |
| 32 | +dev_requirements = (cfg.get('dev_requirements') or '').split() |
| 33 | + |
| 34 | +long_description = open('README.md', encoding="utf8").read() |
| 35 | +#  |
| 36 | +for ext in ['png', 'svg']: |
| 37 | + long_description = re.sub(r'!\['+ext+'\]\((.*)\)', '+'/'+cfg['branch']+'/\\1)', long_description) |
| 38 | + long_description = re.sub(r'src=\"(.*)\.'+ext+'\"', 'src=\"https://raw.githubusercontent.com/{}/{}'.format(cfg['user'],cfg['lib_name'])+'/'+cfg['branch']+'/\\1.'+ext+'\"', long_description) |
26 | 39 |
|
27 | 40 | setuptools.setup( |
28 | | - name = cfg['lib_name'], |
| 41 | + name = 'markdown-merge', |
29 | 42 | license = lic[0], |
30 | 43 | classifiers = [ |
31 | 44 | 'Development Status :: ' + statuses[int(cfg['status'])], |
32 | 45 | 'Intended Audience :: ' + cfg['audience'].title(), |
33 | 46 | 'License :: ' + lic[1], |
34 | 47 | 'Natural Language :: ' + cfg['language'].title(), |
35 | 48 | ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]], |
36 | | - url = 'https://github.com/{}/{}'.format(cfg['user'],cfg['lib_name']), |
| 49 | + url = cfg['git_url'], |
37 | 50 | packages = setuptools.find_packages(), |
38 | 51 | include_package_data = True, |
39 | 52 | install_requires = requirements, |
| 53 | + extras_require={ 'dev': dev_requirements }, |
40 | 54 | python_requires = '>=' + cfg['min_python'], |
41 | | - long_description = open('README.md').read(), |
| 55 | + long_description = long_description, |
42 | 56 | long_description_content_type = 'text/markdown', |
43 | 57 | zip_safe = False, |
44 | | - entry_points = { 'console_scripts': cfg.get('console_scripts','').split() }, |
| 58 | + entry_points = { |
| 59 | + 'console_scripts': cfg.get('console_scripts','').split(), |
| 60 | + 'nbdev': [f'{cfg.get("lib_path")}={cfg.get("lib_path")}._modidx:d'] |
| 61 | + }, |
45 | 62 | **setup_cfg) |
46 | 63 |
|
0 commit comments