pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/url2pkg/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Thu Jan 23 06:05:44 UTC 2025

Modified Files:
        pkgsrc/pkgtools/url2pkg/files: url2pkg.py url2pkg_test.py

Log Message:
url2pkg: add very basic support for Python packages using pyproject.toml

Suggested by Greg Troxel via private mail.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 pkgsrc/pkgtools/url2pkg/files/url2pkg.py
cvs rdiff -u -r1.57 -r1.58 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.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/files/url2pkg.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.63 pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.64
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.63       Thu Jan 23 05:53:08 2025
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.py    Thu Jan 23 06:05:44 2025
@@ -1,5 +1,5 @@
 #! @PYTHONBIN@
-# $NetBSD: url2pkg.py,v 1.63 2025/01/23 05:53:08 rillig Exp $
+# $NetBSD: url2pkg.py,v 1.64 2025/01/23 06:05:44 rillig Exp $
 
 # Copyright (c) 2019 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1069,16 +1069,18 @@ class Adjuster:
         #     BSD license)
         # devel/py-gcovr (uses setuptools; BSD license)
 
-        if not self.wrksrc_isfile('setup.py'):
+        if self.wrksrc_isfile('setup.py'):
+            cmd = f'{self.g.pythonbin} setup.py build'
+            env = {
+                'PYTHONDONTWRITEBYTECODE': 'x',
+                'PYTHONPATH': f'{self.g.libdir}/python'
+            }
+            self.read_dependencies(cmd, env, self.abs_wrksrc, python=True)
+        elif self.wrksrc_isfile('pyproject.toml'):
+            self.todos.append("Extract dependencies from pyproject.toml")
+        else:
             return
 
-        cmd = f'{self.g.pythonbin} setup.py build'
-        env = {
-            'PYTHONDONTWRITEBYTECODE': 'x',
-            'PYTHONPATH': f'{self.g.libdir}/python'
-        }
-        self.read_dependencies(cmd, env, self.abs_wrksrc, python=True)
-
         self.pkgname_prefix = '${PYPKGPREFIX}-'
         self.categories.append('python')
         self.includes.append('../../lang/python/wheel.mk')

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.57 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.58
--- pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.57  Thu Jan 23 05:56:23 2025
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py       Thu Jan 23 06:05:44 2025
@@ -1,4 +1,4 @@
-# $NetBSD: url2pkg_test.py,v 1.57 2025/01/23 05:56:23 rillig Exp $
+# $NetBSD: url2pkg_test.py,v 1.58 2025/01/23 06:05:44 rillig Exp $
 
 # URLs for manual testing:
 #
@@ -1333,6 +1333,37 @@ def test_Adjuster_adjust_python_module(t
     ]
 
 
+def test_Adjuster_adjust_python_module__pyproject_toml(tmp_path: Path):
+    url = 'https://example.org/Mod-1.0.tar.gz'
+    g.pythonbin = 'echo python'
+    g.pkgdir = tmp_path
+    adjuster = Adjuster(g, url, Lines())
+    adjuster.abs_wrksrc = tmp_path
+    adjuster.makefile_lines = Generator(url).generate_Makefile()
+    (tmp_path / 'pyproject.toml').touch()
+
+    adjuster.adjust_python_module()
+
+    assert detab(adjuster.generate_lines()) == [
+        mkcvsid,
+        '',
+        'DISTNAME=       Mod-1.0',
+        'PKGNAME=        ${PYPKGPREFIX}-${DISTNAME}',
+        'CATEGORIES=     pkgtools python',
+        'MASTER_SITES=   https://example.org/',
+        '',
+        'MAINTAINER=     INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users%NetBSD.org@localhost',
+        'HOMEPAGE=       https://example.org/',
+        'COMMENT=        TODO: Short description of the package',
+        '#LICENSE=       # TODO: (see mk/license.mk)',
+        '',
+        '# TODO: Extract dependencies from pyproject.toml',
+        '',
+        '.include "../../lang/python/wheel.mk"',
+        '.include "../../mk/bsd.pkg.mk"',
+    ]
+
+
 def test_Adjuster_adjust_po__not_found():
     adjuster = Adjuster(g, '', Lines())
 



Home | Main Index | Thread Index | Old Index