1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Compare commits

...

4 commits

Author SHA1 Message Date
Juhani Numminen
a5d584371e Refactor and comment locale_dir selection 2019-08-20 16:23:05 +03:00
Juhani Numminen
93c9535216 Detect LANG for gettext on android 2019-08-20 11:54:49 +03:00
Juhani Numminen
8bef9848a5 setup*.py: Install locale/ also on macOS and Windows 2019-08-20 11:54:49 +03:00
lb@lb7520
bd4be45118 Changes to apk build procedures used with fdroid build.
- mkp4a.init: 1 optional parameter
- mkp4a.unsigned: 2 paramters (sdk and ndk paths)
- mkp4a.preload: new helper script
2019-08-20 10:04:55 +02:00
7 changed files with 96 additions and 40 deletions

View file

@ -45,14 +45,11 @@ Prerequisites (needs root):
Build with 'python-for-android' (as user):
Use the repo or an unpacked distribution tarball.
$ python setup.py install
$ make dist (if using the repo)
Use the cloned repo or an unpacked distribution tarball.
go to the android directory, then
$ ./mkp4a.init [<sdkdir>] [<ndkdir>] # prepare sdk and p4a installation
$ ./mkp4a.init # prepare sdk and p4a installation
$ ./mkkeystore # if you want to build a release version.
$ ./mkp4a.debug # build debug apk

View file

@ -3,17 +3,25 @@ set -eux
. mkp4a.common
# NOTE: $1 will be set with fdroid builds only.
echo '### prepare sdk'
./initsdk
if [[ $# == 0 ]]
then
./initsdk
fi
echo '### install p4a'
python3 -m pip install -q --user python-for-android
if [[ $# == 0 ]]
then
python3 -m pip install -q --user python-for-android
fi
echo '### prepare source'
(cd .. && make rules)
(cd .. && make rules && make all_games_html && make mo)
mkdir -p ${tmpdir}
rm -rf ${tmpdir}

27
android/mkp4a.preload Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
# package preload helper for fdroid build.
set -eux
if [[ $# < 3 ]]
then
exit 1
fi
packagebase=${HOME}'/.local/share/python-for-android/packages'
packagedir=${packagebase}/$1
packageurl=$2
packagename=$3
packagemark='.mark-'${packagename}
if [[ $# == 4 ]]
then
packagemark='.mark'$4
fi
mkdir -p ${packagedir}
cd ${packagedir}
wget -nv ${packageurl}/${packagename}
touch ${packagemark}

View file

@ -3,8 +3,18 @@ set -eux
. mkp4a.common
# NOTE: $1 and $2 (sdk and ndk) used with fdroid build only.
if [[ $# == 2 ]]
then
sdkdir=$1
ndkdir=$2
fi
python3 -m pythonforandroid.toolchain apk \
${p4a_options} \
--sdk-dir ${sdkdir} \
--ndk-dir ${ndkdir} \
--release
# python3 -m pythonforandroid.toolchain apk

View file

@ -27,6 +27,11 @@ import os
import subprocess
import sys
try:
import jnius
except ImportError:
jnius = None
import pysollib.settings
# ************************************************************************
@ -36,27 +41,31 @@ import pysollib.settings
def init():
if os.name == 'nt' and 'LANG' not in os.environ:
try:
loc = locale.getdefaultlocale()
os.environ['LANG'] = loc[0]
except Exception:
pass
# locale.setlocale(locale.LC_ALL, '')
if 'LANG' not in os.environ:
if os.name == 'nt':
lang, enc = locale.getdefaultlocale()
os.environ['LANG'] = lang
elif jnius: # android
Locale = jnius.autoclass('java.util.Locale')
os.environ['LANG'] = Locale.getDefault().getLanguage()
locale.setlocale(locale.LC_ALL, '')
# install gettext
# locale_dir = 'locale'
locale_dir = None
if os.path.isdir(sys.path[0]):
d = os.path.join(sys.path[0], 'locale')
else:
# i.e. library.zip
d = os.path.join(os.path.dirname(sys.path[0]), 'locale')
if os.path.exists(d) and os.path.isdir(d):
locale_dir = d
# if locale_dir: locale_dir = os.path.normpath(locale_dir)
# gettext.install('pysol', locale_dir, unicode=True) # ngettext don't work
gettext.bindtextdomain('pysol', locale_dir)
locale_locations = (
# locale/ next to the pysol.py script
sys.path[0],
# locale/ next to library.zip (py2exe)
os.path.dirname(sys.path[0]),
# locale/ in curdir (works for e.g. py2app)
os.curdir)
# leaving the domain unbound means sys.prefix+'/share/locale'
for par in locale_locations:
locale_dir = os.path.join(par, 'locale')
if os.path.isdir(locale_dir):
gettext.bindtextdomain('pysol', locale_dir)
break
gettext.textdomain('pysol')
# debug

View file

@ -2,7 +2,6 @@
# -*- mode: python; -*-
import os
from glob import glob
from pysollib.settings import PACKAGE_URL
from pysollib.settings import VERSION
@ -12,12 +11,22 @@ from setuptools import setup
if os.name == 'nt':
import py2exe # noqa: F401
def get_data_files(source, destination):
"""Iterates over all files under the given tree, to install them to the
destination using the data_files keyword of setuptools.setup."""
for path, _, files in os.walk(source):
files = [os.path.join(path, f) for f in files]
path = path.replace(source, destination, 1)
yield (path, files)
if os.name == 'posix':
data_dir = 'share/PySolFC'
elif os.name == 'nt':
data_dir = 'data'
locale_dir = 'share/locale'
else:
data_dir = 'data'
locale_dir = 'locale'
ddirs = [
'html',
@ -35,21 +44,16 @@ for s in open('MANIFEST.in'):
data_files = []
for d in ddirs:
for root, dirs, files in os.walk(os.path.join('data', d)):
if root.find('.svn') >= 0:
continue
if files:
# files = map(lambda f: os.path.join(root, f), files)
files = [os.path.join(root, f) for f in files]
data_files.append((os.path.join(data_dir, root[5:]), files))
data_files += get_data_files(os.path.join('data', d),
os.path.join(data_dir, d))
data_files += get_data_files('locale', locale_dir)
if os.name == 'posix':
data_files.append(('share/pixmaps', ['data/pysol.xbm', 'data/pysol.xpm']))
for size in os.listdir('data/images/icons'):
data_files.append(('share/icons/hicolor/%s/apps' % size,
['data/images/icons/%s/pysol.png' % size]))
for mofile in glob('locale/*/*/*.mo'):
data_files.append(('share/' + os.path.dirname(mofile), [mofile]))
data_files.append((data_dir, ['data/pysolfc.glade']))
data_files.append(('share/applications', ['data/pysol.desktop']))

View file

@ -52,7 +52,8 @@ PLIST = dict(
)
APP = ['pysol.py']
ICON_FILE = 'data/PySol.icns'
DATA_FILES = ['docs', 'data', 'scripts', 'COPYING', 'README.md'] + SOLVER
DATA_FILES = ['docs', 'data', 'locale', 'scripts', 'COPYING', 'README.md',
] + SOLVER
RESOURCES = []
FRAMEWORKS = [SOLVER_LIB_PATH] if SOLVER_LIB_PATH else []
OPTIONS = dict(argv_emulation=True,