Removed Python 2 support

Drops system, host and target Python 2 support.
Note a lot of recipes were having hardcoded reference to
`lib/python2.7/site-packages/` directory. I suspect most
of theses were not working, but the reference has been updated
to `lib/python3.7/site-packages/` following the same hardcoding
pattern. In follow up work we would do a walkthrough each recipes
to fix at least compilation time issues.
Also note the `rebuild_updated_recipes.py` is expected to fail as
this is touching many recipes including recipes that were already
broken.
This commit is contained in:
Andre Miras 2020-05-05 23:17:44 +02:00
parent 7385cdfca8
commit e29d6aa256
44 changed files with 38 additions and 1060 deletions

View file

@ -16,9 +16,6 @@ The toolchain supports:
- iPhone Simulator (x86_64)
- iPhone / iOS (armv7 and arm64)
You can select between Python 2.7 or Python 3.7 by specifying the recipes
`python2` or `python3` when building.
These recipes are not ported to the new toolchain yet:
- lxml
@ -66,7 +63,6 @@ You can list the available recipes and their versions with:
flask master
freetype 2.5.5
hostlibffi 3.2.1
hostpython2 2.7.1
hostpython3 3.7.1
ios master
itsdangerous master
@ -86,7 +82,6 @@ You can list the available recipes and their versions with:
pycrypto 2.6.1
pykka 1.2.1
pyobjus master
python2 2.7.1
python3 3.7.1
pyyaml 3.11
sdl2 2.0.8

View file

@ -17,7 +17,7 @@ class ClickRecipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
cmd = sh.Command("sed")
shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env)
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -16,7 +16,7 @@ class DistributeRecipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -17,7 +17,7 @@ class FlaskRecipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
cmd = sh.Command("sed")
shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env)
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -19,7 +19,7 @@ class HostSetuptools(Recipe):
# Setuptools version 28.3.0
site_packages_path = join(
self.ctx.dist_dir, 'hostpython',
'lib', 'python2.7', 'site-packages')
'lib', 'python3.7', 'site-packages')
os.chdir(site_packages_path)
with open('setuptools.pth', 'r') as f:
setuptools_egg_path = f.read().strip('./').strip('\n')

View file

@ -7,19 +7,21 @@ logger = logging.getLogger(__name__)
class HostpythonAliasRecipe(Recipe):
"""
Note this recipe was created to handle both hostpython2 and hostpython3.
As hostpython2 support was dropped, this could probably be simplified.
"""
is_alias = True
def init_after_import(self, ctx):
hostpython = ctx.state.get("hostpython")
if not hostpython:
# search in wanted_recipes if it's the first time
if "hostpython2" in ctx.wanted_recipes:
hostpython = "hostpython2"
elif "hostpython3" in ctx.wanted_recipes:
if "hostpython3" in ctx.wanted_recipes:
hostpython = "hostpython3"
else:
logger.error("No hostpython version set in the build.")
logger.error("Add python2 or python3 in your recipes:")
logger.error("Add python3 in your recipes:")
logger.error("./toolchain.py build python3 ...")
sys.exit(1)
if hostpython:

View file

@ -1,56 +0,0 @@
posix posixmodule.c # posix (UNIX) system calls
errno errnomodule.c # posix (UNIX) errno values
pwd pwdmodule.c # this is needed to find out the user's home dir
# if $HOME is not set
_sre _sre.c # Fredrik Lundh's new regular expressions
_codecs _codecsmodule.c # access to the builtin codecs and codec registry
zipimport zipimport.c
_symtable symtablemodule.c
array arraymodule.c # array objects
cmath cmathmodule.c # -lm # complex math library functions
math mathmodule.c # -lm # math library functions, e.g. sin()
_struct _struct.c # binary structure packing/unpacking
time timemodule.c # -lm # time operations and variables
operator operator.c # operator.add() and similar goodies
_weakref _weakref.c # basic weak reference support
_random _randommodule.c # Random number generator
_collections _collectionsmodule.c # Container types
itertools itertoolsmodule.c # Functions creating iterators for efficient looping
strop stropmodule.c # String manipulations
_functools _functoolsmodule.c # Tools for working with functions and callable objects
_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
datetime datetimemodule.c # date/time type
_bisect _bisectmodule.c # Bisection algorithms
fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
select selectmodule.c # select(2); not on ancient System V
_socket socketmodule.c
_md5 md5module.c md5.c
_sha shamodule.c
_sha256 sha256module.c
_sha512 sha512module.c
binascii binascii.c
parser parsermodule.c
cStringIO cStringIO.c
cPickle cPickle.c
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
xxsubtype xxsubtype.c
unicodedata unicodedata.c # static Unicode character database
# Theses modules are used by Kivy inside other module
# json in Settings, _io by zipfile...
_json _json.c
_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c
_heapq _heapqmodule.c
# Special inclusion for sqlite3
_sqlite3 -DSQLITE_OMIT_LOAD_EXTENSION _sqlite/cache.c _sqlite/microprotocols.c _sqlite/row.c _sqlite/connection.c _sqlite/module.c _sqlite/statement.c _sqlite/cursor.c _sqlite/prepare_protocol.c _sqlite/util.c
# Include expat
pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
# Future (used by numpy)
future_builtins future_builtins.c
# ctypes
_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c

View file

@ -1 +0,0 @@
_ssl _ssl.c -DUSE_SSL -lssl -lcrypto

View file

