diff options
author | jaseg <git@jaseg.de> | 2022-06-12 14:42:50 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-06-12 14:42:50 +0200 |
commit | dddced97aa4e2af9a1ea7b267b9ce9a3f844eff2 (patch) | |
tree | fcbd4f50d3e8b71038c4d64a811282bad04f11d8 /setup.py | |
parent | 4d9381b84adb6ed917b51ca3e369d25626b1b5fe (diff) | |
download | gerbolyze-dddced97aa4e2af9a1ea7b267b9ce9a3f844eff2.tar.gz gerbolyze-dddced97aa4e2af9a1ea7b267b9ce9a3f844eff2.tar.bz2 gerbolyze-dddced97aa4e2af9a1ea7b267b9ce9a3f844eff2.zip |
pkg: Format README for PyPI, make wasi defaultv3.0.1
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -7,19 +7,27 @@ from setuptools.command.install import install import subprocess from multiprocessing import cpu_count from pathlib import Path +import re -def version(): +def get_tag(): res = subprocess.run(['git', 'describe', '--tags', '--match', 'v*'], capture_output=True, check=True, text=True) - version, _, _rest = res.stdout.strip()[1:].partition('-') + return res.stdout.strip() + +def get_version(): + version, _, _rest = get_tag()[1:].partition('-') return version -def readme(): - with open('README.rst') as f: - return f.read() +def format_readme_for_pypi(): + tag = get_tag() + # Replace repo-relative image URLs with gitlab raw URLs. Gitlab and github render repo-relative URLs just fine, but + # PyPI doesn't. + return '\n'.join( + re.sub('^.. (figure|image):: (pics/.*)$', f'.. \\1:: https://gitlab.com/gerbolyze/gerbolyze/-/raw/{tag}/\\2', line.strip('\n')) + for line in Path('README.rst').read_text().splitlines()) setup( name = 'gerbolyze', - version = version(), + version = get_version(), py_modules = ['gerbolyze'], package_dir = {'': 'gerbolyze'}, entry_points = ''' @@ -31,7 +39,7 @@ setup( 'self-intersections and holes, etc. fully automatically. It can vectorize raster images both by contour ' 'tracing and by grayscale dithering. All processing is done at the vector level without intermediate ' 'conversions to raster images accurately preserving the input.'), - long_description=readme(), + long_description=format_readme_for_pypi(), long_description_content_type='text/x-rst', project_urls={ "Source Code": "https://git.jaseg.de/gerbolyze", @@ -39,10 +47,7 @@ setup( }, author = 'jaseg', author_email = 'gerbonara@jaseg.de', - install_requires = ['gerbonara', 'numpy', 'python-slugify', 'lxml', 'click'], - extras_require = { - 'wasi': [f'svg-flatten-wasi[resvg-wasi] >= {version()}'], - }, + install_requires = ['gerbonara', 'numpy', 'python-slugify', 'lxml', 'click', 'resvg-wasi', 'svg-flatten-wasi[resvg-wasi]'], license = 'AGPLv3', classifiers = [ 'Development Status :: 5 - Production/Stable', |