[packages/python-Crypto] Rel 20; fix python3 build

arekm arekm at pld-linux.org
Mon Apr 7 23:19:19 CEST 2025


commit 2a78c0f91bb84f214094aabcf8c0b2fae28cd6c9
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Mon Apr 7 23:19:12 2025 +0200

    Rel 20; fix python3 build

 pycrypto-2to3.patch | 100 ----------------------------------------------------
 python-Crypto.spec  |  27 ++++++++++----
 2 files changed, 20 insertions(+), 107 deletions(-)
---
diff --git a/python-Crypto.spec b/python-Crypto.spec
index 9fd17e6..a3581d9 100644
--- a/python-Crypto.spec
+++ b/python-Crypto.spec
@@ -9,7 +9,7 @@ Summary:	PyCrypto - The Python 2 Cryptography Toolkit
 Summary(pl.UTF-8):	Kryptograficzny przybornik dla języka Python 2
 Name:		python-%{module}
 Version:	2.6.1
-Release:	19
+Release:	20
 # Mostly Public Domain apart from parts of HMAC.py and setup.py, which are Python
 License:	Public Domain and Python
 Group:		Development/Languages/Python
@@ -28,9 +28,9 @@ Patch9:		pycrypto-python3.11.patch
 Patch10:	pycrypto-python3.12.patch
 Patch11:	pycrypto-no-distutils.patch
 Patch12:	pycrypto-SyntaxWarning.patch
-Patch13:	pycrypto-2to3.patch
 URL:		http://www.dlitz.net/software/pycrypto/
 BuildRequires:	gmp-devel
+BuildRequires:	libtomcrypt-devel
 %if %{with python2}
 BuildRequires:	python >= 1:2.5
 BuildRequires:	python-devel >= 1:2.5
@@ -38,7 +38,7 @@ BuildRequires:	python-modules >= 1:2.5
 %endif
 %if %{with python3}
 BuildRequires:	python3 >= 1:3.2
-BuildRequires:	python3-2to3 >= 1:3.2
+BuildRequires:	python3-fissix
 BuildRequires:	python3-devel >= 1:3.2
 BuildRequires:	python3-modules >= 1:3.2
 %endif
@@ -107,7 +107,9 @@ zaimplementowanych dla języka Python 3. Pakiet zawiera między innymi:
 - programy demonstracyjne (aktualnie odrobinę stare i nieaktualne)
 
 %prep
-%setup -q -n pycrypto-%{version}
+%setup -q -c
+mv pycrypto-%{version} pycrypto2
+cd pycrypto2
 %patch -P 0 -p1
 %patch -P 1 -p1
 %patch -P 2 -p1
@@ -121,32 +123,43 @@ zaimplementowanych dla języka Python 3. Pakiet zawiera między innymi:
 %patch -P 10 -p1
 %patch -P 11 -p1
 %patch -P 12 -p1
-%patch -P 13 -p1
+cd ..
+
+cp -a pycrypto2 pycrypto3
 
 %build
 %if %{with python2}
+cd pycrypto2
 %py_build %{?with_tests:test}
+cd ..
 %endif
 
 %if %{with python3}
+cd pycrypto3
+%{__python3} -m fissix -w -n --no-diffs .
 %py3_build %{?with_tests:test}
+cd ..
 %endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
 
 %if %{with python2}
+cd pycrypto2
 %py_install
 
 %py_postclean
 
 %{__rm} -r $RPM_BUILD_ROOT%{py_sitedir}/Crypto/SelfTest
+cd ..
 %endif
 
 %if %{with python3}
+cd pycrypto3
 %py3_install
 
 %{__rm} -r $RPM_BUILD_ROOT%{py3_sitedir}/Crypto/SelfTest
+cd ..
 %endif
 
 %clean
@@ -155,7 +168,7 @@ rm -rf $RPM_BUILD_ROOT
 %if %{with python2}
 %files
 %defattr(644,root,root,755)
