Skip to content

Commit

Permalink
first pass with a brand new tool. starting to write the hostpython re…
Browse files Browse the repository at this point in the history
…cipe
  • Loading branch information
tito committed Feb 1, 2015
1 parent 55345e1 commit 577dea0
Show file tree
Hide file tree
Showing 17 changed files with 850 additions and 0 deletions.
Empty file added recipes/__init__.py
Empty file.
Binary file added recipes/__init__.pyc
Binary file not shown.
7 changes: 7 additions & 0 deletions recipes/audiostream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from toolchain import Recipe

class AudiostreamRecipe(Recipe):
version = "master"
url = "https://github.com/kivy/audiostream/archive/{version}.zip"

recipe = AudiostreamRecipe()
52 changes: 52 additions & 0 deletions recipes/hostpython/ModulesSetup
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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
2 changes: 2 additions & 0 deletions recipes/hostpython/ModulesSetup.mobile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ctypes
_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c -I$(srcdir)/../../build/include/ffi
40 changes: 40 additions & 0 deletions recipes/hostpython/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from toolchain import Recipe, shprint
from os.path import join
import sh

class HostpythonRecipe(Recipe):
version = "2.7.1"
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2"

def prebuild_arch(self, arch):
# common to all archs
if not self.has_marker("patched"):
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.copy_file("Setup.dist", "Modules/Setup.dist")
self.set_marker("patched")
super(HostpythonRecipe, self).prebuild_arch(arch)

def build_i386(self):
sdk_path = sh.xcrun(
"--sdk", "macosx",
"--show-sdk-path").splitlines()[0]

build_env = self.ctx.env.copy()
build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics"
build_env["LDFLAGS"] = "-lsqlite3"
build_env["CFLAGS"] = "--sysroot={}".format(sdk_path)
build_env["PWD"] = self.build_dir
configure = sh.Command(join(self.build_dir, "configure"))
print "-->"
shprint(configure, _env=build_env)
sh.make("-C", self.build_dir, "-j4", "python.exe", "Parser/pgen")
print "<--"




recipe = HostpythonRecipe()
Binary file added recipes/hostpython/__init__.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions recipes/hostpython/_scproxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'''
Stub functions for _scproxy on iOS
No proxy is supported yet.
'''

def _get_proxy_settings():
return {'exclude_simple': 1}

def _get_proxies():
return {}
34 changes: 34 additions & 0 deletions recipes/hostpython/ctypes_duplicate.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- 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 ----------------*/
24 changes: 24 additions & 0 deletions recipes/hostpython/dynload.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- 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
}
24 changes: 24 additions & 0 deletions recipes/hostpython/environ_symbol_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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


159 changes: 159 additions & 0 deletions recipes/hostpython/pyconfig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
--- 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
11 changes: 11 additions & 0 deletions recipes/hostpython/setuppath.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- 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
17 changes: 17 additions & 0 deletions recipes/hostpython/ssize-t-max.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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)"
Loading

0 comments on commit 577dea0

Please sign in to comment.