aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsetup.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/setup.py b/setup.py
index be92a3f..c5d1b48 100755
--- a/setup.py
+++ b/setup.py
@@ -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',