From 2b6695e110bc3a95e94ffdc8a69254ed07e969ed Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Fri, 18 Jan 2019 14:04:29 +0100 Subject: [PATCH 1/6] Lock down deps, add script for making Python packages from git. --- package.sh | 20 ++++++++++++++++++++ requirements-testing.txt | 6 ++++-- requirements.txt | 3 ++- setup.py | 11 ++++++----- 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100755 package.sh mode change 100644 => 100755 requirements-testing.txt mode change 100644 => 100755 requirements.txt mode change 100644 => 100755 setup.py diff --git a/package.sh b/package.sh new file mode 100755 index 0000000..2464862 --- /dev/null +++ b/package.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Abort on errors, as well as unset variables. Makes the script less error prone. +set -o errexit + +rm -rf dist || true +rm -rf build_env | true + +virtualenv build_env +source build_env/bin/activate + +pip3 install -r requirements.txt +pip3 install -r requirements-testing.txt + +python3 setup.py bdist_wheel + +rm -rf build_env + +echo "" +ls -alp dist diff --git a/requirements-testing.txt b/requirements-testing.txt old mode 100644 new mode 100755 index fea764c..08e0a27 --- a/requirements-testing.txt +++ b/requirements-testing.txt @@ -1,2 +1,4 @@ -pytest -coverage \ No newline at end of file +pytest==4.1.1 +coverage==4.5.2 +setuptools==40.6.3 +setuptools-scm==3.2.0 diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 index c997f36..ce1c17c --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -typing +typing==3.6.6 + diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 843b34d..33fa66a --- a/setup.py +++ b/setup.py @@ -1,14 +1,15 @@ -# Copyright (c) 2018 Ultimaker B.V. +# Copyright (c) 2019 Ultimaker B.V. # libCharon is released under the terms of the LGPLv3 or higher. -from distutils.core import setup +import setuptools -setup( +setuptools.setup( name = "Charon", - version = "1.0", + use_scm_version=True, description = "Library to read and write file packages.", author = "Ultimaker", author_email = "r.dulek@ultimaker.com", url = "https://github.com/Ultimaker/libCharon", - packages = ["Charon", "Charon.Client", "Charon.Service", "Charon.filetypes"] + packages = ["Charon", "Charon.Client", "Charon.Service", "Charon.filetypes"], + setup_requires=['setuptools_scm'] ) From 165f67ec6038c753049fa4c6b92d41b5c2bf2c1d Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 5 Feb 2019 11:59:25 +0100 Subject: [PATCH 2/6] Make the package script produce a Debian package too. --- package.sh | 22 ++++++++++++++++++++++ requirements.txt | 1 + 2 files changed, 23 insertions(+) diff --git a/package.sh b/package.sh index 2464862..c61b26a 100755 --- a/package.sh +++ b/package.sh @@ -6,15 +6,37 @@ set -o errexit rm -rf dist || true rm -rf build_env | true +#------------------------------------------------------ +# Set up Python + virtualenv build_env source build_env/bin/activate pip3 install -r requirements.txt pip3 install -r requirements-testing.txt +#------------------------------------------------------ +# Python Package build + python3 setup.py bdist_wheel +#------------------------------------------------------ +# Debian package build + +BUILD_DIR=_build_armhf +VERSION=9999.99.99 + +rm -rf $BUILD_DIR || true +mkdir -p $BUILD_DIR + +cd $BUILD_DIR +cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCPACK_PACKAGE_VERSION=${VERSION} -DEMBEDDED=ON +make package +cd .. + rm -rf build_env +echo "" +echo "Your fresh packages:" echo "" ls -alp dist diff --git a/requirements.txt b/requirements.txt index ce1c17c..971a88b 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ typing==3.6.6 +dbus-python From 8cd30a8e670ea9427cf55bf57048a8835f64a3e8 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 5 Feb 2019 12:11:40 +0100 Subject: [PATCH 3/6] Rename `package.sh` to `build_package.sh` --- package.sh => build_package.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename package.sh => build_package.sh (94%) diff --git a/package.sh b/build_package.sh similarity index 94% rename from package.sh rename to build_package.sh index c61b26a..6023b6c 100755 --- a/package.sh +++ b/build_package.sh @@ -39,4 +39,5 @@ rm -rf build_env echo "" echo "Your fresh packages:" echo "" -ls -alp dist +ls -alp dist/*.whl +ls -alp $BUILD_DIR/*.deb From d5c825ec4d1d01b98f38232647173a02cb0f8002 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 5 Feb 2019 15:35:04 +0100 Subject: [PATCH 4/6] Name the Python package 'libCharon'. There is already a 'charon' on PyPi. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 33fa66a..6a55d48 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import setuptools setuptools.setup( - name = "Charon", + name = "libCharon", use_scm_version=True, description = "Library to read and write file packages.", author = "Ultimaker", From 0fd50f7aa14895abdbec29cdb4e99309c5f6f64f Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 5 Feb 2019 17:04:33 +0100 Subject: [PATCH 5/6] Use the Alpine python-dbus pkg for CI instead of the PyPi one. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 Dockerfile diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 index 7248953..57ddc26 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Install pytest python library as well as add all files in current directory FROM python:3.4-alpine AS base WORKDIR /usr/src/app -RUN apk add --no-cache git +RUN apk add --no-cache git py-dbus ADD requirements.txt requirements.txt ADD requirements-testing.txt requirements-testing.txt From 2de4970817dc1d6106c9801eb7ae8a1f36ab29d7 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 5 Feb 2019 17:24:28 +0100 Subject: [PATCH 6/6] Revert the installation of py-dbus in Docker It is for Python 2. :( --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 57ddc26..7248953 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Install pytest python library as well as add all files in current directory FROM python:3.4-alpine AS base WORKDIR /usr/src/app -RUN apk add --no-cache git py-dbus +RUN apk add --no-cache git ADD requirements.txt requirements.txt ADD requirements-testing.txt requirements-testing.txt