@ -1,118 +0,0 @@
from kivy_ios.toolchain import Recipe, shprint, ensure_dir
from os.path import join, exists
import os
import sh
import shutil
import logging
logger = logging.getLogger(__name__)
class Hostpython2Recipe(Recipe):
version = "2.7.1"
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2"
depends = ["hostlibffi"]
optional_depends = ["openssl"]
archs = ["x86_64"]
def init_with_ctx(self, ctx):
super(Hostpython2Recipe, self).init_with_ctx(ctx)
self.set_hostpython(self, "2.7")
self.ctx.so_suffix = ".so"
self.ctx.hostpython = join(self.ctx.dist_dir, "hostpython2", "bin", "python")
self.ctx.hostpgen = join(self.ctx.dist_dir, "hostpython2", "bin", "pgen")
logger.info("Global: hostpython located at {}".format(self.ctx.hostpython))
logger.info("Global: hostpgen located at {}".format(self.ctx.hostpgen))
def prebuild_arch(self, arch):
if self.has_marker("patched"):
return
self.copy_file("_scproxy.py", "Lib/_scproxy.py")
self.apply_patch("ssize-t-max.patch")
self.apply_patch("dynload.patch")
self.apply_patch("static-_sqlite3.patch")
self.copy_file("ModulesSetup", "Modules/Setup.local")
if "openssl.build_all" in self.ctx.state:
self.append_file("ModulesSetup.openssl", "Modules/Setup.local")
self.set_marker("patched")
def postbuild_arch(self, arch):
makefile_fn = join(self.build_dir, "Makefile")
with open(makefile_fn) as fd:
lines = fd.readlines()
for index, line in enumerate(lines):
if "-bundle" not in line:
continue
parts = line.split(" ")
parts.remove("-bundle")
if "-bundle_loader" in parts:
i = parts.index("-bundle_loader")
parts.pop(i)
parts.pop(i)
lines[index] = " ".join(parts)
with open(makefile_fn, "w") as fd:
fd.writelines(lines)
def build_x86_64(self):
sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
build_env = self.ctx.env.copy()
ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
build_env["CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
build_env["LDFLAGS"] = " ".join([
"-lsqlite3",
"-lffi",
"-L{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
])
build_env["CFLAGS"] = " ".join([
"--sysroot={}".format(sdk_path),
"-arch x86_64",
"-mmacosx-version-min=10.12",
"-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include"))
])
if "openssl.build_all" in self.ctx.state:
build_env["LDFLAGS"] += " -L{}".format(join(self.ctx.dist_dir, "lib"))
build_env["CFLAGS"] += " -I{}".format(join(self.ctx.dist_dir, "include",
"x86_64", "openssl"))
configure = sh.Command(join(self.build_dir, "configure"))
shprint(configure,
"--prefix={}".format(join(self.ctx.dist_dir, "hostpython2")),
"--disable-toolbox-glue",
"--without-gcc",
_env=build_env)
shprint(sh.make, "-C", self.build_dir, self.ctx.concurrent_make, "python", "Parser/pgen",
_env=build_env)
shutil.move("python", "hostpython2")
shutil.move("Parser/pgen", "Parser/hostpgen")
def install(self):
arch = list(self.filtered_archs)[0]
build_env = arch.get_env()
build_dir = self.get_build_dir(arch.arch)
build_env["PATH"] = os.environ["PATH"]
# Compiling sometimes looks for Python-ast.py in the 'Python' i.s.o.
# the 'hostpython' folder. Create a symlink to fix. See issue #201
shprint(sh.ln, "-s",
join(build_dir, "hostpython2"),
join(build_dir, "Python"))
shprint(sh.make, self.ctx.concurrent_make,
"-C", build_dir,
"bininstall", "inclinstall",
_env=build_env)
pylib_dir = join(self.ctx.dist_dir, "hostpython2", "lib", "python2.7")
if exists(pylib_dir):
shutil.rmtree(pylib_dir)
shutil.copytree(
join(build_dir, "Lib"),
pylib_dir)
ensure_dir(join(pylib_dir, "config"))
shutil.copy(
join(build_dir, "Makefile"),
join(pylib_dir, "config", "Makefile"))
shutil.copy(
join(build_dir, "Parser", "pgen"),
join(self.ctx.dist_dir, "hostpython2", "bin", "pgen"))
recipe = Hostpython2Recipe()

View file

@ -1,12 +0,0 @@
'''
Stub functions for _scproxy on OsX
No proxy is supported yet.
'''
def _get_proxy_settings():
return {'exclude_simple': 1}
def _get_proxies():
return {}

View file

@ -1,24 +0,0 @@
--- Python-2.7.1/Python/dynload_shlib.c.orig 2011-12-05 00:00:00.000000000 +0100
+++ Python-2.7.1/Python/dynload_shlib.c 2011-12-05 00:02:51.000000000 +0100
@@ -84,6 +84,15 @@
PyOS_snprintf(funcname, sizeof(funcname),
LEAD_UNDERSCORE "init%.200s", shortname);
+ /* On IOS, dlopen crash as soon as we try to open one of our library.
+ * Instead, we have done a redirection of linking to convert our .so into a
+ * .a. Then the main executable is linked with theses symbol. So, instead
+ * of trying to dlopen, directly do the dlsym.
+ * -- Mathieu
+ */
+ return (dl_funcptr) dlsym(RTLD_MAIN_ONLY, funcname);
+
+#if 0
if (fp != NULL) {
int i;
struct stat statb;
@@ -140,4 +149,5 @@
handles[nhandles++].handle = handle;
p = (dl_funcptr) dlsym(handle, funcname);
return p;
+#endif
}

View file

@ -1,17 +0,0 @@
diff -Naur Python-2.7.1.orig/Include/pyport.h Python-2.7.1/Include/pyport.h
--- Python-2.7.1.orig/Include/pyport.h 2010-09-14 18:10:22.000000000 +0200
+++ Python-2.7.1/Include/pyport.h 2011-05-13 12:24:53.000000000 +0200
@@ -186,9 +186,11 @@
#endif
/* Largest positive value of type Py_ssize_t. */
-#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
+//#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
/* Smallest negative value of type Py_ssize_t. */
-#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
+//#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
+#define PY_SSIZE_T_MAX TMP_MAX
+#define PY_SSIZE_T_MIN -TMP_MAX
#if SIZEOF_PID_T > SIZEOF_LONG
# error "Python doesn't support sizeof(pid_t) > sizeof(long)"

View file

