summaryrefslogtreecommitdiff
path: root/pkgtools/url2pkg/files/python
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
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')
-rw-r--r--pkgtools/url2pkg/files/python/distutils/__init__.py9
-rw-r--r--pkgtools/url2pkg/files/python/distutils/core.py18
-rw-r--r--pkgtools/url2pkg/files/python/distutils/extension.py10
-rw-r--r--pkgtools/url2pkg/files/python/distutils/version.py9
-rw-r--r--pkgtools/url2pkg/files/python/setuptools/__init__.py33
-rw-r--r--pkgtools/url2pkg/files/python/setuptools/command/__init__.py7
-rw-r--r--pkgtools/url2pkg/files/python/setuptools/command/build_ext.py7
-rw-r--r--pkgtools/url2pkg/files/python/setuptools/command/install.py7
-rw-r--r--pkgtools/url2pkg/files/python/setuptools/command/sdist.py7
-rw-r--r--pkgtools/url2pkg/files/python/setuptools/dist.py7
-rw-r--r--pkgtools/url2pkg/files/python/url2pkg.py40
11 files changed, 154 insertions, 0 deletions
diff --git a/pkgtools/url2pkg/files/python/distutils/__init__.py b/pkgtools/url2pkg/files/python/distutils/__init__.py
new file mode 100644
index 00000000000..0a3f1933fdf
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/distutils/__init__.py
@@ -0,0 +1,9 @@
+# $NetBSD: __init__.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# This is a drop-in replacement for the distutils Python module. Instead
+# of actually searching for the dependencies, it extracts the dependency
+# information and includes it in the generated pkgsrc package Makefile.
+#
+# https://docs.python.org/3/distutils/
+# As of Python 3.10, distutils is deprecated.
+# The successor is setuptools.
diff --git a/pkgtools/url2pkg/files/python/distutils/core.py b/pkgtools/url2pkg/files/python/distutils/core.py
new file mode 100644
index 00000000000..e14b1138b28
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/distutils/core.py
@@ -0,0 +1,18 @@
+# $NetBSD: core.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation of distutils.core.
+#
+# https://docs.python.org/3/distutils/apiref.html#module-distutils.core
+
+import url2pkg
+
+
+# used by pkgsrc package devel/py-pysha3 1.0.2
+def setup(**kwargs):
+ url2pkg.setup(**kwargs)
+
+
+# Originally from distutils.cmd.
+# used by pkgsrc package devel/py-pysha3 1.0.2
+class Command:
+ pass
diff --git a/pkgtools/url2pkg/files/python/distutils/extension.py b/pkgtools/url2pkg/files/python/distutils/extension.py
new file mode 100644
index 00000000000..14418e2bfca
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/distutils/extension.py
@@ -0,0 +1,10 @@
+# $NetBSD: extension.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation of distutils.extension
+#
+# https://docs.python.org/3/distutils/apiref.html#module-distutils.extension
+
+# used by pkgsrc package devel/py-pysha3 1.0.2
+class Extension:
+ def __init__(self, *args, **kwargs):
+ pass
diff --git a/pkgtools/url2pkg/files/python/distutils/version.py b/pkgtools/url2pkg/files/python/distutils/version.py
new file mode 100644
index 00000000000..0ffe35a2fd6
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/distutils/version.py
@@ -0,0 +1,9 @@
+# $NetBSD: version.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation of distutils.version.
+#
+# https://docs.python.org/3/distutils/apiref.html#module-distutils.version
+
+# used by pkgsrc package wip/py-torch 1.12.0
+class LooseVersion:
+ pass
diff --git a/pkgtools/url2pkg/files/python/setuptools/__init__.py b/pkgtools/url2pkg/files/python/setuptools/__init__.py
new file mode 100644
index 00000000000..f4b713bffc8
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/setuptools/__init__.py
@@ -0,0 +1,33 @@
+# $NetBSD: __init__.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# This is a drop-in replacement for the setuptools Python module. Instead
+# of actually searching for the dependencies, it extracts the dependency
+# information and includes it in the generated pkgsrc package Makefile.
+#
+# https://setuptools.pypa.io/en/latest/index.html
+# https://setuptools.pypa.io/en/latest/setuptools.html
+# https://setuptools.pypa.io/en/latest/userguide/index.html
+# https://github.com/pypa/setuptools/tree/main/setuptools
+
+import url2pkg
+# used by pkgsrc package wip/py-torch 1.12.0
+import distutils # only re-export
+from setuptools.dist import Distribution
+
+
+# used by pkgsrc package devel/py-pysha3 1.0.2
+# used by pkgsrc package wip/py-torch 1.12.0
+def setup(**kwargs):
+ url2pkg.setup(**kwargs)
+
+
+# used by pkgsrc package wip/py-torch 1.12.0
+def find_packages(where='.', exclude=(), include=('*',)):
+ return []
+
+
+# used by pkgsrc package devel/py-pysha3 1.0.2
+# used by pkgsrc package wip/py-torch 1.12.0
+class Extension:
+ def __init__(self, name, sources, *args, **kw) -> None:
+ pass
diff --git a/pkgtools/url2pkg/files/python/setuptools/command/__init__.py b/pkgtools/url2pkg/files/python/setuptools/command/__init__.py
new file mode 100644
index 00000000000..1696368c3f9
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/setuptools/command/__init__.py
@@ -0,0 +1,7 @@
+# $NetBSD: __init__.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation of setuptools.command.
+#
+# https://github.com/pypa/setuptools/blob/main/setuptools/command/__init__.py
+
+# This module is empty, it's just a container for submodules.
diff --git a/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py b/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py
new file mode 100644
index 00000000000..d48c6f859f3
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py
@@ -0,0 +1,7 @@
+# $NetBSD: build_ext.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation of setuptools.command.build_ext.
+#
+# https://github.com/pypa/setuptools/blob/main/setuptools/command/build_ext.py
+
+# used by pkgsrc package wip/pytorch 1.12.0
diff --git a/pkgtools/url2pkg/files/python/setuptools/command/install.py b/pkgtools/url2pkg/files/python/setuptools/command/install.py
new file mode 100644
index 00000000000..a4a7f18dd12
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/setuptools/command/install.py
@@ -0,0 +1,7 @@
+# $NetBSD: install.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation of setuptools.command.install.
+#
+# https://github.com/pypa/setuptools/blob/main/setuptools/command/install.py
+
+# used by pkgsrc package wip/pytorch 1.12.0
diff --git a/pkgtools/url2pkg/files/python/setuptools/command/sdist.py b/pkgtools/url2pkg/files/python/setuptools/command/sdist.py
new file mode 100644
index 00000000000..eeda10630e1
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/setuptools/command/sdist.py
@@ -0,0 +1,7 @@
+# $NetBSD: sdist.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation of setuptools.command.sdist.
+#
+# https://github.com/pypa/setuptools/blob/main/setuptools/command/sdist.py
+
+# used by pkgsrc package wip/pytorch 1.12.0
diff --git a/pkgtools/url2pkg/files/python/setuptools/dist.py b/pkgtools/url2pkg/files/python/setuptools/dist.py
new file mode 100644
index 00000000000..ffcfed9fb13
--- /dev/null
+++ b/pkgtools/url2pkg/files/python/setuptools/dist.py
@@ -0,0 +1,7 @@
+# $NetBSD: dist.py,v 1.1 2022/07/16 08:59:39 rillig Exp $
+#
+# Fake implementation for setuptools.dist.
+
+# used by pkgsrc package wip/py-torch 1.12.0
+class Distribution:
+ pass
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.*