fedora-python / pyp2rpm

Tool to convert a package from PyPI to RPM SPECFILE or to generate SRPM.
MIT License
123 stars 39 forks source link

Modify coverage_pth so that it supports Python 3.10+ #265

Closed gordonmessmer closed 3 years ago

hroncok commented 3 years ago
$ diff -u coverage_pth-0.0.1_original/ coverage_pth-0.0.1
Common subdirectories: coverage_pth-0.0.1_original/coverage_pth.egg-info and coverage_pth-0.0.1/coverage_pth.egg-info
diff -u coverage_pth-0.0.1_original/setup.cfg coverage_pth-0.0.1/setup.cfg
--- coverage_pth-0.0.1_original/setup.cfg   2015-04-15 22:31:58.000000000 +0200
+++ coverage_pth-0.0.1/setup.cfg    2021-03-24 05:52:48.993455200 +0100
@@ -3,5 +3,4 @@
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0

diff -u coverage_pth-0.0.1_original/setup.py coverage_pth-0.0.1/setup.py
--- coverage_pth-0.0.1_original/setup.py    2015-04-15 22:18:24.000000000 +0200
+++ coverage_pth-0.0.1/setup.py 2021-03-24 05:51:35.000000000 +0100
@@ -1,17 +1,27 @@
 from setuptools import setup
 from distutils import sysconfig
+import sys
 import re
 #from setuptools.dist import Distribution

 site_packages_path = sysconfig.get_python_lib()
-sprem = re.match(
-    r'.*(lib[\\/](python\d\.\d[\\/])?site-packages)', site_packages_path, re.I)
-rel_site_packages = sprem.group(1)
+try:
+    sprem = re.match(
+        r'.*(lib[\\/](python\d(\.\d+)*[\\/])?site-packages)', site_packages_path, re.I)
+    if sprem is None:
+        sprem = re.match(
+            r'.*(lib[\\/](python\d(\.\d+)*[\\/])?dist-packages)', site_packages_path, re.I)
+    rel_site_packages = sprem.group(1)
+except Exception as exc:
+    print("I'm having trouble finding your site-packages directory.  Is it where you expect?")
+    print("sysconfig.get_python_lib() returns '{}'".format(site_packages_path))
+    print("Exception was: {}".format(exc))
+    sys.exit(-1)

 #class PureDistribution(Distribution):
 #    def is_pure(self):
 #        return True
-    
+
 setup(
     name = 'coverage_pth',
     version = '0.0.1',
@@ -26,4 +36,4 @@
     ],
     #distclass=PureDistribution,
     zip_safe=False,
-)
\ No newline at end of file
+)
gordonmessmer commented 3 years ago

The change is dougn/coverage_pth#5

I'm afraid I don't follow. The patch you posted looks like a combination of pull/5 and pull/6 (which adds the "\d+" bit), which are already merged in this branch.

hroncok commented 3 years ago

Yes, sorry it is 5 and 6.

The patch I've posted is the diff between the tars.