Skip to content

Commit

Permalink
Merge pull request #5474 from mrpau/feature/5473-build-python-package…
Browse files Browse the repository at this point in the history
…s-and-pexfile-using-buildkite

Build python packages and pex file using buildkite
  • Loading branch information
benjaoming committed Aug 16, 2017
2 parents 077fcff + 0e1a707 commit f05d1c6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .buildkite/build_and_upload_artifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

make dockerenvdist
buildkite-agent artifact upload 'dist/*.whl'
buildkite-agent artifact upload 'dist/*.zip'
buildkite-agent artifact upload 'dist/*.tar.gz'
buildkite-agent artifact upload 'dist/*.pex'
buildkite-agent artifact upload 'dist/*.exe'
8 changes: 8 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
steps:
- label: Build the docker environment
command: make dockerenvbuild

- wait

- label: Build the python packages and windows installer
command: mkdir -p dist && .buildkite/build_and_upload_artifact.sh && docker container prune -f
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:xenial

# install latest python and nodejs
RUN apt-get -y update
RUN apt-get install -y software-properties-common curl
RUN add-apt-repository ppa:voronov84/andreyv
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get -y update && apt-get install -y python2.7 python-pip git nodejs gettext python-sphinx wget

# Install wine and related packages
RUN dpkg --add-architecture i386
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates sudo software-properties-common
RUN add-apt-repository -y ppa:ubuntu-wine/ppa && apt-get -y update && apt-get install --no-install-recommends --assume-yes wine


COPY . /kalite
VOLUME /kalitedist/

# for mounting the whl files into other docker containers
RUN pip install virtualenv && virtualenv /kalite/kalite_env --python=python2.7
RUN /kalite/kalite_env/bin/pip install -r /kalite/requirements_dev.txt \
&& /kalite/kalite_env/bin/pip install -r /kalite/requirements_sphinx.txt \
&& /kalite/kalite_env/bin/pip install -e /kalite/.

# Override the PATH to add the path of our virtualenv python binaries first so it's python executes instead of
# the system python.
ENV PATH=/kalite/kalite_env/bin:$PATH
ENV KALITE_PYTHON=/kalite/kalite_env/bin/python

# Installer dependencies
RUN cd /kalite/ && git clone https://github.com/learningequality/ka-lite-installers.git && cd /kalite/ka-lite-installers && git checkout 0.17.x
RUN cd /kalite/ka-lite-installers/windows && wget http://pantry.learningequality.org/downloads/ka-lite/0.17/content/contentpacks/en.zip

# Build the python packages and the ka-lite windows installer
CMD cd /kalite && make dist \
&& cd /kalite/ka-lite-installers/windows \
&& cp -R /kalite/dist/ka_lite_static-*-py2-none-any.whl /kalite/ka-lite-installers/windows \
&& export KALITE_BUILD_VERSION=$(/kalite/kalite_env/bin/kalite --version) \
&& wine inno-compiler/ISCC.exe installer-source/KaliteSetupScript.iss \
&& cp /kalite/dist/* /kalitedist/ \
&& cp /kalite/ka-lite-installers/windows/KALiteSetup-$(/kalite/kalite_env/bin/kalite --version).exe /kalitedist/
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ coverage:
coverage run --source kalite bin/kalite test
coverage report -m


docs:
# rm -f docs/ka-lite.rst
# rm -f docs/modules.rst
Expand Down Expand Up @@ -114,7 +115,7 @@ sdist: clean docs assets
python setup.py sdist --formats=$(format) --static
python setup.py sdist --formats=$(format)

dist: clean docs assets
dist: clean docs assets
# Building assets currently creates pyc files in the source dirs,
# so we should delete those...
make clean-pyc
Expand All @@ -126,3 +127,16 @@ dist: clean docs assets

install: clean
python setup.py install

dockerwriteversion:
python -c "import kalite; print(kalite.__version__)" > kalite/VERSION

dockerenvclean:
docker container prune -f
docker image prune -f

dockerenvbuild: dockerwriteversion
docker image build -t learningequality/kalite:$$(cat kalite/VERSION) -t learningequality/kalite:latest .

dockerenvdist: dockerwriteversion
docker run -v $$PWD/dist:/kalitedist learningequality/kalite:$$(cat kalite/VERSION)

0 comments on commit f05d1c6

Please sign in to comment.