@ -1,25 +0,0 @@
--- Python-2.7.1/Modules/_sqlite/module.c.orig 2012-10-28 02:30:58.000000000 +0200
+++ Python-2.7.1/Modules/_sqlite/module.c 2012-10-28 02:28:12.000000000 +0200
@@ -28,6 +28,9 @@
#include "prepare_protocol.h"
#include "microprotocols.h"
#include "row.h"
+#ifndef MODULE_NAME
+#define MODULE_NAME "_sqlite3"
+#endif
#if SQLITE_VERSION_NUMBER >= 3003003
#define HAVE_SHARED_CACHE
--- Python-2.7.1/Modules/_sqlite/sqlitecompat.h.orig 2012-10-28 02:30:53.000000000 +0200
+++ Python-2.7.1/Modules/_sqlite/sqlitecompat.h 2012-10-28 02:28:14.000000000 +0200
@@ -26,6 +26,10 @@
#ifndef PYSQLITE_COMPAT_H
#define PYSQLITE_COMPAT_H
+#ifndef MODULE_NAME
+#define MODULE_NAME "_sqlite3"
+#endif
+
/* define Py_ssize_t for pre-2.5 versions of Python */
#if PY_VERSION_HEX < 0x02050000

View file

@ -15,7 +15,7 @@ class ItsDangerousRecipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
cmd = sh.Command("sed")
with cd(build_dir):
shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env)

View file

@ -17,7 +17,7 @@ class Jinja2Recipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
cmd = sh.Command("sed")
shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env)
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -58,7 +58,7 @@ class KiventCoreRecipe(CythonRecipe):
kivent_core/modules/core/setup.py
This constructs the equivalent of the command
"$python2.7 setup.py build_ext install"
"$python setup.py build_ext install"
only with the environment variables altered for each different architecture
The appropriate version of kivy also needs to be added to the path, and this
differs for each architecture (i386, x86_64, armv7, etc)
@ -78,7 +78,7 @@ class KiventCoreRecipe(CythonRecipe):
build_env = self.get_recipe_env(arch)
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
# Add Architecture specific kivy path for 'import kivy' to PYTHONPATH
arch_kivy_path = self.get_recipe('kivy', self.ctx).get_build_dir(arch.arch)

View file

@ -9,7 +9,7 @@ class LibZBarRecipe(Recipe):
url = 'https://github.com/ZBar/ZBar/archive/{version}.zip'
depends = ['hostpython2']
depends = ['hostpython3']
library = 'zbar/.libs/libzbar.a'

View file

@ -17,7 +17,7 @@ class MarkupSafeRecipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
cmd = sh.Command("sed")
shprint(cmd, "-i", "", "s/,.*Feature//g", "./setup.py", _env=build_env)
shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env)

View file

