pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/url2pkg



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Jul 16 08:59:39 UTC 2022

Modified Files:
        pkgsrc/pkgtools/url2pkg: Makefile PLIST
        pkgsrc/pkgtools/url2pkg/files: url2pkg.py url2pkg_test.py
Added Files:
        pkgsrc/pkgtools/url2pkg/files/python: url2pkg.py
        pkgsrc/pkgtools/url2pkg/files/python/distutils: __init__.py core.py
            extension.py version.py
        pkgsrc/pkgtools/url2pkg/files/python/setuptools: __init__.py dist.py
        pkgsrc/pkgtools/url2pkg/files/python/setuptools/command: __init__.py
            build_ext.py install.py sdist.py
Removed Files:
        pkgsrc/pkgtools/url2pkg/files: setuptools.py

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 pkgsrc/pkgtools/url2pkg/Makefile
cvs rdiff -u -r1.9 -r1.10 pkgsrc/pkgtools/url2pkg/PLIST
cvs rdiff -u -r1.7 -r0 pkgsrc/pkgtools/url2pkg/files/setuptools.py
cvs rdiff -u -r1.42 -r1.43 pkgsrc/pkgtools/url2pkg/files/url2pkg.py
cvs rdiff -u -r1.40 -r1.41 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py
cvs rdiff -u -r0 -r1.1 pkgsrc/pkgtools/url2pkg/files/python/url2pkg.py
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/pkgtools/url2pkg/files/python/distutils/__init__.py \
    pkgsrc/pkgtools/url2pkg/files/python/distutils/core.py \
    pkgsrc/pkgtools/url2pkg/files/python/distutils/extension.py \
    pkgsrc/pkgtools/url2pkg/files/python/distutils/version.py
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/pkgtools/url2pkg/files/python/setuptools/__init__.py \
    pkgsrc/pkgtools/url2pkg/files/python/setuptools/dist.py
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/__init__.py \
    pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py \
    pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/install.py \
    pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/sdist.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/url2pkg/Makefile
diff -u pkgsrc/pkgtools/url2pkg/Makefile:1.126 pkgsrc/pkgtools/url2pkg/Makefile:1.127
--- pkgsrc/pkgtools/url2pkg/Makefile:1.126      Thu Jun 30 11:18:45 2022
+++ pkgsrc/pkgtools/url2pkg/Makefile    Sat Jul 16 08:59:38 2022
@@ -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 @@ WRKSRC=             ${WRKDIR}
 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 @@ do-install:
        ${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"

Index: pkgsrc/pkgtools/url2pkg/PLIST
diff -u pkgsrc/pkgtools/url2pkg/PLIST:1.9 pkgsrc/pkgtools/url2pkg/PLIST:1.10
--- pkgsrc/pkgtools/url2pkg/PLIST:1.9   Sun Oct 27 19:19:54 2019
+++ pkgsrc/pkgtools/url2pkg/PLIST       Sat Jul 16 08:59:38 2022
@@ -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

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.42 pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.43
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.42       Tue Feb  8 20:48:09 2022
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.py    Sat Jul 16 08:59:38 2022
@@ -1,5 +1,5 @@
 #! @PYTHONBIN@
-# $NetBSD: url2pkg.py,v 1.42 2022/02/08 20:48:09 rillig Exp $
+# $NetBSD: url2pkg.py,v 1.43 2022/07/16 08:59:38 rillig Exp $
 
 # Copyright (c) 2019 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1021,7 +1021,7 @@ class Adjuster:
         cmd = f'{self.g.pythonbin} setup.py build'
         env = {
             'PYTHONDONTWRITEBYTECODE': 'x',
-            'PYTHONPATH': self.g.libdir
+            'PYTHONPATH': f'{self.g.libdir}/python'
         }
         self.read_dependencies(cmd, env, self.abs_wrksrc, 'py-', '${PYPKGPREFIX}-')
 

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.40 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.41
--- pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.40  Sun Feb  6 21:07:44 2022
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py       Sat Jul 16 08:59:38 2022
@@ -1,4 +1,13 @@
-# $NetBSD: url2pkg_test.py,v 1.40 2022/02/06 21:07:44 rillig Exp $
+# $NetBSD: url2pkg_test.py,v 1.41 2022/07/16 08:59:38 rillig Exp $
+
+# URLs for manual testing:
+#
+# https://files.pythonhosted.org/packages/source/p/pysha3/pysha3-1.0.2.tar.gz
+#   Prefers distutils over setuptools, has no external dependencies.
+#
+# https://github.com/pytorch/pytorch/archive/refs/tags/v1.12.0.tar.gz
+#   Uses setuptools with an extension.
+#   Runs Git from 'setup.py', which is rather unusual.
 
 import pytest
 from url2pkg import *

Added files:

Index: pkgsrc/pkgtools/url2pkg/files/python/url2pkg.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/url2pkg.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/url2pkg.py     Sat Jul 16 08:59:38 2022
@@ -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.*

Index: pkgsrc/pkgtools/url2pkg/files/python/distutils/__init__.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/distutils/__init__.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/distutils/__init__.py  Sat Jul 16 08:59:39 2022
@@ -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.
Index: pkgsrc/pkgtools/url2pkg/files/python/distutils/core.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/distutils/core.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/distutils/core.py      Sat Jul 16 08:59:39 2022
@@ -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
Index: pkgsrc/pkgtools/url2pkg/files/python/distutils/extension.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/distutils/extension.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/distutils/extension.py Sat Jul 16 08:59:39 2022
@@ -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
Index: pkgsrc/pkgtools/url2pkg/files/python/distutils/version.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/distutils/version.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/distutils/version.py   Sat Jul 16 08:59:39 2022
@@ -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

Index: pkgsrc/pkgtools/url2pkg/files/python/setuptools/__init__.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/setuptools/__init__.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/setuptools/__init__.py Sat Jul 16 08:59:39 2022
@@ -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
Index: pkgsrc/pkgtools/url2pkg/files/python/setuptools/dist.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/setuptools/dist.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/setuptools/dist.py     Sat Jul 16 08:59:39 2022
@@ -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

Index: pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/__init__.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/__init__.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/__init__.py Sat Jul 16 08:59:39 2022
@@ -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.
Index: pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/build_ext.py        Sat Jul 16 08:59:39 2022
@@ -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
Index: pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/install.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/install.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/install.py  Sat Jul 16 08:59:39 2022
@@ -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
Index: pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/sdist.py
diff -u /dev/null pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/sdist.py:1.1
--- /dev/null   Sat Jul 16 08:59:39 2022
+++ pkgsrc/pkgtools/url2pkg/files/python/setuptools/command/sdist.py    Sat Jul 16 08:59:39 2022
@@ -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



Home | Main Index | Thread Index | Old Index