Commit fa78642c authored by Xavier Claessens's avatar Xavier Claessens

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
parent 029a2a8d
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import os
......
#!/usr/bin/env python
#!/usr/bin/env python3
#
# ios.py
#
......
......@@ -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):
'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):
'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):
'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):
......
......@@ -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)
......
......@@ -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])
......@@ -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 '''
......
......@@ -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
### 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):
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
......
#!/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 @@
import subprocess
import os
import sys
from cerbero.errors import FatalError
......@@ -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] == ' ':
......
#!/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>
#
......
#!/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>
#
......
#!/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):
# 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):
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)
......
#!/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>
#
......
#!/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>
#
......
#!/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>
#
......
#!/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
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):
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
......
#!/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>
#
......
#!/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>
#
......
......@@ -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\]\$
'''
bashrc = tempfile.NamedTemporaryFile()
bashrc.write(BASHRC % (platform, arch))
bashrc.write((BASHRC % (platform, arch)).encode())
bashrc.flush()
if sourcedir:
......
......@@ -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')
......@@ -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):
# 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):
......
......@@ -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 '
......
#!/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>
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment