pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg url2pkg: split support files for Pyth...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/28caf9ed014d
branches:  trunk
changeset: 381953:28caf9ed014d
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 16 08:59:38 2022 +0000

description:
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:

 pkgtools/url2pkg/Makefile                                     |  18 +--
 pkgtools/url2pkg/PLIST                                        |  17 ++-
 pkgtools/url2pkg/files/python/distutils/__init__.py           |   9 +
 pkgtools/url2pkg/files/python/distutils/core.py               |  18 +++
 pkgtools/url2pkg/files/python/distutils/extension.py          |  10 +
 pkgtools/url2pkg/files/python/distutils/version.py            |   9 +
 pkgtools/url2pkg/files/python/setuptools/__init__.py          |  33 ++++++
 pkgtools/url2pkg/files/python/setuptools/command/__init__.py  |   7 +
 pkgtools/url2pkg/files/python/setuptools/command/build_ext.py |   7 +
 pkgtools/url2pkg/files/python/setuptools/command/install.py   |   7 +
 pkgtools/url2pkg/files/python/setuptools/command/sdist.py     |   7 +
 pkgtools/url2pkg/files/python/setuptools/dist.py              |   7 +
 pkgtools/url2pkg/files/python/url2pkg.py                      |  40 +++++++
 pkgtools/url2pkg/files/setuptools.py                          |  57 -----------
 pkgtools/url2pkg/files/url2pkg.py                             |   4 +-
 pkgtools/url2pkg/files/url2pkg_test.py                        |  11 +-
 16 files changed, 185 insertions(+), 76 deletions(-)

diffs (truncated from 371 to 300 lines):

diff -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/Makefile
--- a/pkgtools/url2pkg/Makefile Sat Jul 16 08:24:43 2022 +0000
+++ b/pkgtools/url2pkg/Makefile Sat Jul 16 08:59:38 2022 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.126 2022/06/30 11:18:45 nia Exp $
+# $NetBSD: Makefile,v 1.127 2022/07/16 08:59:38 rillig Exp $
 
-PKGNAME=       url2pkg-21.4.2
-PKGREVISION=   2
+PKGNAME=       url2pkg-22.2.0
 CATEGORIES=    pkgtools
 
 MAINTAINER=    rillig%NetBSD.org@localhost
@@ -13,20 +12,18 @@
 NO_CHECKSUM=   yes
 NO_BUILD=      yes
 USE_LANGUAGES= # none
-USE_TOOLS+=    perl:run
+USE_TOOLS+=    perl:run pax
 AUTO_MKDIRS=   yes
 
 PYTHON_VERSIONED_DEPENDENCIES= test:test
 
 do-extract:
-       ${RUN} cd ${FILESDIR} && cp *.* ${WRKSRC}/
+       ${RUN} cd ${FILESDIR} && pax -rw *.* python/*.py python/*/*.py python/*/*/*.py ${WRKSRC}/
 
 do-test:
        ${RUN} cd ${WRKSRC} && env PKGSRCDIR=${PKGSRCDIR} MAKE=${MAKE:Q} \
                ${PREFIX}/bin/pytest-${PYVERSSUFFIX} ${PY_TEST_FLAGS:U}
 
-.include "../../mk/bsd.prefs.mk"
-
 SUBST_CLASSES+=                up
 SUBST_STAGE.up=                do-configure
 SUBST_MESSAGE.up=      Replacing variable placeholders
@@ -39,10 +36,9 @@
        ${INSTALL_MAN} ${FILESDIR}/url2pkg.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8
        ${INSTALL_DATA} ${WRKSRC}/Build.pm ${DESTDIR}${PREFIX}/lib/url2pkg/Module/
        ${INSTALL_DATA} ${WRKSRC}/MakeMaker.pm ${DESTDIR}${PREFIX}/lib/url2pkg/ExtUtils/
-       ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/
-       ${INSTALL_DATA} /dev/null ${DESTDIR}${PREFIX}/lib/url2pkg/distutils/__init__.py
-       ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/distutils/core.py
-       ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/distutils/extension.py
+       ${RUN} cd ${WRKSRC}; for f in $$(find python -name '*.py' -print); do \
+               ${INSTALL_DATA} "$$f" ${DESTDIR}${PREFIX}/lib/url2pkg/"$$f"; \
+       done
 
 .include "../../lang/python/application.mk"
 .include "../../lang/python/versioned_dependencies.mk"
diff -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/PLIST
--- a/pkgtools/url2pkg/PLIST    Sat Jul 16 08:24:43 2022 +0000
+++ b/pkgtools/url2pkg/PLIST    Sat Jul 16 08:59:38 2022 +0000
@@ -1,9 +1,16 @@
-@comment $NetBSD: PLIST,v 1.9 2019/10/27 19:19:54 rillig Exp $
+@comment $NetBSD: PLIST,v 1.10 2022/07/16 08:59:38 rillig Exp $
 bin/url2pkg
 lib/url2pkg/ExtUtils/MakeMaker.pm
 lib/url2pkg/Module/Build.pm
-lib/url2pkg/distutils/__init__.py
-lib/url2pkg/distutils/core.py
-lib/url2pkg/distutils/extension.py
-lib/url2pkg/setuptools.py
+lib/url2pkg/python/distutils/__init__.py
+lib/url2pkg/python/distutils/core.py
+lib/url2pkg/python/distutils/extension.py
+lib/url2pkg/python/distutils/version.py
+lib/url2pkg/python/setuptools/__init__.py
+lib/url2pkg/python/setuptools/command/__init__.py
+lib/url2pkg/python/setuptools/command/build_ext.py
+lib/url2pkg/python/setuptools/command/install.py
+lib/url2pkg/python/setuptools/command/sdist.py
+lib/url2pkg/python/setuptools/dist.py
+lib/url2pkg/python/url2pkg.py
 man/man8/url2pkg.8
diff -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/distutils/__init__.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/distutils/__init__.py       Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/distutils/core.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/distutils/core.py   Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/distutils/extension.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/distutils/extension.py      Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/distutils/version.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/distutils/version.py        Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/setuptools/__init__.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/setuptools/__init__.py      Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/setuptools/command/__init__.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/setuptools/command/__init__.py      Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/setuptools/command/build_ext.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py     Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/setuptools/command/install.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/setuptools/command/install.py       Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/setuptools/command/sdist.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/setuptools/command/sdist.py Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/setuptools/dist.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/setuptools/dist.py  Sat Jul 16 08:59:38 2022 +0000
@@ -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 -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/python/url2pkg.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/python/url2pkg.py  Sat Jul 16 08:59:38 2022 +0000
@@ -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.*
diff -r 47dbd86880b8 -r 28caf9ed014d pkgtools/url2pkg/files/setuptools.py
--- a/pkgtools/url2pkg/files/setuptools.py      Sat Jul 16 08:24:43 2022 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-# $NetBSD: setuptools.py,v 1.7 2019/10/27 19:19:55 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.
-
-
-def url2pkg_print_depends(varname, depends):
-    for dep in depends:
-        print('%s\t%s%s' % (varname, dep.replace(' ', ''), '' if '>' in dep else '>=0'))
-
-
-def url2pkg_print_var(varname, value):
-    if value != '':
-        print('var\t%s\t%s' % (varname, value))
-
-
-def url2pkg_print_cmd(cmd, arg):
-    print('\t'.join(('cmd', cmd, arg)))
-
-
-def url2pkg_print_license(license_name):
-    if license_name == '':



Home | Main Index | Thread Index | Old Index