Skip to content

Commit ed227a7

Browse files
committed
update
1 parent dee1c88 commit ed227a7

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

setup.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from packaging.version import parse
1+
from pkg_resources import parse_version
22
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')
55

66
# note: all settings are in settings.ini; edit there, not here
77
config = ConfigParser(delimiters=['='])
@@ -13,34 +13,51 @@
1313
for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
1414
setup_cfg = {o:cfg[o] for o in cfg_keys}
1515

16+
if len(sys.argv)>1 and sys.argv[1]=='version':
17+
print(setup_cfg['version'])
18+
exit()
19+
1620
licenses = {
1721
'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'),
1822
}
1923
statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
2024
'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()
2526
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+
# ![png](docs/images/output_13_0.png)
36+
for ext in ['png', 'svg']:
37+
long_description = re.sub(r'!\['+ext+'\]\((.*)\)', '!['+ext+']('+'https://raw.githubusercontent.com/{}/{}'.format(cfg['user'],cfg['lib_name'])+'/'+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)
2639

2740
setuptools.setup(
28-
name = cfg['lib_name'],
41+
name = 'markdown-merge',
2942
license = lic[0],
3043
classifiers = [
3144
'Development Status :: ' + statuses[int(cfg['status'])],
3245
'Intended Audience :: ' + cfg['audience'].title(),
3346
'License :: ' + lic[1],
3447
'Natural Language :: ' + cfg['language'].title(),
3548
] + ['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'],
3750
packages = setuptools.find_packages(),
3851
include_package_data = True,
3952
install_requires = requirements,
53+
extras_require={ 'dev': dev_requirements },
4054
python_requires = '>=' + cfg['min_python'],
41-
long_description = open('README.md').read(),
55+
long_description = long_description,
4256
long_description_content_type = 'text/markdown',
4357
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+
},
4562
**setup_cfg)
4663

0 commit comments

Comments
 (0)