-%doc ACKS COPYRIGHT ChangeLog README TODO Doc
+%doc pycrypto2/{ACKS,COPYRIGHT,ChangeLog,README,TODO,Doc}
 %dir %{py_sitedir}/%{module}
 %{py_sitedir}/%{module}/*.py[co]
 %dir %{py_sitedir}/%{module}/Cipher
@@ -185,7 +198,7 @@ rm -rf $RPM_BUILD_ROOT
 %if %{with python3}
 %files -n python3-%{module}
 %defattr(644,root,root,755)
-%doc ACKS COPYRIGHT ChangeLog README TODO Doc
+%doc pycrypto2/{ACKS,COPYRIGHT,ChangeLog,README,TODO,Doc}
 %dir %{py3_sitedir}/%{module}
 %{py3_sitedir}/%{module}/*.py
 %{py3_sitedir}/%{module}/__pycache__
diff --git a/pycrypto-2to3.patch b/pycrypto-2to3.patch
deleted file mode 100644
index 2c73f32..0000000
--- a/pycrypto-2to3.patch
+++ /dev/null
@@ -1,100 +0,0 @@
---- pycrypto-2.6.1/setup.py.orig	2023-10-26 21:03:02.214676533 +0200
-+++ pycrypto-2.6.1/setup.py	2023-10-26 21:06:02.467033356 +0200
-@@ -55,6 +55,85 @@ USE_GCOV = 0
- 
- from setuptools.command.build_py import build_py
- 
-+if sys.version_info[0] == 3:
-+    # from python3.10 distutils/util.py
-+    def run_2to3(files, fixer_names=None, options=None, explicit=None):
-+        """Invoke 2to3 on a list of Python files.
-+        The files should all come from the build area, as the
-+        modification is done in-place. To reduce the build time,
-+        only files modified since the last invocation of this
-+        function should be passed in the files argument."""
-+    
-+        if not files:
-+            return
-+    
-+        # Make this class local, to delay import of 2to3
-+        from lib2to3.refactor import RefactoringTool, get_fixers_from_package
-+        from distutils import log
-+        class DistutilsRefactoringTool(RefactoringTool):
-+            def log_error(self, msg, *args, **kw):
-+                log.error(msg, *args)
-+    
-+            def log_message(self, msg, *args):
-+                log.info(msg, *args)
-+    
-+            def log_debug(self, msg, *args):
-+                log.debug(msg, *args)
-+    
-+        if fixer_names is None:
-+            fixer_names = get_fixers_from_package('lib2to3.fixes')
-+        r = DistutilsRefactoringTool(fixer_names, options=options)
-+        r.refactor(files, write=True)
-+    
-+    class Mixin2to3:
-+        '''Mixin class for commands that run 2to3.
-+        To configure 2to3, setup scripts may either change
-+        the class variables, or inherit from individual commands
-+        to override how 2to3 is invoked.'''
-+    
-+        # provide list of fixers to run;
-+        # defaults to all from lib2to3.fixers
-+        fixer_names = None
-+    
-+        # options dictionary
-+        options = None
-+    
-+        # list of fixers to invoke even though they are marked as explicit
-+        explicit = None
-+    
-+        def run_2to3(self, files):
-+            return run_2to3(files, self.fixer_names, self.options, self.explicit)
-+    
-+    # from python3.10 distutils/command/build_py.py
-+    class build_py_2to3(build_py, Mixin2to3):
-+        def run(self):
-+            self.updated_files = []
-+    
-+            # Base class code
-+            if self.py_modules:
-+                self.build_modules()
-+            if self.packages:
-+                self.build_packages()
-+                self.build_package_data()
-+    
-+            # 2to3
-+            self.run_2to3(self.updated_files)
-+    
-+            # Remaining base class code
-+            self.byte_compile(self.get_outputs(include_bytecode=0))
-+    
-+        def build_module(self, module, module_file, package):
-+            res = build_py.build_module(self, module, module_file, package)
-+            if res[1]:
-+                # file was copied
-+                self.updated_files.append(res[0])
-+            return res
-+
-+    build_py_base = build_py_2to3
-+else:
-+    build_py_base = build_py
-+
-+
- # Work around the print / print() issue with Python 2.x and 3.x. We only need
- # to print at one point of the code, which makes this easy
- 
-@@ -225,9 +303,9 @@ class PCTBuildConfigure(Command):
-             if os.system(cmd) != 0:
-                 raise RuntimeError("autoconf error")
- 
--class PCTBuildPy(build_py):
-+class PCTBuildPy(build_py_base):
-     def find_package_modules(self, package, package_dir, *args, **kwargs):
--        modules = build_py.find_package_modules(self, package, package_dir,
-+        modules = build_py_base.find_package_modules(self, package, package_dir,
-             *args, **kwargs)
- 
-         # Exclude certain modules
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-Crypto.git/commitdiff/2a78c0f91bb84f214094aabcf8c0b2fae28cd6c9



More information about the pld-cvs-commit mailing list