Browse Source

python3: Manual fixing of errors left by 2to3 script

Some of those fixes come from Ehsan Azar's branch.

https://bugzilla.gnome.org/show_bug.cgi?id=733067
zrythm
Xavier Claessens 5 years ago
parent
commit
fa78642c4a
  1. 2
      cerbero-uninstalled
  2. 2
      cerbero/bootstrap/ios.py
  3. 8
      cerbero/bootstrap/linux.py
  4. 2
      cerbero/commands/__init__.py
  5. 2
      cerbero/config.py
  6. 5
      cerbero/enums.py
  7. 53
      cerbero/hacks.py
  8. 7
      cerbero/ide/pkgconfig.py
  9. 2
      cerbero/ide/vs/pkgconfig2vsprops.py
  10. 2
      cerbero/ide/vs/vsprops.py
  11. 8
      cerbero/ide/xcode/fwlib.py
  12. 2
      cerbero/ide/xcode/xcconfig.py
  13. 2
      cerbero/tools/libtool.py
  14. 2
      cerbero/tools/osxrelocator.py
  15. 7
      cerbero/tools/osxuniversalgenerator.py
  16. 2
      cerbero/tools/pkgconfig.py
  17. 2
      cerbero/tools/strip.py
  18. 6
      cerbero/utils/shell.py
  19. 12
      packages/gstreamer-1.0-effects.package
  20. 3
      recipes/gobject-introspection.recipe
  21. 12
      recipes/gst-plugins-bad-1.0.recipe
  22. 2
      test/test_cerbero_ide_pkgconfig.py

2
cerbero-uninstalled

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import os

2
cerbero/bootstrap/ios.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# ios.py
#

8
cerbero/bootstrap/linux.py

@ -48,7 +48,7 @@ class DebianBootstrapper (UnixBootstrapper): @@ -48,7 +48,7 @@ class DebianBootstrapper (UnixBootstrapper):
packages = ['autotools-dev', 'automake', 'autoconf', 'libtool', 'g++',
'autopoint', 'make', 'cmake', 'bison', 'flex', 'yasm',
'pkg-config', 'gtk-doc-tools', 'libxv-dev', 'libx11-dev',
'libpulse-dev', 'python-dev', 'texinfo', 'gettext',
'libpulse-dev', 'python3-dev', 'texinfo', 'gettext',
'build-essential', 'pkg-config', 'doxygen', 'curl',
'libxext-dev', 'libxi-dev', 'x11proto-record-dev',
'libxrender-dev', 'libgl1-mesa-dev', 'libxfixes-dev',
@ -107,7 +107,7 @@ class RedHatBootstrapper (UnixBootstrapper): @@ -107,7 +107,7 @@ class RedHatBootstrapper (UnixBootstrapper):
'pkgconfig', 'gtk-doc', 'curl', 'doxygen', 'texinfo',
'texinfo-tex', 'texlive-dvips', 'docbook-style-xsl',
'transfig', 'intltool', 'rpm-build', 'redhat-rpm-config',
'python-devel', 'libXrender-devel', 'pulseaudio-libs-devel',
'python3-devel', 'libXrender-devel', 'pulseaudio-libs-devel',
'libXv-devel', 'mesa-libGL-devel', 'libXcomposite-devel',
'alsa-lib-devel', 'perl-ExtUtils-MakeMaker', 'libXi-devel',
'perl-XML-Simple', 'gperf', 'gdk-pixbuf2-devel', 'wget',
@ -144,7 +144,7 @@ class OpenSuseBootstrapper (UnixBootstrapper): @@ -144,7 +144,7 @@ class OpenSuseBootstrapper (UnixBootstrapper):
'gtk-doc', 'curl', 'doxygen', 'texinfo',
'texlive', 'docbook-xsl-stylesheets',
'transfig', 'intltool', 'patterns-openSUSE-devel_rpm_build',
'python-devel', 'xorg-x11-libXrender-devel', 'libpulse-devel',
'python3-devel', 'xorg-x11-libXrender-devel', 'libpulse-devel',
'xorg-x11-libXv-devel', 'Mesa-libGL-devel', 'libXcomposite-devel',
'libX11-devel', 'alsa-devel', 'libXi-devel', 'Mesa-devel',
'Mesa-libGLESv3-devel',
@ -158,7 +158,7 @@ class ArchBootstrapper (UnixBootstrapper): @@ -158,7 +158,7 @@ class ArchBootstrapper (UnixBootstrapper):
'libtool', 'bison', 'flex', 'automake', 'autoconf', 'make',
'curl', 'gettext', 'alsa-lib', 'yasm', 'gperf',
'docbook-xsl', 'transfig', 'libxrender',
'libxv', 'mesa', 'python2', 'wget', 'glib-networking', 'git',
'libxv', 'mesa', 'python3', 'wget', 'glib-networking', 'git',
'subversion', 'xorg-util-macros']
def __init__(self, config):

