Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
614 changes: 307 additions & 307 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
recipe.yaml

tests/

conda-bld/
75 changes: 75 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Using the latest Ubuntu LTS amd64 image
FROM amd64/ubuntu:22.04

ENV HOME /root
ENV ANDROID_HOME="$HOME/Android/Sdk"
ENV PY_VER 3.12
ENV ANDROID_SDK_FILENAME android-ndk-r25c-linux.zip
ENV ANDROID_SDK_URL https://dl.google.com/android/repository/${ANDROID_SDK_FILENAME}
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV CONDA_BLD_PATH /host_dir/conda-bld
ENV CONDA_POST ${HOME}/miniconda3/envs/conda-mobile/lib/python${PY_VER}/site-packages/conda_build/post.py

# Install system dependencies and clean up in one layer to use Docker cache efficiently
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
curl \
gnupg \
apt-transport-https \
openjdk-11-jdk \
make \
ninja-build \
cmake \
git \
autoconf \
automake \
libtool \
locales-all \
dos2unix \
rsync \
tar \
unzip \
pkg-config \
autopoint \
rename \
ucommon-utils \
texinfo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install Android SDK
RUN mkdir -p ${ANDROID_HOME}/ndk && \
curl --progress-bar -L -o ${ANDROID_SDK_FILENAME} ${ANDROID_SDK_URL} && \
unzip ${ANDROID_SDK_FILENAME} -d ${ANDROID_HOME}/ndk && \
rm ${ANDROID_SDK_FILENAME}

# Install Miniconda
RUN curl --progress-bar -O https://repo.anaconda.com/miniconda/Miniconda3-py312_24.1.2-0-Linux-x86_64.sh && \
bash Miniconda3-py312_24.1.2-0-Linux-x86_64.sh -b -p ${HOME}/miniconda3 && \
rm Miniconda3-py312_24.1.2-0-Linux-x86_64.sh

# Initialize Conda in bashrc
RUN echo ". ${HOME}/miniconda3/etc/profile.d/conda.sh" >> ${HOME}/.bashrc && \
echo "conda activate conda-mobile" >> ${HOME}/.bashrc

# Install micromamba and create conda environment
RUN . ${HOME}/miniconda3/etc/profile.d/conda.sh && \
conda install -n base --override-channels -c conda-forge mamba 'python_abi=*=*cp*' && \
mamba create -n conda-mobile python=${PY_VER} && \
conda activate conda-mobile && \
conda install -c conda-forge conda-build conda-verify anaconda-client boa && \
# issue https://stackoverflow.com/a/78293971
conda install --solver=classic conda-forge::conda-libmamba-solver conda-forge::libmamba conda-forge::libmambapy conda-forge::libarchive

# Patch conda build
RUN sed -i 's/.match(fn):/.match(fn) and exists(join(prefix, fn)):/g' ${CONDA_POST}


# Create alias to md5sum necessary for conda
RUN echo "alias md5='md5sum'" >> ${HOME}/.bashrc

ENTRYPOINT [ "/bin/bash", "-c", "source ${HOME}/miniconda3/etc/profile.d/conda.sh && conda activate conda-mobile && exec \"$@\"", "--" ]
CMD ["/bin/bash"]
86 changes: 42 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,88 +1,86 @@
# Build all in order

PY_VER=3.7

PY_VER=3.12

# Build android recipes
android-libs:
conda-build android-libffi
conda-build android-liblzma
conda-build android-libbz2
conda-build android-openssl
conda-build android-sqlite
conda mambabuild android-libffi
conda mambabuild android-liblzma
conda mambabuild android-libbz2
conda mambabuild android-openssl
conda mambabuild android-sqlite

android-python:
conda-build --py $PY_VER android-python
conda mambabuild --py $PY_VER android-python

android-enaml:
# Enaml
conda-build --py $PY_VER android-atom
conda-build --py $PY_VER android-enaml
conda mambabuild --py $PY_VER android-atom
conda mambabuild --py $PY_VER android-enaml

android-msgpack: android-python
conda-build --py $PY_VER android-msgpack
conda mambabuild --py $PY_VER android-msgpack

# Shapely
android-shapely:
conda-build android-lz4
conda-build android-libgeos
conda-build android-shapely --py $PY_VER
conda-build android-pyproj --py $PY_VER
conda mambabuild android-lz4
conda mambabuild android-libgeos
conda mambabuild android-shapely --py $PY_VER
conda mambabuild android-pyproj --py $PY_VER

