Skip to content

Commit

Permalink
Merge branch 'release/v20190812'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Aug 12, 2019
2 parents 587f6f7 + 0c9cb0a commit 8f37a1b
Show file tree
Hide file tree
Showing 54 changed files with 1,563 additions and 1,340 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
- TAG=pywallet-android DOCKERFILE=dockerfiles/Dockerfile-android COMMAND='buildozer android debug'

install:
- docker build --tag=$TAG --file=$DOCKERFILE .
- docker build --tag=$TAG --file=$DOCKERFILE --build-arg TRAVIS .

script:
- travis_wait docker run $TAG $COMMAND
- travis_wait 30 docker run $TAG $COMMAND
56 changes: 27 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,57 @@ VENV_NAME=venv
ACTIVATE_PATH=$(VENV_NAME)/bin/activate
PIP=`. $(ACTIVATE_PATH); which pip`
TOX=`which tox`
GARDEN=`. $(ACTIVATE_PATH); which garden`
GARDEN=$(VENV_NAME)/bin/garden
PYTHON=$(VENV_NAME)/bin/python
SYSTEM_DEPENDENCIES=virtualenv build-essential libpython2.7-dev \
SYSTEM_DEPENDENCIES=virtualenv build-essential libpython3.6-dev \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \
cmake python-numpy tox wget curl libssl-dev libzbar-dev \
xclip xsel
OS=$(shell lsb_release -si)
OPENCV_VERSION=2.4.13.6
OPENCV_BASENAME=opencv-$(OPENCV_VERSION)
OPENCV_BUILD=$(OPENCV_BASENAME)/build/lib/cv2.so
OPENCV_DEPLOY=$(VENV_NAME)/lib/python2.7/site-packages/cv2.so
NPROC=`grep -c '^processor' /proc/cpuinfo`
TMPDIR ?= /tmp
DOWNLOAD_DIR = $(TMPDIR)/downloads
KM_REPOSITORY=https://raw.githubusercontent.com/AndreMiras/km
KM_BRANCH=develop
OPENCV_MAKEFILE_NAME=Makefile.opencv
OPENCV_MAKEFILE_URL=$(KM_REPOSITORY)/$(KM_BRANCH)/attachments/$(OPENCV_MAKEFILE_NAME)


all: system_dependencies opencv virtualenv
all: system_dependencies virtualenv

virtualenv:
test -d venv || virtualenv -p python2 venv
. venv/bin/activate
$(VENV_NAME):
test -d $(VENV_NAME) || virtualenv -p python3 $(VENV_NAME)
. $(VENV_NAME)/bin/activate
$(PIP) install Cython==0.26.1
$(PIP) install -r requirements/requirements.txt
$(GARDEN) install qrcode
$(GARDEN) install xcamera

virtualenv: $(VENV_NAME)

system_dependencies:
ifeq ($(OS), Ubuntu)
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
endif

$(OPENCV_BUILD):
curl --location https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz \
--progress-bar --output $(OPENCV_BASENAME).tar.gz
tar -xf $(OPENCV_BASENAME).tar.gz
cmake \
-D BUILD_DOCS=OFF -D BUILD_PACKAGE=OFF -D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF -D BUILD_opencv_apps=OFF \
-D BUILD_opencv_nonfree=OFF -D BUILD_opencv_stitching=OFF \
-D BUILD_opencv_superres=OFF -D BUILD_opencv_ts=OFF \
-D BUILD_WITH_DEBUG_INFO=OFF -D WITH_1394=OFF -D WITH_CUDA=OFF \
-D WITH_CUFFT=OFF -D WITH_GIGEAPI=OFF -D WITH_JASPER=OFF \
-D WITH_OPENEXR=OFF -D WITH_PVAPI=OFF -D WITH_GTK=OFF \
-D BUILD_opencv_python=ON -B$(OPENCV_BASENAME)/build -H$(OPENCV_BASENAME)
cmake --build $(OPENCV_BASENAME)/build -- -j$(NPROC)
$(DOWNLOAD_DIR):
mkdir --parents $(DOWNLOAD_DIR)

opencv_build: $(OPENCV_BUILD)
opencv_build: $(DOWNLOAD_DIR)
curl --location --progress-bar $(OPENCV_MAKEFILE_URL) \
--output $(DOWNLOAD_DIR)/$(OPENCV_MAKEFILE_NAME)
make --file $(DOWNLOAD_DIR)/$(OPENCV_MAKEFILE_NAME) VENV_NAME=$(VENV_NAME)

$(OPENCV_DEPLOY): opencv_build virtualenv
cp $(OPENCV_BUILD) $(OPENCV_DEPLOY)
opencv_deploy: opencv_build virtualenv
make --file $(DOWNLOAD_DIR)/$(OPENCV_MAKEFILE_NAME) opencv_deploy VENV_NAME=$(VENV_NAME)

opencv: $(OPENCV_DEPLOY)
opencv: opencv_deploy

clean:
rm -rf $(VENV_NAME) .tox/ $(OPENCV_BASENAME)

