mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Compare commits
4 commits
a8dbceec93
...
a5d584371e
Author | SHA1 | Date | |
---|---|---|---|
|
a5d584371e | ||
|
93c9535216 | ||
|
8bef9848a5 | ||
|
bd4be45118 |
7 changed files with 96 additions and 40 deletions
|
@ -45,14 +45,11 @@ Prerequisites (needs root):
|
||||||
|
|
||||||
Build with 'python-for-android' (as user):
|
Build with 'python-for-android' (as user):
|
||||||
|
|
||||||
Use the repo or an unpacked distribution tarball.
|
Use the cloned repo or an unpacked distribution tarball.
|
||||||
|
|
||||||
$ python setup.py install
|
|
||||||
$ make dist (if using the repo)
|
|
||||||
|
|
||||||
go to the android directory, then
|
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.
|
$ ./mkkeystore # if you want to build a release version.
|
||||||
|
|
||||||
$ ./mkp4a.debug # build debug apk
|
$ ./mkp4a.debug # build debug apk
|
||||||
|
|
|
@ -3,17 +3,25 @@ set -eux
|
||||||
|
|
||||||
. mkp4a.common
|
. mkp4a.common
|
||||||
|
|
||||||
|
# NOTE: $1 will be set with fdroid builds only.
|
||||||
|
|
||||||
echo '### prepare sdk'
|
echo '### prepare sdk'
|
||||||
|
|
||||||
./initsdk
|
if [[ $# == 0 ]]
|
||||||
|
then
|
||||||
|
./initsdk
|
||||||
|
fi
|
||||||
|
|
||||||
echo '### install p4a'
|
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'
|
echo '### prepare source'
|
||||||
|
|
||||||
(cd .. && make rules)
|
(cd .. && make rules && make all_games_html && make mo)
|
||||||
|
|
||||||
mkdir -p ${tmpdir}
|
mkdir -p ${tmpdir}
|
||||||
rm -rf ${tmpdir}
|
rm -rf ${tmpdir}
|
||||||
|
|
27
android/mkp4a.preload
Executable file
27
android/mkp4a.preload
Executable 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}
|
|
@ -3,8 +3,18 @@ set -eux
|
||||||
|
|
||||||
. mkp4a.common
|
. 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 \
|
python3 -m pythonforandroid.toolchain apk \
|
||||||
${p4a_options} \
|
${p4a_options} \
|
||||||
|
--sdk-dir ${sdkdir} \
|
||||||
|
--ndk-dir ${ndkdir} \
|
||||||
--release
|
--release
|
||||||
|
|
||||||
# python3 -m pythonforandroid.toolchain apk
|
# python3 -m pythonforandroid.toolchain apk
|
||||||
|
|
|
@ -27,6 +27,11 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
import jnius
|
||||||
|
except ImportError:
|
||||||
|
jnius = None
|
||||||
|
|
||||||
import pysollib.settings
|
import pysollib.settings
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -36,27 +41,31 @@ import pysollib.settings
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
|
||||||
if os.name == 'nt' and 'LANG' not in os.environ:
|
if 'LANG' not in os.environ:
|
||||||
try:
|
if os.name == 'nt':
|
||||||
loc = locale.getdefaultlocale()
|
lang, enc = locale.getdefaultlocale()
|
||||||
os.environ['LANG'] = loc[0]
|
os.environ['LANG'] = lang
|
||||||
except Exception:
|
elif jnius: # android
|
||||||
pass
|
Locale = jnius.autoclass('java.util.Locale')
|
||||||
# locale.setlocale(locale.LC_ALL, '')
|
os.environ['LANG'] = Locale.getDefault().getLanguage()
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
# install gettext
|
# install gettext
|
||||||
# locale_dir = 'locale'
|
locale_locations = (
|
||||||
locale_dir = None
|
# locale/ next to the pysol.py script
|
||||||
if os.path.isdir(sys.path[0]):
|
sys.path[0],
|
||||||
d = os.path.join(sys.path[0], 'locale')
|
# locale/ next to library.zip (py2exe)
|
||||||
else:
|
os.path.dirname(sys.path[0]),
|
||||||
# i.e. library.zip
|
# locale/ in curdir (works for e.g. py2app)
|
||||||
d = os.path.join(os.path.dirname(sys.path[0]), 'locale')
|
os.curdir)
|
||||||
if os.path.exists(d) and os.path.isdir(d):
|
# leaving the domain unbound means sys.prefix+'/share/locale'
|
||||||
locale_dir = d
|
|
||||||
# if locale_dir: locale_dir = os.path.normpath(locale_dir)
|
for par in locale_locations:
|
||||||
# gettext.install('pysol', locale_dir, unicode=True) # ngettext don't work
|
locale_dir = os.path.join(par, 'locale')
|
||||||
gettext.bindtextdomain('pysol', locale_dir)
|
if os.path.isdir(locale_dir):
|
||||||
|
gettext.bindtextdomain('pysol', locale_dir)
|
||||||
|
break
|
||||||
|
|
||||||
gettext.textdomain('pysol')
|
gettext.textdomain('pysol')
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
|
|
28
setup.py
28
setup.py
|
@ -2,7 +2,6 @@
|
||||||
# -*- mode: python; -*-
|
# -*- mode: python; -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from glob import glob
|
|
||||||
|
|
||||||
from pysollib.settings import PACKAGE_URL
|
from pysollib.settings import PACKAGE_URL
|
||||||
from pysollib.settings import VERSION
|
from pysollib.settings import VERSION
|
||||||
|
@ -12,12 +11,22 @@ from setuptools import setup
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import py2exe # noqa: F401
|
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':
|
if os.name == 'posix':
|
||||||
data_dir = 'share/PySolFC'
|
data_dir = 'share/PySolFC'
|
||||||
elif os.name == 'nt':
|
locale_dir = 'share/locale'
|
||||||
data_dir = 'data'
|
|
||||||
else:
|
else:
|
||||||
data_dir = 'data'
|
data_dir = 'data'
|
||||||
|
locale_dir = 'locale'
|
||||||
|
|
||||||
ddirs = [
|
ddirs = [
|
||||||
'html',
|
'html',
|
||||||
|
@ -35,21 +44,16 @@ for s in open('MANIFEST.in'):
|
||||||
data_files = []
|
data_files = []
|
||||||
|
|
||||||
for d in ddirs:
|
for d in ddirs:
|
||||||
for root, dirs, files in os.walk(os.path.join('data', d)):
|
data_files += get_data_files(os.path.join('data', d),
|
||||||
if root.find('.svn') >= 0:
|
os.path.join(data_dir, d))
|
||||||
continue
|
|
||||||
if files:
|
data_files += get_data_files('locale', locale_dir)
|
||||||
# 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))
|
|
||||||
|
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
data_files.append(('share/pixmaps', ['data/pysol.xbm', 'data/pysol.xpm']))
|
data_files.append(('share/pixmaps', ['data/pysol.xbm', 'data/pysol.xpm']))
|
||||||
for size in os.listdir('data/images/icons'):
|
for size in os.listdir('data/images/icons'):
|
||||||
data_files.append(('share/icons/hicolor/%s/apps' % size,
|
data_files.append(('share/icons/hicolor/%s/apps' % size,
|
||||||
['data/images/icons/%s/pysol.png' % 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((data_dir, ['data/pysolfc.glade']))
|
||||||
data_files.append(('share/applications', ['data/pysol.desktop']))
|
data_files.append(('share/applications', ['data/pysol.desktop']))
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ PLIST = dict(
|
||||||
)
|
)
|
||||||
APP = ['pysol.py']
|
APP = ['pysol.py']
|
||||||
ICON_FILE = 'data/PySol.icns'
|
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 = []
|
RESOURCES = []
|
||||||
FRAMEWORKS = [SOLVER_LIB_PATH] if SOLVER_LIB_PATH else []
|
FRAMEWORKS = [SOLVER_LIB_PATH] if SOLVER_LIB_PATH else []
|
||||||
OPTIONS = dict(argv_emulation=True,
|
OPTIONS = dict(argv_emulation=True,
|
||||||
|
|
Loading…
Add table
Reference in a new issue