summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2023-12-10 21:00:26 +0100
committerFedja Beader <fedja@protonmail.ch>2023-12-10 21:00:26 +0100
commit715982bdf8b7c6bd6fb05221d82a0e1ab905336f (patch)
tree4e7adfdbe497908e2c19a7992816dd26f2edc751
parent4e30c2ce14bb1cfbb0e3f87423db2c6f8d76f911 (diff)
downloadattobuild-715982bdf8b7c6bd6fb05221d82a0e1ab905336f.tar.gz
attobuild-715982bdf8b7c6bd6fb05221d82a0e1ab905336f.tar.bz2
attobuild-715982bdf8b7c6bd6fb05221d82a0e1ab905336f.tar.xz
attobuild-715982bdf8b7c6bd6fb05221d82a0e1ab905336f.zip
Upgrade to Python3.
Mostly using 2to3 automatic converter with some educated guesses on my part. Produces same TMWA Makefile as py2 attoconf. YMMV.
-rw-r--r--attoconf/classy.py7
-rw-r--r--attoconf/core.py11
-rw-r--r--attoconf/help.py2
-rw-r--r--attoconf/lib/arches.py2
-rw-r--r--attoconf/lib/c.py4
-rw-r--r--attoconf/lib/config_hash.py6
-rw-r--r--attoconf/lib/install.py2
-rw-r--r--attoconf/lib/lex.py2
-rw-r--r--attoconf/lib/make.py2
-rw-r--r--attoconf/lib/pkg_config.py2
-rw-r--r--attoconf/lib/templates.py2
-rw-r--r--attoconf/lib/yacc.py2
-rw-r--r--attoconf/tests/test_core.py10
-rw-r--r--attoconf/tests/test_help.py4
-rw-r--r--attoconf/tests/test_types.py4
-rw-r--r--attoconf/tests/test_version.py2
-rw-r--r--attoconf/types.py2
-rw-r--r--attoconf/version.py6
-rwxr-xr-xsetup.py2
19 files changed, 37 insertions, 37 deletions
diff --git a/attoconf/classy.py b/attoconf/classy.py
index 59a62e1..33c9c40 100644
--- a/attoconf/classy.py
+++ b/attoconf/classy.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
from .core import Project, Build
@@ -26,7 +26,7 @@ class PolymorphicSlotMergerMetaclass(type):
s = ()
for b in bases:
s2 = b.__dict__.get('_merge_slots_', ())
- if isinstance(s2, basestring):
+ if isinstance(s2, str):
s2 = (s2,)
s += s2
s += dct.get('_merge_slots_', ())
@@ -48,12 +48,11 @@ class PolymorphicSlotMergerMetaclass(type):
def add_slots(cls):
return cls
-class ClassyProject(Project):
+class ClassyProject(Project, metaclass=PolymorphicSlotMergerMetaclass):
''' A more convenient, objectish, way of setting up a project.
'''
__slots__ = ()
_merge_slots_ = ()
- __metaclass__ = PolymorphicSlotMergerMetaclass
def __init__(self, srcdir):
super(ClassyProject, self).__init__(srcdir)
diff --git a/attoconf/core.py b/attoconf/core.py
index 8fff40f..efc952b 100644
--- a/attoconf/core.py
+++ b/attoconf/core.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
from collections import namedtuple, OrderedDict
import os
@@ -140,7 +140,8 @@ class Project(object):
self.help.print(sys.stdout, hidden)
sys.exit()
# sneaky
-Project.do_help.im_func.__module__ = 'attoconf.types'
+Project.do_help.__module__ = 'attoconf.types'
+#Project.do_help.__func__.__module__ = 'attoconf.types'
class Build(object):
''' A Build is a directory and set of options applied to a Project.
@@ -157,7 +158,7 @@ class Build(object):
self.project = project
self.builddir = trim_trailing_slashes(builddir)
self.vars = {as_var(k): o.init
- for (k, o) in project.options.iteritems()}
+ for (k, o) in project.options.items()}
self._seen_args = OrderedDict()
def apply_arg(self, arg):
@@ -196,7 +197,7 @@ class Build(object):
check(self)
status_file = os.path.join(self.builddir, 'config.status')
# open fd to control +x mode
- status_fd = os.open(status_file, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0777)
+ status_fd = os.open(status_file, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o777)
with os.fdopen(status_fd, 'w') as status:
print('Generating config.status')
status.write('#!%s\n' % sys.executable)
@@ -205,7 +206,7 @@ class Build(object):
status.write('old_build_dir = os.path.dirname(sys.argv[0])\n')
status.write('configure = os.path.join(old_build_dir, %r, "configure")\n'
% self.relative_source())
- seen_args = ['='.join(kv) for kv in self._seen_args.iteritems()]
+ seen_args = ['='.join(kv) for kv in self._seen_args.items()]
status.write('os.execvp(configure, [configure] + %r + sys.argv[1:])\n'
% seen_args)
diff --git a/attoconf/help.py b/attoconf/help.py
index 0fbc0a3..777becb 100644
--- a/attoconf/help.py
+++ b/attoconf/help.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
def put_line_in_width(file, line, width, indent):
''' Print a line with wrapping.
diff --git a/attoconf/lib/arches.py b/attoconf/lib/arches.py
index 63f6244..67a84bd 100644
--- a/attoconf/lib/arches.py
+++ b/attoconf/lib/arches.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
from ..classy import ClassyProject
from ..types import triple, maybe
diff --git a/attoconf/lib/c.py b/attoconf/lib/c.py
index 03f77da..98d88df 100644
--- a/attoconf/lib/c.py
+++ b/attoconf/lib/c.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import errno
import os
@@ -44,7 +44,7 @@ class TempFile:
def __init__(self, filename, content):
self.filename = filename
if content is not None:
- with open(filename, 'wx') as of:
+ with open(filename, 'x') as of:
of.write(content)
else:
# TODO: raise OSError(errno.EEXIST) if file already exists
diff --git a/attoconf/lib/config_hash.py b/attoconf/lib/config_hash.py
index 81d4a68..b3cb423 100644
--- a/attoconf/lib/config_hash.py
+++ b/attoconf/lib/config_hash.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
from hashlib import md5
import os
@@ -25,8 +25,8 @@ from ..classy import ClassyProject
def calc_hash(build):
hash = md5()
- for var, val in sorted(build.vars.iteritems()):
- hash.update('%s = %s\n' % (var, val))
+ for var, val in sorted(build.vars.items()):
+ hash.update(('%s = %s\n' % (var, val)).encode(encoding = 'UTF-8', errors = 'strict'))
return hash.hexdigest()
diff --git a/attoconf/lib/install.py b/attoconf/lib/install.py
index 26e515c..04b5c5a 100644
--- a/attoconf/lib/install.py
+++ b/attoconf/lib/install.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import os
diff --git a/attoconf/lib/lex.py b/attoconf/lib/lex.py
index 5f8ff43..27c2a7e 100644
--- a/attoconf/lib/lex.py
+++ b/attoconf/lib/lex.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
from ..classy import ClassyProject
from ..types import ShellList
diff --git a/attoconf/lib/make.py b/attoconf/lib/make.py
index f815cd0..ca70f34 100644
--- a/attoconf/lib/make.py
+++ b/attoconf/lib/make.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import os
import sys
diff --git a/attoconf/lib/pkg_config.py b/attoconf/lib/pkg_config.py
index 00bfba8..5bc846b 100644
--- a/attoconf/lib/pkg_config.py
+++ b/attoconf/lib/pkg_config.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import os
import sys
diff --git a/attoconf/lib/templates.py b/attoconf/lib/templates.py
index 0ec1a3e..7c26133 100644
--- a/attoconf/lib/templates.py
+++ b/attoconf/lib/templates.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import os
import sys
diff --git a/attoconf/lib/yacc.py b/attoconf/lib/yacc.py
index 885bbd3..c3fd1de 100644
--- a/attoconf/lib/yacc.py
+++ b/attoconf/lib/yacc.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
from ..classy import ClassyProject
from ..types import ShellList
diff --git a/attoconf/tests/test_core.py b/attoconf/tests/test_core.py
index d8de71f..93aeaaf 100644
--- a/attoconf/tests/test_core.py
+++ b/attoconf/tests/test_core.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import unittest
@@ -23,7 +23,7 @@ from attoconf.core import Project, Build
from attoconf.types import uint, shell_word, shell_partial_word, maybe
import os
-from cStringIO import StringIO
+from io import StringIO
import sys
class ReplacingStdout(object):
@@ -91,9 +91,9 @@ General:
def test_path(self):
proj = Project('foo/')
build = Build(proj, 'bar/')
- self.assertEquals(build.project.srcdir, 'foo')
- self.assertEquals(build.builddir, 'bar')
- self.assertEquals(build.relative_source(), '../foo')
+ self.assertEqual(build.project.srcdir, 'foo')
+ self.assertEqual(build.builddir, 'bar')
+ self.assertEqual(build.relative_source(), '../foo')
def test_configure(self):
def check_foo(bld, FOO):
diff --git a/attoconf/tests/test_help.py b/attoconf/tests/test_help.py
index ea42c28..60a9e49 100644
--- a/attoconf/tests/test_help.py
+++ b/attoconf/tests/test_help.py
@@ -15,13 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import unittest
from attoconf.help import Help, HelpSection, put_line_in_width
-from cStringIO import StringIO
+from io import StringIO
class TestHelpSection(unittest.TestCase):
def test_basic(self):
diff --git a/attoconf/tests/test_types.py b/attoconf/tests/test_types.py
index 662c0a3..14926ef 100644
--- a/attoconf/tests/test_types.py
+++ b/attoconf/tests/test_types.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import unittest
@@ -26,7 +26,7 @@ class TestEnum(unittest.TestCase):
foobar = enum('foo', 'bar')
foobar('foo')
foobar('bar')
- with self.assertRaisesRegexp(ValueError, "'baz' not in {foo, bar}"):
+ with self.assertRaisesRegex(ValueError, "'baz' not in {foo, bar}"):
foobar('baz')
class TestShell(unittest.TestCase):
diff --git a/attoconf/tests/test_version.py b/attoconf/tests/test_version.py
index 4325fba..9967283 100644
--- a/attoconf/tests/test_version.py
+++ b/attoconf/tests/test_version.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import unittest
diff --git a/attoconf/types.py b/attoconf/types.py
index 8a8d56a..e1af528 100644
--- a/attoconf/types.py
+++ b/attoconf/types.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import os
from pipes import quote as shell_quote
diff --git a/attoconf/version.py b/attoconf/version.py
index 829005c..065195b 100644
--- a/attoconf/version.py
+++ b/attoconf/version.py
@@ -15,14 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with attoconf. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function, division, absolute_import
+
import sys
from . import _version
-if sys.version_info[0] != 2 or sys.version_info[1] < 7:
- sys.exit('Unsupported Python version: %s\nattoconf requires Python 2.7' % sys.version)
+if sys.version_info[0] != 3 or sys.version_info[1] < 10:
+ sys.exit('Unsupported Python version: %s\nattoconf requires Python 3.10+' % sys.version)
def require_version(major, minor, patch=0):
''' Check that this is the right version of attoconf, or die trying.
diff --git a/setup.py b/setup.py
index 09c35c9..db30276 100755
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
from distutils.core import setup