Add build package and Woodpecker CI stuff
This commit is contained in:
parent
252f9a87ac
commit
bc276b9845
4 changed files with 158 additions and 41 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -2,3 +2,7 @@
|
|||
*~
|
||||
mylib.egg-info
|
||||
venv*
|
||||
build
|
||||
dist
|
||||
deb_dist
|
||||
mylib-*.tar.gz
|
||||
|
|
33
.woodpecker.yml
Normal file
33
.woodpecker.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
pipelines:
|
||||
test:
|
||||
image: debian
|
||||
commands:
|
||||
- apt update
|
||||
- apt -y upgrade
|
||||
- apt install -y python3-all python3-dev python3-pip python3-venv build-essential pkg-config libsystemd-dev libldap2-dev libsasl2-dev libpq-dev libmariadb-dev wget unzip
|
||||
- wget -O /opt/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip
|
||||
- unzip -d /opt /opt/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip
|
||||
- echo /opt/instantclient_* > /etc/ld.so.conf.d/oracle-instantclient.conf
|
||||
- ldconfig
|
||||
- python3 -m venv venv
|
||||
- source venv/bin/activate
|
||||
- python3 -m pip install -e ".[dev]"
|
||||
- python3 -m pytest tests
|
||||
build:
|
||||
image: debian
|
||||
commands:
|
||||
- apt update
|
||||
- apt -y upgrade
|
||||
- apt -y install --no-install-recommends git sed python3-all python3-dev python3-pip python3-venv dpkg-dev build-essential debhelper dh-python bash-completion lsb-release
|
||||
- ./build.sh
|
||||
- rm -fr deb_dist/python3-mylib-*
|
||||
publish:
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
base_url: https://gitea.zionetrix.net
|
||||
files: dist/* deb_dist/*
|
||||
checksum:
|
||||
- md5
|
||||
- sha512
|
80
build.sh
Executable file
80
build.sh
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Enter source directory
|
||||
cd $( dirname $0 )
|
||||
|
||||
# Clean previous build
|
||||
rm -fr dist deb_dist
|
||||
|
||||
# Set version in pyproject.toml
|
||||
VERSION="$( git describe --tags )"
|
||||
sed -i "s/^version *=.*$/version = '$VERSION'/" setup.py
|
||||
|
||||
if [ -d venv ]
|
||||
then
|
||||
VENV=$( realpath venv )
|
||||
TEMP_VENV=0
|
||||
else
|
||||
# Install stdeb in temporary venv
|
||||
VENV=$(mktemp -d)
|
||||
echo "Create a temporary virtualenv in $VENV to install build dependencies..."
|
||||
TEMP_VENV=1
|
||||
python3 -m venv $VENV
|
||||
$VENV/bin/python3 -m pip install stdeb GitPython wheel
|
||||
fi
|
||||
|
||||
# Build wheel package
|
||||
$VENV/bin/python3 setup.py bdist_wheel
|
||||
|
||||
# Check gitdch is installed
|
||||
GITDCH=$(which gitdch)
|
||||
set -e
|
||||
if [ -z "$GITDCH" ]
|
||||
then
|
||||
TMP_GITDCH=$(mktemp -d)
|
||||
echo "Temporary install gitdch in $TMP_GITDCH"
|
||||
git clone https://gitea.zionetrix.net/bn8/gitdch.git $TMP_GITDCH/gitdch
|
||||
GITDCH=$TMP_GITDCH/gitdch/gitdch
|
||||
else
|
||||
TMP_GITDCH=""
|
||||
fi
|
||||
|
||||
# Build debian source package
|
||||
$VENV/bin/python3 setup.py --command-packages=stdeb.command sdist_dsc \
|
||||
--package3 "python3-mylib" \
|
||||
--maintainer "Benjamin Renard <brenard@zionetrix.net>" \
|
||||
--compat 10 \
|
||||
--section net \
|
||||
--forced-upstream-version "$VERSION"
|
||||
|
||||
# Keep only debian package directory and orig.tar.gz archive
|
||||
find deb_dist/ -maxdepth 1 -type f ! -name '*.orig.tar.gz' -delete
|
||||
|
||||
# Enter in debian package directory
|
||||
cd deb_dist/mylib-$VERSION
|
||||
|
||||
# Generate EE debian codename
|
||||
DEBIAN_CODENAME=$( lsb_release -c -s )
|
||||
[ $( lsb_release -r -s ) -ge 9 ] && DEBIAN_CODENAME="${DEBIAN_CODENAME}-ee"
|
||||
|
||||
# Generate debian changelog using generate_debian_changelog.py
|
||||
$VENV/bin/python3 $GITDCH \
|
||||
--package-name mylib \
|
||||
--version "${VERSION}" \
|
||||
--code-name $DEBIAN_CODENAME \
|
||||
--output debian/changelog \
|
||||
--path ../../ \
|
||||
--verbose
|
||||
|
||||
# Add custom package name for dependencies
|
||||
cat << EOF > debian/py3dist-overrides
|
||||
cx_oracle python3-cx-oracle
|
||||
EOF
|
||||
|
||||
[ $TEMP_VENV -eq 1 ] && rm -fr $VENV
|
||||
|
||||
# Clean temporary gitdch installation
|
||||
[ -n "$TMP_GITDCH" ] && rm -fr $TMP_GITDCH
|
||||
|
||||
# Build debian package
|
||||
dpkg-buildpackage --no-sign
|
36
setup.py
36
setup.py
|
@ -1,25 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from setuptools import find_packages
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
with open(os.path.join(here, 'README.md')) as f:
|
||||
README = f.read()
|
||||
|
||||
setup(
|
||||
name="mylib",
|
||||
version='0.0',
|
||||
long_description=README,
|
||||
classifiers=[
|
||||
'Programming Language :: Python',
|
||||
],
|
||||
install_requires=[
|
||||
'progressbar',
|
||||
],
|
||||
extras_require={
|
||||
'dev': [
|
||||
'pytest',
|
||||
|
@ -28,7 +13,6 @@ setup(
|
|||
'pylint',
|
||||
],
|
||||
'config': [
|
||||
'configparser',
|
||||
'argcomplete',
|
||||
'keyring',
|
||||
'systemd-python',
|
||||
|
@ -39,7 +23,6 @@ setup(
|
|||
'pytz',
|
||||
],
|
||||
'email': [
|
||||
'email3',
|
||||
'mako',
|
||||
],
|
||||
'pgsql': [
|
||||
|
@ -51,7 +34,24 @@ setup(
|
|||
'mysql': [
|
||||
'mysqlclient',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
install_requires = ['progressbar']
|
||||
for extra, deps in extras_require.items():
|
||||
if extra != 'dev':
|
||||
install_requires.extend(deps)
|
||||
|
||||
version = '0.1'
|
||||
|
||||
setup(
|
||||
name="mylib",
|
||||
version=version,
|
||||
description='A set of helpers small libs to make common tasks easier in my script development',
|
||||
classifiers=[
|
||||
'Programming Language :: Python',
|
||||
],
|
||||
install_requires=install_requires,
|
||||
extras_require=extras_require,
|
||||
author='Benjamin Renard',
|
||||
author_email='brenard@zionetrix.net',
|
||||
url='https://gogs.zionetrix.net/bn8/python-mylib',
|
||||
|
|
Loading…
Reference in a new issue