2
cerbero/commands/__init__.py

@ -66,7 +66,7 @@ def load_commands(subparsers): @@ -66,7 +66,7 @@ def load_commands(subparsers):
__import__('cerbero.commands.%s' % name)
except ImportError as e:
m.warning("Error importing command %s:\n %s" % (name, e))
for command in list(_commands.values()):
for command in _commands.values():
command.add_parser(subparsers)

2
cerbero/config.py

@ -537,7 +537,7 @@ class Config (object): @@ -537,7 +537,7 @@ class Config (object):
def _perl_version(self):
version = shell.check_call("perl -e 'print \"$]\";'")
# FIXME: when perl's mayor is >= 10
mayor = version[0]
mayor = str(version[0])
minor = str(int(version[2:5]))
revision = str(int(version[5:8]))
return '.'.join([mayor, minor, revision])

5
cerbero/enums.py

@ -166,6 +166,11 @@ class LicenseDescription: @@ -166,6 +166,11 @@ class LicenseDescription:
self.acronym = acronym
self.pretty_name = pretty_name
def __lt__(self, other):
return self.acronym < other.acronym
def __repr__(self):
return "LicenseDescription(%s)" % self.acronym
class License:
''' Enumeration of licensesversions '''

53
cerbero/hacks.py

@ -39,14 +39,14 @@ def pretify(string, pretty_print=True): @@ -39,14 +39,14 @@ def pretify(string, pretty_print=True):
def write(self, file_or_filename, encoding=None, pretty_print=False):
if not pretty_print:
return oldwrite(self, file_or_filename, encoding)
tmpfile = io.StringIO()
tmpfile = io.BytesIO()
oldwrite(self, tmpfile, encoding)
tmpfile.seek(0)
if hasattr(file_or_filename, "write"):
out_file = file_or_filename
else:
out_file = open(file_or_filename, "wb")
out_file.write(pretify(tmpfile.read()))
out_file.write(pretify(tmpfile.read()).encode())
if not hasattr(file_or_filename, "write"):
out_file.close()
@ -56,49 +56,7 @@ etree.ElementTree.write = write @@ -56,49 +56,7 @@ etree.ElementTree.write = write
### Windows Hacks ###
# On windows, python transforms all enviroment variables to uppercase,
# but we need lowercase ones to override configure options like
# am_cv_python_platform
environclass = os.environ.__class__
import UserDict
class _Environ(environclass):
def __init__(self, environ):
UserDict.UserDict.__init__(self)
self.data = {}
for k, v in list(environ.items()):
self.data[k] = v
def __setitem__(self, key, item):
os.putenv(key, item)
self.data[key] = item
def __getitem__(self, key):
return self.data[key]
def __delitem__(self, key):
os.putenv(key, '')
del self.data[key]
def pop(self, key, *args):
os.putenv(key, '')
return self.data.pop(key, *args)
def has_key(self, key):
return key in self.data
def __contains__(self, key):
return key in self.data
def get(self, key, failobj=None):
return self.data.get(key, failobj)
# we don't want backlashes in paths as it breaks shell commands
oldexpanduser = os.path.expanduser
oldabspath = os.path.abspath
oldrealpath = os.path.realpath
@ -120,12 +78,17 @@ def realpath(path): @@ -120,12 +78,17 @@ def realpath(path):
return oldrealpath(path).replace('\\', '/')
if sys.platform.startswith('win'):
os.environ = _Environ(os.environ)
os.path.join = join
os.path.expanduser = expanduser
os.path.abspath = abspath
os.path.realpath = realpath
# On windows, python transforms all enviroment variables to uppercase,
# but we need lowercase ones to override configure options like
# am_cv_python_platform
os.environ.encodekey = os.environ.encodevalue
import stat
import shutil
from shutil import rmtree as shutil_rmtree

