summaryrefslogtreecommitdiff
path: root/pkgtools/url2pkg/files/python/url2pkg.py
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2022-07-16 08:59:38 +0000
committerrillig <rillig@pkgsrc.org>2022-07-16 08:59:38 +0000
commite8b2442e1bacce72d9877eb0163eabe17bcdf2b2 (patch)
tree87f7294952bfc3b207bc03f663a1b52e8ec2e1e5 /pkgtools/url2pkg/files/python/url2pkg.py
parent720319d4f773c613c7dd7825032b31102b472935 (diff)
downloadpkgsrc-e8b2442e1bacce72d9877eb0163eabe17bcdf2b2.tar.gz
url2pkg: split support files for Python distutils and setuptools
When url2pkg determines the metadata of a Python module, it had merged the two implementations for Python's distutils and setuptools, which made the code hard to understand. Split them again. Extend the support for setuptools, so that url2pkg correctly handles wip/pytorch; it still fails because pytorch does some Git stuff from inside setup.py, but that may be fixed later. Bump version to 22.2.0.
Diffstat (limited to 'pkgtools/url2pkg/files/python/url2pkg.py')
-rw-r--r--pkgtools/url2pkg/files/python/url2pkg.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkgtools/url2pkg/files/python/url2pkg.py b/pkgtools/url2pkg/files/python/url2pkg.py
new file mode 100644
index 00000000000..3f3ede6e9a2
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/url2pkg.py
@@ -0,0 +1,40 @@
+# $NetBSD: url2pkg.py,v 1.1 2022/07/16 08:59:38 rillig Exp $
+#
+# Forwards the module metadata from distutils and setuptools to url2pkg.
+
+def print_depends(varname, depends):
+ for dep in depends:
+ print('%s\t%s%s' % (varname, dep.replace(' ', ''), '' if '>' in dep else '>=0'))
+
+
+def print_var(varname, value):
+ if value != '':
+ print('var\t%s\t%s' % (varname, value))
+
+
+def print_cmd(cmd, arg):
+ print('\t'.join(('cmd', cmd, arg)))
+
+
+def print_license(license_name):
+ if license_name == '':
+ return
+ print_cmd('license', license_name)
+ print_cmd(
+ 'license_default',
+ '%s # TODO: from setup.py; needs to be adjusted' % license_name)
+
+
+def setup(**kwargs):
+ print_depends('DEPENDS', kwargs.get('requires', [])) # only for distutils.core
+ print_depends('DEPENDS', kwargs.get('install_requires', []))
+ print_depends('TEST_DEPENDS', kwargs.get('tests_require', []))
+ print_depends('BUILD_DEPENDS', kwargs.get('extras_require', {}).get('dev', []))
+ print_depends('BUILD_DEPENDS', kwargs.get('setup_requires', []))
+ print_var('COMMENT', kwargs.get('description', '').rstrip('.'))
+ print_var('HOMEPAGE', kwargs.get('url', ''))
+ print_license(kwargs.get('license', ''))
+
+ # TODO: implement 'python_requires'
+ # example pkgsrc package: devel/py-futures
+ # example values: >=2.6, <3, >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*