@ -48,7 +48,7 @@ class PillowRecipe(Recipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = self.get_pil_env(arch)
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
shprint(hostpython, "-m", "easy_install",
"--prefix", dest_dir, "-Z", "./",
_env=build_env)

View file

@ -33,7 +33,7 @@ class PycryptoRecipe(CythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
with cd(build_dir):
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -7,15 +7,15 @@ logger = logging.getLogger(__name__)
class PythonAliasRecipe(Recipe):
"""
Note this recipe was created to handle both python2 and python3.
As python2 support was dropped, this could probably be simplified.
"""
is_alias = True
def init_after_import(self, ctx):
python = ctx.state.get("python")
if not python:
# search in wanted_recipes if it's the first time
if "python2" in ctx.wanted_recipes:
python = "python2"
else:
python = "python3"
self.depends = [python]
self.recipe_dir = join(ctx.root_dir, "recipes", python)

View file

@ -1,54 +0,0 @@
#posix posixmodule.c # posix (UNIX) system calls
#errno errnomodule.c # posix (UNIX) errno values
#pwd pwdmodule.c # this is needed to find out the user's home dir
# if $HOME is not set
#_sre _sre.c # Fredrik Lundh's new regular expressions
#_codecs _codecsmodule.c # access to the builtin codecs and codec registry
#zipimport zipimport.c
#_symtable symtablemodule.c
array arraymodule.c # array objects
cmath cmathmodule.c # -lm # complex math library functions
math mathmodule.c # -lm # math library functions, e.g. sin()
_struct _struct.c # binary structure packing/unpacking
time timemodule.c # -lm # time operations and variables
operator operator.c # operator.add() and similar goodies
#_weakref _weakref.c # basic weak reference support
_random _randommodule.c # Random number generator
_collections _collectionsmodule.c # Container types
itertools itertoolsmodule.c # Functions creating iterators for efficient looping
strop stropmodule.c # String manipulations
_functools _functoolsmodule.c # Tools for working with functions and callable objects
_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
datetime datetimemodule.c # date/time type
_bisect _bisectmodule.c # Bisection algorithms
fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
select selectmodule.c # select(2); not on ancient System V
_csv _csv.c
_socket socketmodule.c
_md5 md5module.c md5.c
_sha shamodule.c
_sha256 sha256module.c
_sha512 sha512module.c
binascii binascii.c
parser parsermodule.c
cStringIO cStringIO.c
cPickle cPickle.c
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
#xxsubtype xxsubtype.c
unicodedata unicodedata.c # static Unicode character database
# Theses modules are used by Kivy inside other module
# json in Settings, _io by zipfile...
_json _json.c
_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c
_heapq _heapqmodule.c
# Special inclusion for sqlite3
_sqlite3 -DSQLITE_OMIT_LOAD_EXTENSION _sqlite/cache.c _sqlite/microprotocols.c _sqlite/row.c _sqlite/connection.c _sqlite/module.c _sqlite/statement.c _sqlite/cursor.c _sqlite/prepare_protocol.c _sqlite/util.c
# Include expat
pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
# Future (used by numpy)
future_builtins future_builtins.c

View file

@ -1,2 +0,0 @@
# Ctypes
_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c -I$(srcdir)/../../build/include/ffi

View file

@ -1 +0,0 @@
_ssl _ssl.c -DUSE_SSL -lssl -lcrypto

View file

@ -1,156 +0,0 @@
from kivy_ios.toolchain import Recipe, shprint
from os.path import join
import sh
import os
import logging
logger = logging.getLogger(__name__)
class Python2Recipe(Recipe):
version = "2.7.1"
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2"
depends = ["hostpython2", "libffi"]
optional_depends = ["openssl"]
library = "libpython2.7.a"
pbx_libraries = ["libz", "libbz2", "libsqlite3"]
def init_with_ctx(self, ctx):
super(Python2Recipe, self).init_with_ctx(ctx)
self.set_python(self, "2.7")
ctx.python_ver_dir = "python2.7"
ctx.python_prefix = join(ctx.dist_dir, "root", "python2")
ctx.site_packages_dir = join(
ctx.python_prefix, "lib", ctx.python_ver_dir, "site-packages")
def prebuild_arch(self, arch):
# common to all archs
if self.has_marker("patched"):
return
self.apply_patch("ssize-t-max.patch")
self.apply_patch("dynload.patch")
self.apply_patch("static-_sqlite3.patch")
self.copy_file("ModulesSetup", "Modules/Setup.local")
self.copy_file("_scproxy.py", "Lib/_scproxy.py")
self.apply_patch("xcompile.patch")
self.apply_patch("setuppath.patch")
self.append_file("ModulesSetup.mobile", "Modules/Setup.local")
self.apply_patch("ipv6.patch")
if "openssl.build_all" in self.ctx.state:
self.append_file("ModulesSetup.openssl", "Modules/Setup.local")
self.apply_patch("posixmodule.patch")
self.set_marker("patched")
def build_arch(self, arch):
build_env = arch.get_env()
configure = sh.Command(join(self.build_dir, "configure"))
shprint(configure,
"CC={}".format(build_env["CC"]),
"LD={}".format(build_env["LD"]),
"CFLAGS={}".format(build_env["CFLAGS"]),
"LDFLAGS={} -undefined dynamic_lookup".format(build_env["LDFLAGS"]),
"--without-pymalloc",
"--disable-toolbox-glue",
"--host={}-apple-darwin".format(arch),
"--prefix=/python",
"--with-system-ffi",
"--without-doc-strings",
"--enable-ipv6",
_env=build_env)
self._patch_pyconfig()
self.apply_patch("ctypes_duplicate.patch")
self.apply_patch("ctypes_duplicate_longdouble.patch")
shprint(sh.make, self.ctx.concurrent_make,
"CROSS_COMPILE_TARGET=yes",
"HOSTPYTHON={}".format(self.ctx.hostpython),
"HOSTPGEN={}".format(self.ctx.hostpgen))
def install(self):
arch = list(self.filtered_archs)[0]
build_env = arch.get_env()
build_dir = self.get_build_dir(arch.arch)
build_env["PATH"] = os.environ["PATH"]
shprint(sh.make, self.ctx.concurrent_make,
"-C", build_dir,
"install",
"CROSS_COMPILE_TARGET=yes",
"HOSTPYTHON={}".format(self.ctx.hostpython),
"prefix={}".format(join(self.ctx.dist_dir, "root", "python2")),
_env=build_env)
self.reduce_python()
def _patch_pyconfig(self):
# patch pyconfig to remove some functionnalities
# (to have uniform build accross all platfors)
# this was before in a patch itself, but because the different
# architecture can lead to different pyconfig.h, we would need one patch
# per arch. Instead, express here the line we don't want / we want.
pyconfig = join(self.build_dir, "pyconfig.h")
def _remove_line(lines, pattern):
for line in lines[:]:
if pattern in line:
lines.remove(line)
with open(pyconfig, "r") as fd:
lines = fd.readlines()
_remove_line(lines, "#define HAVE_BIND_TEXTDOMAIN_CODESET 1")
_remove_line(lines, "#define HAVE_FINITE 1")
_remove_line(lines, "#define HAVE_FSEEK64 1")
_remove_line(lines, "#define HAVE_FTELL64 1")
_remove_line(lines, "#define HAVE_GAMMA 1")
_remove_line(lines, "#define HAVE_GETHOSTBYNAME_R 1")
_remove_line(lines, "#define HAVE_GETHOSTBYNAME_R_6_ARG 1")
_remove_line(lines, "#define HAVE_GETRESGID 1")
_remove_line(lines, "#define HAVE_GETRESUID 1")
_remove_line(lines, "#define HAVE_GETSPENT 1")
_remove_line(lines, "#define HAVE_GETSPNAM 1")
_remove_line(lines, "#define HAVE_MREMAP 1")
_remove_line(lines, "#define HAVE_PLOCK 1")
_remove_line(lines, "#define HAVE_SEM_TIMEDWAIT 1")
_remove_line(lines, "#define HAVE_SETRESGID 1")
_remove_line(lines, "#define HAVE_SETRESUID 1")
_remove_line(lines, "#define HAVE_TMPNAM_R 1")
_remove_line(lines, "#define HAVE__GETPTY 1")
lines.append("#define HAVE_GETHOSTBYNAME 1\n")
with open(pyconfig, "w") as fd:
fd.writelines(lines)
def reduce_python(self):
logger.info("Reduce python")
oldpwd = os.getcwd()
try:
logger.info("Remove files unlikely to be used")
os.chdir(join(self.ctx.dist_dir, "root", "python2"))
sh.rm("-rf", "share")
sh.rm("-rf", "bin")
os.chdir(join(self.ctx.dist_dir, "root", "python2", "lib"))
sh.rm("-rf", "pkgconfig")
sh.rm("libpython2.7.a")
os.chdir(join(self.ctx.dist_dir, "root", "python2", "lib", "python2.7"))
sh.find(".", "-iname", "*.pyc", "-exec", "rm", "{}", ";")
sh.find(".", "-iname", "*.py", "-exec", "rm", "{}", ";")
sh.rm("-rf", "wsgiref", "bsddb", "curses", "idlelib", "hotshot")
sh.rm("-rf", sh.glob("lib*"))
# now create the zip.
logger.info("Create a python27.zip")
sh.rm("config/libpython2.7.a")
sh.rm("config/python.o")
sh.rm("config/config.c.in")
sh.rm("config/makesetup")
sh.rm("config/install-sh")
sh.mv("config", "..")
sh.mv("site-packages", "..")
sh.zip("-r", "../python27.zip", sh.glob("*"))
sh.rm("-rf", sh.glob("*"))
sh.mv("../config", ".")
sh.mv("../site-packages", ".")
finally:
os.chdir(oldpwd)
recipe = Python2Recipe()

View file

@ -1,12 +0,0 @@
'''
Stub functions for _scproxy on iOS
No proxy is supported yet.
'''
def _get_proxy_settings():
return {'exclude_simple': 1}
def _get_proxies():
return {}

View file

@ -1,34 +0,0 @@
--- Python2.7-old/Modules/_ctypes/cfield.c 2010-05-09 16:46:46.000000000 +0200
+++ Python2.7-new/Modules/_ctypes/cfield.c 2013-08-27 00:21:15.000000000 +0200
@@ -1747,24 +1747,6 @@
} ffi_type;
*/
-/* align and size are bogus for void, but they must not be zero */
-ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID };
-
-ffi_type ffi_type_uint8 = { 1, 1, FFI_TYPE_UINT8 };
-ffi_type ffi_type_sint8 = { 1, 1, FFI_TYPE_SINT8 };
-
-ffi_type ffi_type_uint16 = { 2, 2, FFI_TYPE_UINT16 };
-ffi_type ffi_type_sint16 = { 2, 2, FFI_TYPE_SINT16 };
-
-ffi_type ffi_type_uint32 = { 4, 4, FFI_TYPE_UINT32 };
-ffi_type ffi_type_sint32 = { 4, 4, FFI_TYPE_SINT32 };
-
-ffi_type ffi_type_uint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_UINT64 };
-ffi_type ffi_type_sint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_SINT64 };
-
-ffi_type ffi_type_float = { sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT };
-ffi_type ffi_type_double = { sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE };
-
#ifdef ffi_type_longdouble
#undef ffi_type_longdouble
#endif
@@ -1772,6 +1754,4 @@
ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN,
FFI_TYPE_LONGDOUBLE };
-ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER };
-
/*---------------- EOF ----------------*/