# Lxml
android-lxml:
conda-build android-libxml2
conda-build android-libxslt
conda-build android-lxml --py $PY_VER
conda mambabuild android-libxml2
conda mambabuild android-libxslt
conda mambabuild android-lxml --py $PY_VER

# ZMQ
android-pyzmq:
cofile:///home/jrm/Workspace/codelv/conda-mobile/android-enaml/tables/0.10.3.a1nda-build android-libsodium
conda-build android-libzmq
conda-build android-pyzmq --py $PY_VER
conda mambabuild android-libzmq
conda mambabuild android-pyzmq --py $PY_VER


android-numpy:
conda-build android-numpy --py $PY_VER
conda mambabuild android-numpy --py $PY_VER

android-pandas: android-numpy
conda-build android-pandas --py $PY_VER
conda mambabuild android-pandas --py $PY_VER

android-cryptography:
conda-build android-cffi --python=$PY_VER
conda-build android-cryptography --python=$PY_VER
conda mambabuild android-cffi --python=$PY_VER
conda mambabuild android-cryptography --python=$PY_VER


android-pymongo:
conda-build android-pymongo --python=$PY_VER
conda mambabuild android-pymongo --python=$PY_VER

ios-libs:
conda-build ios-libffi
conda-build ios-openssl
conda mambabuild ios-libffi
conda mambabuild ios-openssl

ios-python:
conda-build --py $PY_VER ios-python
conda mambabuild --py $PY_VER ios-python

ios-enaml:
conda-build --py $PY_VER ios-atom
conda-build --py $PY_VER ios-enaml
conda mambabuild --py $PY_VER ios-atom
conda mambabuild --py $PY_VER ios-enaml

ios-msgpack:
conda-build --py $PY_VER ios-msgpack
conda mambabuild --py $PY_VER ios-msgpack


