git: 42f2aee7df51 - main - devel/py-stsci.distutils: Fix build with setuptools 58.0.0+

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Fri, 25 Mar 2022 13:50:13 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=42f2aee7df51c8251c8660200916e0bd1ff3d240

commit 42f2aee7df51c8251c8660200916e0bd1ff3d240
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-03-25 13:32:24 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-03-25 13:38:12 +0000

    devel/py-stsci.distutils: Fix build with setuptools 58.0.0+
    
    With hat:       python
---
 devel/py-stsci.distutils/files/patch-2to3 | 144 ++++++++++++++++++++++++++++++
 1 file changed, 144 insertions(+)

diff --git a/devel/py-stsci.distutils/files/patch-2to3 b/devel/py-stsci.distutils/files/patch-2to3
new file mode 100644
index 000000000000..6f8f0536a9cd
--- /dev/null
+++ b/devel/py-stsci.distutils/files/patch-2to3
@@ -0,0 +1,144 @@
+--- stsci/distutils/command/build_optional_ext.py.orig	2013-12-23 23:22:38 UTC
++++ stsci/distutils/command/build_optional_ext.py
+@@ -3,7 +3,7 @@ from distutils.command.build_ext import build_ext
+ from distutils.errors import DistutilsError, CCompilerError, CompileError
+ from distutils.util import strtobool
+ 
+-from ConfigParser import ConfigParser
++from configparser import ConfigParser
+ 
+ 
+ class build_optional_ext(build_ext):
+@@ -33,7 +33,7 @@ class build_optional_ext(build_ext):
+         cfg = ConfigParser()
+         try:
+             cfg.read('setup.cfg')
+-        except Exception, e:
++        except Exception as e:
+             log.warn('Failed to read setup.cfg: %s; proceeding as though '
+                      'there are no optional extensions' % e)
+             return
+@@ -75,7 +75,7 @@ class build_optional_ext(build_ext):
+     def build_extension(self, ext):
+         try:
+             build_ext.build_extension(self, ext)
+-        except (CCompilerError, DistutilsError, CompileError), e:
++        except (CCompilerError, DistutilsError, CompileError) as e:
+             if not hasattr(ext, '_optional') or not ext._optional:
+                 raise
+             log.warn('building optional extension "%s" failed: %s' %
+--- stsci/distutils/release.py.orig	2013-12-23 23:22:38 UTC
++++ stsci/distutils/release.py
+@@ -6,7 +6,7 @@ import os
+ import shutil
+ import sys
+ 
+-from ConfigParser import ConfigParser
++from configparser import ConfigParser
+ 
+ from setuptools.dist import Distribution
+ from zest.releaser.utils import ask
+@@ -105,7 +105,7 @@ def add_to_stsci_package_index(data):
+     answer = ''
+     while not answer:
+         try:
+-            answer = raw_input(question).strip()
++            answer = input(question).strip()
+             if not answer:
+                 if package_path:
+                     # The user simple pressed enter, so use the supplied
+@@ -114,13 +114,13 @@ def add_to_stsci_package_index(data):
+                 else:
+                     continue
+             if not os.path.exists(answer):
+-                print ('The supplied path %s does not exist.  Please enter a '
+-                       'different path or press Ctrl-C to cancel.' % answer)
++                print(('The supplied path %s does not exist.  Please enter a '
++                       'different path or press Ctrl-C to cancel.' % answer))
+             if not os.access(answer, os.W_OK):
+-                print ('The supplied path %s is not writeable.  Either change '
++                print(('The supplied path %s is not writeable.  Either change '
+                        'the permissions of the directory or have someone '
+                        'grant you access and try again, enter a different '
+-                       'directory, or press Ctrl-C to cancel.' % answer)
++                       'directory, or press Ctrl-C to cancel.' % answer))
+             package_path = answer
+             break
+             # The default was not supplied, so keep asking
+@@ -141,15 +141,15 @@ def add_to_stsci_package_index(data):
+                                                     '*.zip'))[0]
+             except IndexError:
+                 try:
+-                    print (
++                    print((
+                         "Could not find a source distribution in %s; did you "
+                         "do a source checkout for upload?  If possible, try "
+                         "to cd to %s and manually create a source "
+                         "distribution by running `python setup.py sdist`.  "
+                         "Then press enter to try again (or hit Ctrl-C to "
+                         "cancel).  Go ahead, I'll wait..." %
+-                        (data['tagdir'], data['tagdir']))
+-                    raw_input()
++                        (data['tagdir'], data['tagdir'])))
++                    input()
+                 except KeyboardInterrupt:
+                     return
+ 
+@@ -166,12 +166,12 @@ def add_to_stsci_package_index(data):
+             dist.fetch_build_eggs(['basketweaver'])
+         except:
+             # There are so many things that could possibly go wrong here...
+-            print ('Failed to get basketweaver, which is required to rebuild '
++            print(('Failed to get basketweaver, which is required to rebuild '
+                    'the package index.  To manually complete the release, '
+                    'install basketweaver manually, then copy %s into %s, cd '
+                    'to %s, and then run `makeindex *`, where makeindex is the '
+                    'command installed by basketweaver.' %
+-                   (sdist_file, package_path, package_path))
++                   (sdist_file, package_path, package_path)))
+         import basketweaver.makeindex
+ 
+     # Now we should have everything we need...
+@@ -183,4 +183,4 @@ def add_to_stsci_package_index(data):
+     finally:
+         os.chdir(old_cwd)
+ 
+-    print 'Finished adding package to %s.' % PACKAGE_INDEX_URL
++    print('Finished adding package to %s.' % PACKAGE_INDEX_URL)
+--- stsci/distutils/tests/__init__.py.orig	2013-12-23 23:22:38 UTC
++++ stsci/distutils/tests/__init__.py
+@@ -7,6 +7,7 @@ import tempfile
+ import nose
+ 
+ from .util import reload, rmtree
++import importlib
+ 
+ 
+ TESTPACKAGE_URL = ('https://svn.stsci.edu/svn/ssb/stsci_python/'
+@@ -24,7 +25,7 @@ class StsciDistutilsTestCase(object):
+                                   'checkout', TESTPACKAGE_URL, cls.wc_dir],
+                                   stdout=subprocess.PIPE,
+                                   stderr=subprocess.PIPE)
+-        except OSError, e:
++        except OSError as e:
+             raise nose.SkipTest('svn unavailable to checkout out test '
+                                 'package: %s' % e)
+ 
+@@ -48,7 +49,7 @@ class StsciDistutilsTestCase(object):
+         # package's __path__ since it's already been imported.
+         if 'stsci' in sys.modules:
+             # Clean the existing __path__ up
+-            reload(sys.modules['stsci'])
++            importlib.reload(sys.modules['stsci'])
+             sys.modules['stsci'].__path__.insert(
+                 0, os.path.join(self.package_dir, 'stsci'))
+ 
+--- stsci/distutils/tests/testpackage/setup.py.orig	2013-12-23 23:22:38 UTC
++++ stsci/distutils/tests/testpackage/setup.py
+@@ -12,6 +12,5 @@ setup(
+     namespace_packages=['stsci'], packages=['stsci'],
+     dependency_links=['http://stsdas.stsci.edu/download/packages'],
+     d2to1=True,
+-    use_2to3=True,
+     zip_safe=False,
+ )