View file

@ -1,17 +0,0 @@
diff -Naur Python-2.7.1.orig/Modules/_ctypes/cfield.c Python-2.7.1/Modules/_ctypes/cfield.c
--- Python-2.7.1.orig/Modules/_ctypes/cfield.c 2015-02-11 13:00:42.000000000 +0100
+++ Python-2.7.1/Modules/_ctypes/cfield.c 2015-02-11 13:01:12.000000000 +0100
@@ -1747,11 +1747,12 @@
} ffi_type;
*/
+#if 0
#ifdef ffi_type_longdouble
#undef ffi_type_longdouble
#endif
/* This is already defined on OSX */
ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN,
FFI_TYPE_LONGDOUBLE };
-
+#endif
/*---------------- EOF ----------------*/

View file

@ -1,24 +0,0 @@
--- Python-2.7.1/Python/dynload_shlib.c.orig 2011-12-05 00:00:00.000000000 +0100
+++ Python-2.7.1/Python/dynload_shlib.c 2011-12-05 00:02:51.000000000 +0100
@@ -84,6 +84,15 @@
PyOS_snprintf(funcname, sizeof(funcname),
LEAD_UNDERSCORE "init%.200s", shortname);
+ /* On IOS, dlopen crash as soon as we try to open one of our library.
+ * Instead, we have done a redirection of linking to convert our .so into a
+ * .a. Then the main executable is linked with theses symbol. So, instead
+ * of trying to dlopen, directly do the dlsym.
+ * -- Mathieu
+ */
+ return (dl_funcptr) dlsym(RTLD_SELF, funcname);
+
+#if 0
if (fp != NULL) {
int i;
struct stat statb;
@@ -140,4 +149,5 @@
handles[nhandles++].handle = handle;
p = (dl_funcptr) dlsym(handle, funcname);
return p;
+#endif
}

View file

@ -1,24 +0,0 @@
Index: Modules/posixmodule.c
===================================================================
--- Modules/posixmodule.c (revision 52827)
+++ Modules/posixmodule.c (working copy)
@@ -314,7 +314,7 @@
#endif
/* Return a dictionary corresponding to the POSIX environment table */
-#ifdef WITH_NEXT_FRAMEWORK
+#ifdef __APPLE__
/* On Darwin/MacOSX a shared library or framework has no access to
** environ directly, we must obtain it with _NSGetEnviron().
*/
@@ -332,7 +332,7 @@
d = PyDict_New();
if (d == NULL)
return NULL;
-#ifdef WITH_NEXT_FRAMEWORK
+#ifdef __APPLE__
if (environ == NULL)
environ = *_NSGetEnviron();
#endif

View file

@ -1,63 +0,0 @@
--- Python-2.7.1.orig/configure.in 2017-05-14 19:54:10.000000000 +0200
+++ Python-2.7.1/configure.in 2017-05-14 19:56:01.000000000 +0200
@@ -3111,17 +3111,17 @@
AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
-if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
-then
- if test $ipv6 = yes
- then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- fi
-else
- AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
-fi
+# if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
+# then
+# if test $ipv6 = yes
+# then
+# echo 'Fatal: You must get working getaddrinfo() function.'
+# echo ' or you can specify "--disable-ipv6"'.
+# exit 1
+# fi
+# else
+# AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
+# fi
AC_CHECK_FUNCS(getnameinfo)
--- Python-2.7.1.orig/configure 2017-05-14 20:22:04.000000000 +0200
+++ Python-2.7.1/configure 2017-05-14 20:22:03.000000000 +0200
@@ -10802,19 +10802,19 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_buggy_getaddrinfo" >&5
$as_echo "$ac_cv_buggy_getaddrinfo" >&6; }
-if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
-then
- if test $ipv6 = yes
- then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- fi
-else
+# if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
+# then
+# if test $ipv6 = yes
+# then
+# echo 'Fatal: You must get working getaddrinfo() function.'
+# echo ' or you can specify "--disable-ipv6"'.
+# exit 1
+# fi
+# else
$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h
-fi
+# fi
for ac_func in getnameinfo
do :

View file