test:
$(TOX)

uitest:
. $(ACTIVATE_PATH) && \
$(PYTHON) -m kivyunittest --folder src/tests/ui/ --pythonpath src/
23 changes: 0 additions & 23 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@
* https://kivy.org/docs/guide/packaging-android.html#packaging-your-application-into-apk
* https://python-for-android.readthedocs.io/en/latest/quickstart/#installing-dependencies
* https://kivy.org/docs/guide/packaging-android.html
* Upstream
* pydevp2p
* fix broken tests:
* https://github.com/ethereum/pydevp2p/commit/8e1f2b2ef28ecba22bf27eac346bfa7007eaf0fe
* pyethereum
* take a look at the potential unlock wallet performance improvement:
https://github.com/ethereum/pyethereum/pull/777
* python-for-android
* recipes
* secp256k1
* `env['CFLAGS'] += ' -I' + join(libsecp256k1_dir, 'include')` # note the `+=`
* `env['INCLUDE_DIR'] = join(libsecp256k1_dir, 'include')` # see secp256k1-py README.md
* `env['LIB_DIR'] = join(libsecp256k1_dir, '.libs')` # see secp256k1-py README.md
* `env['LDFLAGS'] += ' -L' + join(libsecp256k1_dir, '.libs')` # note the `.libs`
* But in fact passing the library path ("LIB_DIR" and "LDFLAGS") may not be required
because libsecp256k1 recipe has `self.install_libs(arch, *libs)`
* libsecp256k1
* remove java symbols from libsecp256k1 (configure `--enable-jni=no`) to reduce library size
* `should_build()` with `.libs/libsecp256k1.so` check
* Continuous integration
* https://github.com/kivy/python-for-android/issues/625
* p4a apk --reauirements=kivy --private /tmp/p4a/ --package=org.package.testname --name=testname --boostrap=sdl2
* buildozer android p4a -- apk ...
* MISC
* kill running threads on application leave
so it doesn't hangs when you quite while the thread tries to connect
105 changes: 58 additions & 47 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ source.include_exts = py,png,jpg,kv,atlas,md

# (list) List of directory to exclude (let empty to not exclude anything)
#source.exclude_dirs = tests, bin
source.exclude_dirs = bin, venv, src/python-for-android
source.exclude_dirs = python-for-android

# (list) List of exclusions using pattern matching
#source.exclude_patterns = license,images/*/*.jpg
Expand All @@ -38,42 +38,43 @@ version.filename = %(source.dir)s/version.py
# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements =
hostpython2,
kivy,
android,
setuptools,
openssl,
pycryptodome,
pysha3,
ethash,
scrypt,
bitcoin,
rlp==0.6.0,
repoze.lru,
PyYAML,
https://github.com/ethereum/pyethereum/archive/2e53bf3.zip,
devp2p==0.9.3,
coincurve==7.1.0,
gevent,
pbkdf2,
https://github.com/ethereum/pyethapp/archive/409331e88a397ce5276c430aff4a8866d413e45d.zip,
https://gitlab.com/kivymd/KivyMD/repository/archive.zip?ref=e81c02afbca915a4d71c85d3486f6710b53df2c1,
requests,
eth-hash==0.1.1,
pyelliptic==1.5.7,
attrdict==2.0.0,
certifi==2018.10.15,
cffi==1.11.5,
libsecp256k1==355a38f,
asn1crypto==0.24.0,
coincurve==7.1.0,
qrcode,
contextlib2,
raven,
libiconv,
libzbar,
zbar,
pil,
https://github.com/AndreMiras/garden.zbarcam/archive/20171220.zip
chardet==3.0.4,
cytoolz==0.9.0,
eth-abi==1.2.2,
eth-account==0.3.0,
eth-hash==0.1.1,
eth-keyfile==0.5.1,
eth-keys==0.2.0b3,
eth-rlp==0.1.2,
eth-utils==1.4.1,
eth-typing==2.0.0,
gevent,
hexbytes==0.1.0,
https://github.com/AndreMiras/garden.layoutmargin/archive/20180517.tar.gz,
https://github.com/AndreMiras/garden.zbarcam/archive/20190303.zip,
https://github.com/AndreMiras/KivyMD/archive/20181106.tar.gz,
idna==2.7,
Kivy==1.11.1,
libzbar==0.10,
lru-dict==1.1.5,
openssl,
parsimonious==0.8.1,
Pillow==5.2.0,
pycryptodome==3.4.6,
python3,
pyzbar==0.1.8,
qrcode==5.3,
raven==6.1.0,
requests==2.20.0,
rlp==1.0.3,
setuptools==40.9.0,
toolz==0.9.0,
urllib3==1.24.1,
web3==4.8.1
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
Expand Down Expand Up @@ -125,20 +126,22 @@ fullscreen = 0
#android.presplash_color = #FFFFFF
# (list) Permissions
#android.permissions = INTERNET
android.permissions = INTERNET, CAMERA
# (int) Android API to use
#android.api = 19
# (int) Target Android API, should be as high as possible.
android.api = 27
# (int) Minimum API required
#android.minapi = 9
# (int) Minimum API your APK will support.
android.minapi = 21
# (int) Android SDK version to use
#android.sdk = 20
android.sdk = 20
# (str) Android NDK version to use
#android.ndk = 9c
android.ndk = 17c
# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
android.ndk_api = 21
# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True
Expand All @@ -157,6 +160,12 @@ android.permissions = INTERNET, CAMERA
# when an update is due and you just want to test/build your package
# android.skip_update = False
# (bool) If True, then automatically accept SDK license
# agreements. This is intended for automation only. If set to False,
# the default, you will be shown the license when first running
# buildozer.
android.accept_sdk_license = True
# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity
Expand Down Expand Up @@ -189,10 +198,6 @@ android.blacklist_src = blacklist.txt
# bootstrap)
#android.gradle_dependencies =
# (str) python-for-android branch to use, defaults to master
#p4a.branch = stable
p4a.branch = master
# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
#android.ouya.category = GAME
Expand Down Expand Up @@ -233,6 +238,12 @@ android.arch = armeabi-v7a
# Python for android (p4a) specific
#
# (str) python-for-android fork to use, defaults to upstream (kivy)
p4a.fork = kivy
# (str) python-for-android branch to use, defaults to master
p4a.branch = develop
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#p4a.source_dir =
Expand Down Expand Up @@ -265,7 +276,7 @@ p4a.local_recipes = %(source.dir)s/python-for-android/recipes/
[buildozer]
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 1
log_level = 2
# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1
Expand Down
52 changes: 30 additions & 22 deletions dockerfiles/Dockerfile-android
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
# docker run -it --rm pywallet-android
FROM ubuntu:18.04