7
cerbero/ide/pkgconfig.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#
@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
import subprocess
import os
import sys
from cerbero.errors import FatalError
@ -102,6 +103,10 @@ class PkgConfig(object): @@ -102,6 +103,10 @@ class PkgConfig(object):
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
output, unused_err = process.communicate()
output = output.strip()
if sys.stdout.encoding:
output = output.decode(sys.stdout.encoding)
if delimiter:
res = output.split('%s' % delimiter)
if res[0] == ' ':

2
cerbero/ide/vs/pkgconfig2vsprops.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

2
cerbero/ide/vs/vsprops.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

8
cerbero/ide/xcode/fwlib.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#
@ -196,11 +196,11 @@ class StaticFrameworkLibrary(FrameworkLibrary): @@ -196,11 +196,11 @@ class StaticFrameworkLibrary(FrameworkLibrary):
# Hard link source file to the target name
os.link(obj_path, tmpdir_thinarch + '/' + target_name)
except:
# Fall back to cp if hard link doesn't work for any reason
# Fall back to cp if hard link doesn't work for any reason
shell.call('cp %s %s' % (obj_path, target_name), tmpdir_thinarch)
# If we have a duplicate object, commit any collected ones
if target_name in target_objs:
if target_name in target_objs:
m.warning ("Committing %d objects due to dup %s" % (len (target_objs), target_name))
shell.call('ar -cqS %s %s' % (libname, " ".join (target_objs)), tmpdir_thinarch)
target_objs = []
@ -209,7 +209,7 @@ class StaticFrameworkLibrary(FrameworkLibrary): @@ -209,7 +209,7 @@ class StaticFrameworkLibrary(FrameworkLibrary):
object_files_md5.append(md5)
# Put all the collected target_objs in the archive. cmdline limit is 262k args on OSX.
if len(target_objs):
if len(target_objs):
shell.call('ar -cqS %s %s' % (libname, " ".join (target_objs)), tmpdir_thinarch)
shutil.rmtree(lib_tmpdir)
shell.call('ar -s %s' % (libname), tmpdir_thinarch)

2
cerbero/ide/xcode/xcconfig.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

2
cerbero/tools/libtool.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

2
cerbero/tools/osxrelocator.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

7
cerbero/tools/osxuniversalgenerator.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Thiago Santos <thiago.sousa.santos@collabora.com>
#
@ -21,6 +21,7 @@ import os @@ -21,6 +21,7 @@ import os
import subprocess
import shutil
import tempfile
import sys
from cerbero.utils import shell
from cerbero.tools.osxrelocator import OSXRelocator
@ -224,6 +225,10 @@ class OSXUniversalGenerator(object): @@ -224,6 +225,10 @@ class OSXUniversalGenerator(object):
process = subprocess.Popen(cmd, cwd=cwd,
stdout=subprocess.PIPE, shell=True)
output, unused_err = process.communicate()
if sys.stdout.encoding:
output = output.decode(sys.stdout.encoding)
return output

2
cerbero/tools/pkgconfig.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

2
cerbero/tools/strip.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

6
cerbero/utils/shell.py