pip:
# Pip (pure python) recipes
conda-build pip-ply
conda-build pip-automat
conda-build pip-futures
conda-build pip-backports_abc
conda-build pip-constantly
conda-build pip-hyperlink
conda-build pip-inda
conda-build pip-incremental
conda-build pip-singledispatch
conda-build pip-six
conda-build pip-zope.interface
conda-build pip-twisted
conda-build pip-tornado
# conda mambabuild pip-ply
# conda mambabuild pip-automat
# conda mambabuild pip-backports_abc
# conda mambabuild pip-constantly
# conda mambabuild pip-inda
conda mambabuild pip-hyperlink
conda mambabuild pip-incremental
conda mambabuild pip-singledispatch
conda mambabuild pip-six
conda mambabuild pip-zope.interface
conda mambabuild pip-twisted
conda mambabuild pip-tornado
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,33 @@ To add a new recipe or to build existing recipes:
1. Install [`micromamba`](https://github.com/mamba-org/mamba#micromamba)
2. Install [`boa`](https://github.com/mamba-org/boa)
3. Clone this repo or create your own recipe(s)
4. Install the android ndk using `sdkmanager "ndk:23.1.7779620"` (or update the android-ndk recipe)
4. Install the android ndk using `sdkmanager "ndk:25.2.9519653"` (or update the android-ndk recipe)
5. Add the requirements to your recipes as needed
6. Install `build-essential`, `rename`, `autopoint`, and `texinfo` with apt
7. Run `boa build <recipe-name>`
7. Run `conda mambabuild <recipe-name>`
8. Then either add a PR or create your own repos with recipes.

This project requires several environment variables to be set. You can set these environment variables in your shell or system configuration, depending on your operating system.

Here is a brief explanation of each of these variables:
```bash
ANDROID_API_LEVEL: The Android API level to target when building the application.
ANDROID_NDK_API_LEVEL: The minimum Android API level that is supported by the Android NDK.
ANDROID_HOME: The location of the Android SDK.
ANDROID_NDK_HOME: The location of the Android NDK.
ANDROID_TOOLCHAIN: The location of the LLVM toolchain provided by the Android NDK.
```

Here is an example of how to set these environment variables in your shell:
```bash
export ANDROID_API_LEVEL=33
export ANDROID_NDK_API_LEVEL=24
export ANDROID_BUILD_TOOLS_VERSION=30.0.3
export ANDROID_HOME="/android/sdk"
export ANDROID_NDK_HOME="/android/ndk"
export ANDROID_TOOLCHAIN="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64"
```


#### Recipe requirements

Expand All @@ -108,11 +129,11 @@ requirements:
- python
- cython
- android-ndk
- android-python * py310*
- android-python * py312*
- android-libc++
run:
- python # Adding python here make conda append the py27 or py310 build string
- android-python * py310* # Required so it installs the correct pkg for the py version
- android-python * py312* # Required so it installs the correct pkg for the py version
- android-libc++ # Pure c/c++ libraries do not need a "build" filter

```
Expand Down Expand Up @@ -157,11 +178,38 @@ these libraries from the env for the given target and use them as is.
[enaml-native](https://github.com/codelv/enaml-native) supports this.


### Troubleshooting

<details>
<summary> sed:1: "configure": command c expects \ followed by text</summary>

This is caused when running a shell script that use sed in macos, note that sed on macos behaviors diffently from linux, so you need to install gnu-sed and use gsed instead of sed.

for reference see [this](https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da)


</details>



### CI

The ci script is generated using `python generate-ci.py`. Running it will
update the `ci.yaml` and generate a boa `recipe.yaml` for each package.

### Docker

```bash
# create a docker image
docker build -t conda-mobile .

# run the image from current conda mobile recipes dir
docker run -it --rm -v $PWD:/host_dir conda-mobile

# go to the host dir and build the recipe
cd /host_dir && conda mambabuild android-python
```


### Contributing

Expand All @@ -176,3 +224,5 @@ If you need a package or otherwise need support please contact me at [codelv.com

If you use one of these builds in a commerical application please consider
sponsoring me or dropping a donation at [codelv.com/donate](https://codelv.com/donate).


15 changes: 5 additions & 10 deletions android-atom/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
# ==================================================================================================
export HOSTPYTHON=$PYTHON
source $BUILD_PREFIX/android/activate-ndk.sh

if [ "$PY3K" == "1" ]; then
export PY_LIB_VER="3.10"
else
export PY_LIB_VER="2.7"
fi
export PY_LIB_VER_NODOTS=$(echo $PY_LIB_VER | tr -d '.')

for ARCH in $ARCHS
do
Expand All @@ -30,16 +25,16 @@ do
# Build
python setup.py build

# Rename and move all so files to lib
cd build/lib.android-$ARCH-$PY_VER/
# Rename and move all so files to lib
cd build/lib.android-$ARCH-cpython-$PY_LIB_VER_NODOTS/
find * -type f -name "*.so" -exec rename 's!/!.!g' {} \;
rename 's/^/lib./' *.so; rename 's/\.cpython-.+\.so/\.so/' *.so;
cd $SRC_DIR

# Copy to install
mkdir -p $PREFIX/android/$ARCH/python/site-packages/
cp -RL build/lib.android-$ARCH-$PY_VER/atom $PREFIX/android/$ARCH/python/site-packages/
cp -RL build/lib.android-$ARCH-$PY_VER/*.so $PREFIX/android/$ARCH/lib
cp -RL build/lib.android-$ARCH-cpython-$PY_LIB_VER_NODOTS/atom $PREFIX/android/$ARCH/python/site-packages/
cp -RL build/lib.android-$ARCH-cpython-$PY_LIB_VER_NODOTS/*.so $PREFIX/android/$ARCH/lib
validate-lib-arch $PREFIX/android/$ARCH/lib/*.so

done
14 changes: 6 additions & 8 deletions android-atom/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "atom" %}
{% set version = "0.8.0" %}
{% set version = "0.10.4" %}
{% set hash_type = "sha256" %}
{% set hash_value = "4055fbdeeb692d3d52c6e3c628d7513fc71f147920cac7d0da05b6dbb5ec8c8d" %}
package:
Expand All @@ -8,10 +8,8 @@ package:

source:
git_url: https://github.com/nucleic/atom.git
git_rev: main
#fn: '{{ name }}-{{ version }}.tar.gz'
#url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
#'{{ hash_type }}': '{{ hash_value }}'
git_rev: '{{version}}'



requirements:
Expand All @@ -21,15 +19,15 @@ requirements:
- pip-cppy
- android-ndk
- android-libcxx
- android-python * py310*
- android-python * py312*
run:
- python
- android-libcxx
- android-python * py310*
- android-python * py312*

build:
binary_relocation: False
string: 'py310'
string: 'py312'
noarch: generic

about:
Expand Down
Loading