ARG TRAVIS=false
ENV USER="user"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}" \
PATH="${HOME_DIR}/.local/bin:${PATH}"
ENV DOCKERFILES_VERSION="master" \
ENV DOCKERFILES_VERSION="develop" \
DOCKERFILES_URL="https://raw.githubusercontent.com/AndreMiras/dockerfiles"
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android_new"
# currently needed because buildozer still uses `tools/android` binary
# even though we have the new `tools/bin/sdkmanager` available
ENV USE_SDK_WRAPPER=true
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android"


# configure locale
Expand All @@ -29,15 +27,31 @@ ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"

# install system dependencies (required to setup all the tools)
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
make curl ca-certificates xz-utils unzip openjdk-8-jdk sudo python-pip \
python-setuptools

# install build dependencies (required to successfully build the project)
# TODO: should this go to a Makefile instead so it can be shared/reused?
RUN apt install -qq --yes --no-install-recommends \
file autoconf automake libtool gettext pkg-config libltdl-dev
autoconf \
automake \
ca-certificates \
cmake \
curl \
gettext \
libffi-dev \
libltdl-dev \
libpython2.7-dev \
libpython3.6-dev \
libtool \
make \
openjdk-8-jdk \
pkg-config \
python3-setuptools \
python3.6 \
python3-pip \
python3-setuptools \
python \
sudo \
unzip \
xz-utils \
zip

# prepare non root env
RUN useradd --create-home --shell /bin/bash ${USER}
Expand All @@ -48,19 +62,13 @@ RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
USER ${USER}
WORKDIR ${WORK_DIR}

# downloads and installs Android SDK
# makes sure to have an up to date build-tools version to workaround buildozer bug, see:
# https://github.com/kivy/buildozer/commit/83ad94d#r29065648
RUN curl --location --progress-bar ${MAKEFILES_URL}/android_sdk.mk --output android_sdk.mk
RUN make -f android_sdk.mk

# install buildozer and dependencies
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk
RUN make -f buildozer.mk

# links SDK to where buildozer is expecting to see it
RUN mkdir -p ${HOME}/.buildozer/android/platform
RUN ln -sfn ${HOME}/.android ${HOME}/.buildozer/android/platform/android-sdk-20
# enforces buildozer master (586152c) until next release
RUN pip3 install --upgrade https://github.com/kivy/buildozer/archive/586152c.zip

COPY . ${WORK_DIR}
# limits the amount of logs for Travis
RUN if [ "${TRAVIS}" = "true" ]; then sed 's/log_level = [0-9]/log_level = 1/' -i buildozer.spec; fi
ENTRYPOINT ["./dockerfiles/start.sh"]
6 changes: 6 additions & 0 deletions docs/Troubleshoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ See upstream ticket: https://github.com/kivy/python-for-android/issues/1148
buildozer android p4a -- apk --private $PWD/src/ --local-recipes $PWD/src/python-for-android/recipes/ --package=com.github.andremiras --name PyWallet --version 0.1 --bootstrap=sdl2 --requirements=python2,kivy
```


### Uninstaling the app using adb
```
buildozer android adb -- uninstall com.github.andremiras.pywallet
```

## Kivy

### Debugging widget sizes
Expand Down
Loading

0 comments on commit 8f37a1b

Please sign in to comment.