@ -170,6 +170,10 @@ def check_call(cmd, cmd_dir=None, shell=False, split=True, fail=False): @@ -170,6 +170,10 @@ def check_call(cmd, cmd_dir=None, shell=False, split=True, fail=False):
raise Exception()
except Exception:
raise FatalError(_("Error running command: %s") % cmd)
if sys.stdout.encoding:
output = output.decode(sys.stdout.encoding)
return output
@ -465,7 +469,7 @@ PS1='\[\033[01;32m\][cerbero-%s-%s]\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ @@ -465,7 +469,7 @@ PS1='\[\033[01;32m\][cerbero-%s-%s]\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
'''
bashrc = tempfile.NamedTemporaryFile()
bashrc.write(BASHRC % (platform, arch))
bashrc.write((BASHRC % (platform, arch)).encode())
bashrc.flush()
if sourcedir:

12
packages/gstreamer-1.0-effects.package

@ -22,9 +22,9 @@ class Package(custom.GStreamer, package.Package): @@ -22,9 +22,9 @@ class Package(custom.GStreamer, package.Package):
'gst-plugins-ugly-1.0:plugins_effects_devel',
'gst-plugins-bad-1.0:plugins_effects_devel']
def prepare(self):
if self.config.platform == Platform.WINDOWS:
# FIXME: This will almost certainly fail to build on Windows due to
# https://bugzilla.gnome.org/show_bug.cgi?id=770264
# See also, gst-plugins-bad-1.0.recipe and -static
self.files.remove('webrtc-audio-processing:libs')
def prepare(self):
if self.config.platform == Platform.WINDOWS:
# FIXME: This will almost certainly fail to build on Windows due to
# https://bugzilla.gnome.org/show_bug.cgi?id=770264
# See also, gst-plugins-bad-1.0.recipe and -static
self.files.remove('webrtc-audio-processing:libs')

3
recipes/gobject-introspection.recipe

@ -11,6 +11,7 @@ class Recipe(recipe.Recipe): @@ -11,6 +11,7 @@ class Recipe(recipe.Recipe):
licenses = [License.GPLv2Plus]
autoreconf = True
autoreconf_sh = 'gtkdocize && autoreconf -vfi'
configure_options = '--with-python=python3'
deps = ['glib']
files_bins = ['g-ir-annotation-tool', 'g-ir-compiler', 'g-ir-doc-tool', 'g-ir-generate', 'g-ir-scanner']
@ -73,7 +74,7 @@ class Recipe(recipe.Recipe): @@ -73,7 +74,7 @@ class Recipe(recipe.Recipe):
# on arch python2 needs to be specified as the interpreter
# the full path needs to be specified, since shebangs are generated
if self.config.target_distro == Distro.ARCH:
self.config_sh = "PYTHON=/usr/bin/python2 %s" % self.config_sh
self.config_sh = "PYTHON=/usr/bin/python3 %s" % self.config_sh
# TODO: catch the share/man stuff like man1/g-ir* ?
def configure(self):

12
recipes/gst-plugins-bad-1.0.recipe

@ -371,12 +371,12 @@ class Recipe(custom.GStreamer): @@ -371,12 +371,12 @@ class Recipe(custom.GStreamer):
if self.config.platform == Platform.WINDOWS:
# FIXME: This will almost certainly fail to build on Windows due to
# https://bugzilla.gnome.org/show_bug.cgi?id=770264
# See also, -static and gstreamer-1.0-effects.package
self.deps.remove('webrtc-audio-processing')
self.files_plugins_effects.remove('lib/gstreamer-1.0/libgstwebrtcdsp%(mext)s')
self.files_plugins_effects_devel.remove('lib/gstreamer-1.0/libgstwebrtcdsp.a')
self.files_plugins_effects_devel.remove('lib/gstreamer-1.0/libgstwebrtcdsp.la')
# https://bugzilla.gnome.org/show_bug.cgi?id=770264
# See also, -static and gstreamer-1.0-effects.package
self.deps.remove('webrtc-audio-processing')
self.files_plugins_effects.remove('lib/gstreamer-1.0/libgstwebrtcdsp%(mext)s')
self.files_plugins_effects_devel.remove('lib/gstreamer-1.0/libgstwebrtcdsp.a')
self.files_plugins_effects_devel.remove('lib/gstreamer-1.0/libgstwebrtcdsp.la')
if self.config.target_platform != Platform.LINUX:
self.configure_options += ' --disable-gtk-doc '

2
test/test_cerbero_ide_pkgconfig.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#

Loading…
Cancel
Save