8000 add mysqldb/libmysqlclient recipes · kived/python-for-android@c3c7cca · GitHub
[go: up one dir, main page]

Skip to content

Commit c3c7cca

Browse files
committed
add mysqldb/libmysqlclient recipes
1 parent fdb2b5f commit c3c7cca

File tree

9 files changed

+174
-0
lines changed

9 files changed

+174
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
asdgasdgasdg
2+
asdg
3+
asdg
4+
include(${CMAKE_ROOT}/Modules/Platform/Linux.cmake)
5+
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from pythonforandroid.logger import shprint
2+
from pythonforandroid.recipe import Recipe
3+
from pythonforandroid.util import current_directory
4+
import sh
5+
from os.path import join
6+
7+
8+
class LibmysqlclientRecipe(Recipe):
9+
name = 'libmysqlclient'
10+
version = 'master'
11+
url = 'https://github.com/0x-ff/libmysql-android/archive/{version}.zip'
12+
# version = '5.5.47'
13+
# url = 'http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-{version}.tar.gz'
14+
#
15+
# depends = ['ncurses']
16+
#
17+
18+
# patches = ['add-custom-platform.patch']
19+
20+
patches = ['disable-soversion.patch']
21+
22+
def should_build(self, arch):
23+
return not self.has_libs(arch, 'libmysql.so')
24+
25+
def build_arch(self, arch):
26+
env = self.get_recipe_env(arch)
27+
with current_directory(join(self.get_build_dir(arch.arch), 'libmysqlclient')):
28+
shprint(sh.cp, '-t', '.', join(self.get_recipe_dir(), 'p4a.cmake'))
29+
# shprint(sh.mkdir, 'Platform')
30+
# shprint(sh.cp, '-t', 'Platform', join(self.get_recipe_dir(), 'Linux.cmake'))
31+
shprint(sh.rm, '-f', 'CMakeCache.txt')
32+
shprint(sh.cmake, '-G', 'Unix Makefiles',
33+
# '-DCMAKE_MODULE_PATH=' + join(self.get_build_dir(arch.arch), & 10000 #39;libmysqlclient'),
34+
'-DCMAKE_INSTALL_PREFIX=./install',
35+
'-DCMAKE_TOOLCHAIN_FILE=p4a.cmake', _env=env)
36+
shprint(sh.make, _env=env)
37+
38+
self.install_libs(arch, join('libmysql', 'libmysql.so'))
39+
40+
# def get_recipe_env(self, arch=None):
41+
# env = super(LibmysqlclientRecipe, self).get_recipe_env(arch)
42+
# env['WITHOUT_SERVER'] = 'ON'
43+
# ncurses = self.get_recipe('ncurses', self)
44+
# # env['CFLAGS'] += ' -I' + join(ncurses.get_build_dir(arch.arch),
45+
# # 'include')
46+
# env['CURSES_LIBRARY'] = join(self.ctx.get_libs_dir(arch.arch), 'libncurses.so')
47+
# env['CURSES_INCLUDE_PATH'] = join(ncurses.get_build_dir(arch.arch),
48+
# 'include')
49+
# return env
50+
#
51+
# def build_arch(self, arch):
52+
# env = self.get_recipe_env(arch)
53+
# with current_directory(self.get_build_dir(arch.arch)):
54+
# # configure = sh.Command('./configure')
55+
# # TODO: should add openssl as an optional dep and compile support
56+
# # shprint(configure, '--enable-shared', '--enable-assembler',
57+
# # '--enable-thread-safe-client', '--with-innodb',
58+
# # '--without-server', _env=env)
59+
# # shprint(sh.make, _env=env)
60+
# shprint(sh.cmake, '.', '-DCURSES_LIBRARY=' + env['CURSES_LIBRARY'],
61+
# '-DCURSES_INCLUDE_PATH=' + env['CURSES_INCLUDE_PATH'], _env=env)
62+
# shprint(sh.make, _env=env)
63+
#
64+
# self.install_libs(arch, 'libmysqlclient.so')
65+
66+
67+
recipe = LibmysqlclientRecipe()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--- libmysqlclient/libmysqlclient/libmysql/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
2+
+++ b/libmysqlclient/libmysql/CMakeLists.txt 2016-01-11 13:28:51.142356988 -0600
3+
@@ -152,3 +152,5 @@
4+
${CMAKE_SOURCE_DIR}/libmysql/libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX}
5+
DESTINATION "lib")
6+
ENDIF(WIN32)
7+
+
8+
+LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_PREFIX}")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- libmysqlclient/libmysqlclient/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
2+
+++ b/libmysqlclient/CMakeLists.txt 2016-01-11 13:48:41.672323738 -0600
3+
@@ -24,6 +24,8 @@
4+
SET(CMAKE_BUILD_TYPE "Release")
5+
ENDIF(NOT CMAKE_BUILD_TYPE)
6+
7+
+SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")
8+
+
9+
# This reads user configuration, generated by configure.js.
10+
IF(WIN32 AND EXISTS ${CMAKE_SOURCE_DIR}/win/configure.data)
11+
INCLUDE(${CMAKE_SOURCE_DIR}/win/configure.data)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- libmysqlclient/libmysqlclient/libmysql/CMakeLists.txt 2013-02-27 00:25:45.000000000 -0600
2+
+++ b/libmysqlclient/libmysql/CMakeLists.txt 2016-01-11 14:00:26.729332913 -0600
3+
@@ -97,9 +97,6 @@
4+
ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} libmysql.def)
5+
TARGET_LINK_LIBRARIES(libmysql ${CMAKE_THREAD_LIBS_INIT})
6+
STRING(REGEX REPLACE "\\..+" "" LIBMYSQL_SOVERSION ${SHARED_LIB_VERSION})
7+
-SET_TARGET_PROPERTIES(libmysql
8+
- PROPERTIES VERSION ${SHARED_LIB_VERSION}
9+
- SOVERSION ${LIBMYSQL_SOVERSION})
10+
IF(OPENSSL_LIBRARIES)
11+
TARGET_LINK_LIBRARIES(libmysql ${OPENSSL_LIBRARIES} ${OPENSSL_LIBCRYPTO})
12+
ENDIF(OPENSSL_LIBRARIES)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
2+
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
3+
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
2+
from os.path import join
3+
4+
5+
class MysqldbRecipe(CompiledComponentsPythonRecipe):
6+
name = 'mysqldb'
7+
version = '1.2.5'
8+
url = 'https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-{version}.zip'
9+
site_packages_name = 'MySQLdb'
10+
11+
depends = ['python2', 'setuptools', 'libmysqlclient']
12+
13+
patches = ['override-mysql-config.patch',
14+
'disable-zip.patch']
15+
16+
# call_hostpython_via_targetpython = False
17+
18+
def get_recipe_env(self, arch=None):
19+
env = super(MysqldbRecipe, self).get_recipe_env(arch)
20+
21+
hostpython = self.get_recipe('hostpython2', self.ctx)
22+
# TODO: fix hardcoded path
23+
env['PYTHONPATH'] = (join(hostpython.get_build_dir(arch.arch),
24+
'build', 'lib.linux-x86_64-2.7') +
25+
':' + env.get('PYTHONPATH', ''))
26+
27+
libmysql = self.get_recipe('libmysqlclient', self.ctx)
28+
mydir = join(libmysql.get_build_dir(arch.arch), 'libmysqlclient')
29+
# env['CFLAGS'] += ' -I' + join(mydir, 'include')
30+
# env['LDFLAGS'] += ' -L' + join(mydir)
31+
libdir = self.ctx.get_libs_dir(arch.arch)
32+
env['MYSQL_libs'] = env['MYSQL_libs_r'] = '-L' + libdir + ' -lmysql'
33+
env['MYSQL_cflags'] = env['MYSQL_include'] = '-I' + join(mydir,
34+
'include')
35+
36+
return env
37+
38+
39+
recipe = MysqldbRecipe()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--- mysqldb/setup.py 2014-01-02 13:52:50.000000000 -0600
2+
+++ b/setup.py 2016-01-11 15:25:09.375114016 -0600
3+
@@ -18,4 +18,5 @@
4+
metadata['ext_modules'] = [
5+
setuptools.Extension(sources=['_mysql.c'], **options)]
6+
metadata['long_description'] = metadata['long_description'].replace(r'\n', '')
7+
+metadata['zip_safe'] = False
8+
setuptools.setup(**metadata)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--- mysqldb/setup_posix.py 2014-01-02 13:52:50.000000000 -0600
2+
+++ b/setup_posix.py 2016-01-11 14:38:33.603528571 -0600
3+
@@ -13,17 +13,7 @@
4+
return "-%s" % f
5+
6+
def mysql_config(what):
7+
- from os import popen
8+
-
9+
- f = popen("%s --%s" % (mysql_config.path, what))
10+
- data = f.read().strip().split()
11+
- ret = f.close()
12+
- if ret:
13+
- if ret/256:
14+
- data = []
15+
- if ret/256 > 1:
16+
- raise EnvironmentError("%s not found" % (mysql_config.path,))
17+
- return data
18+
+ return os.environ['MYSQL_' + what.replace('-', '_')].strip().split()
19+
mysql_config.path = "mysql_config"
20+
21+
def get_config():

0 commit comments

Comments
 (0)
0