@ -1,16 +0,0 @@
Index: Python-2.7.1/Modules/posixmodule.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- Python-2.7.1/Modules/posixmodule.c (date 1290868829000)
+++ Python-2.7.1/Modules/posixmodule.c (revision )
@@ -2644,7 +2644,7 @@
#endif
}
-
+#undef HAVE_SYSTEM
#ifdef HAVE_SYSTEM
PyDoc_STRVAR(posix_system__doc__,
"system(command) -> exit_status\n\n\

View file

@ -1,159 +0,0 @@
--- Python2.7-old/pyconfig.h 2013-08-26 19:26:05.000000000 +0200
+++ Python2.7-new/pyconfig.h 2013-08-27 00:11:06.000000000 +0200
@@ -72,7 +72,7 @@
/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
-#define HAVE_BIND_TEXTDOMAIN_CODESET 1
+/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */
/* Define to 1 if you have the <bluetooth/bluetooth.h> header file. */
/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */
@@ -218,7 +218,7 @@
/* #undef HAVE_FDATASYNC */
/* Define to 1 if you have the `finite' function. */
-#define HAVE_FINITE 1
+/* #undef HAVE_FINITE */
/* Define to 1 if you have the `flock' function. */
#define HAVE_FLOCK 1
@@ -233,7 +233,7 @@
#define HAVE_FPATHCONF 1
/* Define to 1 if you have the `fseek64' function. */
-#define HAVE_FSEEK64 1
+/* #undef HAVE_FSEEK64 */
/* Define to 1 if you have the `fseeko' function. */
#define HAVE_FSEEKO 1
@@ -245,7 +245,7 @@
#define HAVE_FSYNC 1
/* Define to 1 if you have the `ftell64' function. */
-#define HAVE_FTELL64 1
+/* #undef HAVE_FTELL64 */
/* Define to 1 if you have the `ftello' function. */
#define HAVE_FTELLO 1
@@ -260,7 +260,7 @@
#define HAVE_GAI_STRERROR 1
/* Define to 1 if you have the `gamma' function. */
-#define HAVE_GAMMA 1
+/* #undef HAVE_GAMMA */
/* Define if we can use gcc inline assembler to get and set x87 control word
*/
@@ -279,10 +279,10 @@
#define HAVE_GETGROUPS 1
/* Define to 1 if you have the `gethostbyname' function. */
-/* #undef HAVE_GETHOSTBYNAME */
+#define HAVE_GETHOSTBYNAME 1
/* Define this if you have some version of gethostbyname_r() */
-#define HAVE_GETHOSTBYNAME_R 1
+/* #undef HAVE_GETHOSTBYNAME_R */
/* Define this if you have the 3-arg version of gethostbyname_r(). */
/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */
@@ -291,7 +291,7 @@
/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */
/* Define this if you have the 6-arg version of gethostbyname_r(). */
-#define HAVE_GETHOSTBYNAME_R_6_ARG 1
+/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */
/* Define to 1 if you have the `getitimer' function. */
#define HAVE_GETITIMER 1
@@ -327,19 +327,19 @@
#define HAVE_GETPWENT 1
/* Define to 1 if you have the `getresgid' function. */
-#define HAVE_GETRESGID 1
+/* #undef HAVE_GETRESGID */
/* Define to 1 if you have the `getresuid' function. */
-#define HAVE_GETRESUID 1
+/* #undef HAVE_GETRESUID */
/* Define to 1 if you have the `getsid' function. */
#define HAVE_GETSID 1
/* Define to 1 if you have the `getspent' function. */
-#define HAVE_GETSPENT 1
+/* #undef HAVE_GETSPENT */
/* Define to 1 if you have the `getspnam' function. */
-#define HAVE_GETSPNAM 1
+/* #undef HAVE_GETSPNAM */
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
@@ -465,7 +465,7 @@
#define HAVE_MKTIME 1
/* Define to 1 if you have the `mremap' function. */
-#define HAVE_MREMAP 1
+/* #undef HAVE_MREMAP */
/* Define to 1 if you have the <ncurses.h> header file. */
/* #undef HAVE_NCURSES_H */
@@ -492,7 +492,7 @@
#define HAVE_PAUSE 1
/* Define to 1 if you have the `plock' function. */
-#define HAVE_PLOCK 1
+/* #undef HAVE_PLOCK */
/* Define to 1 if you have the `poll' function. */
#define HAVE_POLL 1
@@ -567,7 +567,7 @@
#define HAVE_SEM_OPEN 1
/* Define to 1 if you have the `sem_timedwait' function. */
-#define HAVE_SEM_TIMEDWAIT 1
+/* #undef HAVE_SEM_TIMEDWAIT */
/* Define to 1 if you have the `sem_unlink' function. */
#define HAVE_SEM_UNLINK 1
@@ -600,10 +600,10 @@
#define HAVE_SETREGID 1
/* Define to 1 if you have the `setresgid' function. */
-#define HAVE_SETRESGID 1
+/* #undef HAVE_SETRESGID */
/* Define to 1 if you have the `setresuid' function. */
-#define HAVE_SETRESUID 1
+/* #undef HAVE_SETRESUID */
/* Define to 1 if you have the `setreuid' function. */
#define HAVE_SETREUID 1
@@ -829,7 +829,7 @@
#define HAVE_TMPNAM 1
/* Define to 1 if you have the `tmpnam_r' function. */
-#define HAVE_TMPNAM_R 1
+/* #undef HAVE_TMPNAM_R */
/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
`HAVE_STRUCT_TM_TM_ZONE' instead. */
@@ -894,7 +894,7 @@
#define HAVE_ZLIB_COPY 1
/* Define to 1 if you have the `_getpty' function. */
-#define HAVE__GETPTY 1
+/* #undef HAVE__GETPTY */
/* Define if you are using Mach cthreads directly under /include */
/* #undef HURD_C_THREADS */
@@ -1245,5 +1245,4 @@
#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
#endif
-#endif /*Py_PYCONFIG_H*/
-
+#endif /*Py_PYCONFIG_H*/
\ No newline at end of file

View file

@ -1,11 +0,0 @@
--- Python-2.7.1/setup.py.orig 2013-10-25 17:28:03.000000000 +0200
+++ Python-2.7.1/setup.py 2013-10-25 17:27:56.000000000 +0200
@@ -87,7 +87,7 @@
f = os.path.join(sysroot, dir[1:], filename)
if os.path.exists(f):
- return [dir]
+ return [os.path.dirname(f)]
# Not found anywhere
return None

View file

@ -1,17 +0,0 @@
diff -Naur Python-2.7.1.orig/Include/pyport.h Python-2.7.1/Include/pyport.h
--- Python-2.7.1.orig/Include/pyport.h 2010-09-14 18:10:22.000000000 +0200
+++ Python-2.7.1/Include/pyport.h 2011-05-13 12:24:53.000000000 +0200
@@ -186,9 +186,11 @@
#endif
/* Largest positive value of type Py_ssize_t. */
-#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
+//#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
/* Smallest negative value of type Py_ssize_t. */
-#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
+//#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
+#define PY_SSIZE_T_MAX TMP_MAX
+#define PY_SSIZE_T_MIN -TMP_MAX
#if SIZEOF_PID_T > SIZEOF_LONG
# error "Python doesn't support sizeof(pid_t) > sizeof(long)"

View file

@ -1,25 +0,0 @@
--- Python-2.7.1/Modules/_sqlite/module.c.orig 2012-10-28 02:30:58.000000000 +0200
+++ Python-2.7.1/Modules/_sqlite/module.c 2012-10-28 02:28:12.000000000 +0200
@@ -28,6 +28,9 @@
#include "prepare_protocol.h"
#include "microprotocols.h"
#include "row.h"
+#ifndef MODULE_NAME
+#define MODULE_NAME "_sqlite3"
+#endif
#if SQLITE_VERSION_NUMBER >= 3003003
#define HAVE_SHARED_CACHE
--- Python-2.7.1/Modules/_sqlite/sqlitecompat.h.orig 2012-10-28 02:30:53.000000000 +0200
+++ Python-2.7.1/Modules/_sqlite/sqlitecompat.h 2012-10-28 02:28:14.000000000 +0200
@@ -26,6 +26,10 @@
#ifndef PYSQLITE_COMPAT_H
#define PYSQLITE_COMPAT_H
+#ifndef MODULE_NAME
+#define MODULE_NAME "_sqlite3"
+#endif
+
/* define Py_ssize_t for pre-2.5 versions of Python */
#if PY_VERSION_HEX < 0x02050000

View file

@ -1,138 +0,0 @@
diff -Naur Python-2.7-old/Makefile.pre.in Python-2.7-new/Makefile.pre.in
--- Python-2.7-old/Makefile.pre.in 2010-04-11 17:10:46.000000000 -0700
+++ Python-2.7-new/Makefile.pre.in 2010-07-09 13:40:47.000000000 -0700
@@ -179,6 +179,7 @@
PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)
+HOSTPYTHON= ./$(BUILDPYTHON)
# The task to run while instrument when building the profile-opt target
PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
@@ -212,6 +213,8 @@
# Parser
PGEN= Parser/pgen$(EXE)
+HOSTPGEN= $(PGEN)
+
POBJS= \
Parser/acceler.o \
Parser/grammar1.o \
@@ -404,8 +407,8 @@
# Build the shared modules
sharedmods: $(BUILDPYTHON)
@case $$MAKEFLAGS in \
- *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
+ *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
+ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
esac
# Build static library
@@ -538,7 +541,7 @@
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
-@$(INSTALL) -d Include
- -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+ -$(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
$(PGEN): $(PGENOBJS)
$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
@@ -919,26 +922,26 @@
done; \
done
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
$(DESTDIR)$(LIBDEST)
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST) -f \
-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
$(DESTDIR)$(LIBDEST)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
-d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
+ $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
# Create the PLATDIR source directory, if one wasn't distributed..
$(srcdir)/Lib/$(PLATDIR):
@@ -1042,8 +1045,10 @@
# Install the dynamically loadable modules
# This goes into $(exec_prefix)
-sharedinstall: sharedmods
- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
+sharedinstall: sharedmods
+ CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
+ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
+ --skip-build \
--prefix=$(prefix) \
--install-scripts=$(BINDIR) \
--install-platlib=$(DESTSHARED) \
diff -Naur Python-2.7-old/setup.py Python-2.7-new/setup.py
--- Python-2.7-old/setup.py 2010-06-27 05:36:16.000000000 -0700
+++ Python-2.7-new/setup.py 2010-07-09 13:54:29.000000000 -0700
@@ -23,6 +23,10 @@
# This global variable is used to hold the list of modules to be disabled.
disabled_module_list = []
+# _ctypes fails to cross-compile due to the libffi configure script.
+if os.environ.has_key('PYTHONXCPREFIX'):
+ disabled_module_list.append('_ctypes')
+
def add_dir_to_list(dirlist, dir):
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
1) 'dir' is not already in 'dirlist'
@@ -278,6 +282,14 @@
(ext.name, sys.exc_info()[1]))
self.failed.append(ext.name)
return
+
+ # Inport check will not work when cross-compiling.
+ if os.environ.has_key('PYTHONXCPREFIX'):
+ self.announce(
+ 'WARNING: skipping inport check for cross-compiled: "%s"' %
+ ext.name)
+ return
+
# Workaround for Mac OS X: The Carbon-based modules cannot be
# reliably imported into a command-line Python
if 'Carbon' in ext.extra_link_args:
--- Python-2.7Orig/configure 2011-04-29 22:30:59.231331437 +1000
+++ Python-2.7/configure 2010-05-29 01:28:47.000000000 +1000
@@ -13517,7 +13517,7 @@
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
- ac_cv_have_long_long_format=no
+ ac_cv_have_long_long_format="cross -- assuming yes"
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -13569,7 +13569,7 @@
$as_echo "$ac_cv_have_long_long_format" >&6; }
fi
-if test "$ac_cv_have_long_long_format" = yes
+if test "$ac_cv_have_long_long_format" != no
then
$as_echo "#define PY_FORMAT_LONG_LONG \"ll\"" >>confdefs.h

View file

@ -16,7 +16,7 @@ class PyYamlRecipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = os.path.join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = os.path.join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = os.path.join(dest_dir, 'lib', 'python3.7', 'site-packages')
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -17,7 +17,7 @@ class WerkzeugRecipe(PythonRecipe):
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
dest_dir = join(self.ctx.dist_dir, "root", "python")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)

View file

@ -10,7 +10,7 @@ class ZbarLightRecipe(Recipe):
version = '1.2'
url = 'https://github.com/Polyconseil/zbarlight/archive/{version}.tar.gz'
library = "zbarlight.a"
depends = ['hostpython2', 'python2', 'libzbar']
depends = ['hostpython3', 'python3', 'libzbar']
pbx_libraries = ["libz", "libbz2", 'libc++', 'libsqlite3', 'CoreMotion']
include_per_arch = True
@ -24,7 +24,7 @@ class ZbarLightRecipe(Recipe):
build_env["ARCH"] = arch.arch
build_env["C_INCLUDE_PATH"] = join(arch.sysroot, "usr", "include")
build_env["LIBRARY_PATH"] = join(arch.sysroot, "usr", "lib")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
build_env["CFLAGS"] = " ".join([
" -I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "libzbar", 'zbar')) +
" -arch {}".format(arch.arch)
@ -44,15 +44,15 @@ class ZbarLightRecipe(Recipe):
arch = list(self.filtered_archs)[0]
build_dir = join(self.get_build_dir(arch.arch), 'build',
'lib.macosx-10.13-x86_64-2.7', 'zbarlight')
dist_dir = join(self.ctx.dist_dir, 'root', 'python2', 'lib',
'python2.7', 'site-packages', 'zbarlight')
dist_dir = join(self.ctx.dist_dir, 'root', 'python3', 'lib',
'python3.7', 'site-packages', 'zbarlight')
# Patch before Copying
# self.apply_patch("zbarlight_1_2.patch")#Issue getting the version, hard coding for now
copy_tree(build_dir, dist_dir)
os.remove(join(dist_dir, '_zbarlight.c'))
def _patch__init__(self):
init = join(self.ctx.dist_dir, 'root', 'python2', 'lib', 'python2.7',
init = join(self.ctx.dist_dir, 'root', 'python3', 'lib', 'python3.7',
'site-packages', 'zbarlight', "__init__.py")
shprint( # noqa: F821
sh.sed, "-i.bak",

View file

@ -709,7 +709,6 @@ class Recipe(object):
hostpython))
logger.error("You can have only one hostpython version compiled")
sys.exit(1)
self.ctx.python_major = version.split('.')[0]
self.ctx.hostpython_ver = version
self.ctx.hostpython_recipe = instance
@ -1388,9 +1387,9 @@ pip Install a pip dependency into the distribution
ensure_recipes_loaded(ctx)
if not hasattr(ctx, "python_ver"):
logger.error("No python recipes compiled!")
logger.error("You must have compiled at least python2 or")
logger.error("python3 recipes to be able to create a project.")
logger.error("No python recipe compiled!")
logger.error("You must have compiled at least python3")
logger.error("recipe to be able to create a project.")
sys.exit(1)
template_dir = join(curdir, "tools", "templates")
@ -1402,8 +1401,6 @@ pip Install a pip dependency into the distribution
"project_dir": realpath(args.directory),
"version": "1.0.0",
"dist_dir": ctx.dist_dir,
"python_version": ctx.python_ver,
"python_major": ctx.python_major
}
cookiecutter(template_dir, no_input=True, extra_context=context)
filename = join(

View file

@ -5,7 +5,5 @@
"kivy_dir": "",
"project_dir": "",
"version": "1.0.0",
"dist_dir": "",
"python_version": "",
"python_major": ""
"dist_dir": ""
}

View file

@ -33,8 +33,8 @@
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
2CB5F34517D5233A006187AB /* bridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bridge.h; sourceTree = SOURCE_ROOT; };
2CB5F34617D5233A006187AB /* bridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = bridge.m; sourceTree = SOURCE_ROOT; };
59738AB41A8BB5D8001B2C0C /* lib */ = {isa = PBXFileReference; lastKnownFileType = folder; name = lib; path = {{ cookiecutter.dist_dir }}/root/python{{ cookiecutter.python_major }}/lib; sourceTree = "<group>"; };
59FDEA8A21E7D34E004E6ECE /* include */ = {isa = PBXFileReference; lastKnownFileType = folder; name = include; path = {{ cookiecutter.dist_dir }}/root/python{{ cookiecutter.python_major }}/include; sourceTree = "<group>"; };
59738AB41A8BB5D8001B2C0C /* lib */ = {isa = PBXFileReference; lastKnownFileType = folder; name = lib; path = {{ cookiecutter.dist_dir }}/root/python3/lib; sourceTree = "<group>"; };
59FDEA8A21E7D34E004E6ECE /* include */ = {isa = PBXFileReference; lastKnownFileType = folder; name = include; path = {{ cookiecutter.dist_dir }}/root/python3/include; sourceTree = "<group>"; };
59738ABA1A8E19AA001B2C0C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = {{ cookiecutter.project_name }}/Images.xcassets; sourceTree = "<group>"; };
59738AD01A8E62D6001B2C0C /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "LaunchImages/Default-568h@2x.png"; sourceTree = "<group>"; };
59738AD11A8E62D6001B2C0C /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-667h@2x.png"; path = "LaunchImages/Default-667h@2x.png"; sourceTree = "<group>"; };
@ -234,11 +234,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
{%- if cookiecutter.python_major == "2" %}
shellScript = "{{ cookiecutter.dist_dir }}/hostpython2/bin/python -OO -m compileall \"$PROJECT_DIR\"/YourApp";
{%- else %}
shellScript = "{{ cookiecutter.dist_dir }}/hostpython3/bin/python -m compileall -f -b \"$PROJECT_DIR\"/YourApp";
{%- endif %}
};
/* End PBXShellScriptBuildPhase section */
@ -254,11 +250,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
{%- if cookiecutter.python_major == "2" %}
shellScript = "find \"$PROJECT_DIR\"/YourApp/ -regex '.*\\.py[c]*' -delete";
{%- else %}
shellScript = "find \"$PROJECT_DIR\"/YourApp/ -regex '.*\\.py' -delete";
{%- endif %}
};
/* End PBXShellScriptBuildPhase section */

View file

@ -16,7 +16,7 @@ def recursive_include(module):
setup(
name="kivy-ios",
version="1.1.0",
version="1.1.0.dev0",
description="Kivy for iOS",
long_description=read("README.md"),
long_description_content_type="text/markdown",