Skip to content

Commit 9099733

Browse files
alercunhafalkTX
authored andcommitted
Merge pull request #18 from alercunha/modernize
Enhancements to modernize branch
1 parent fbb770b commit 9099733

9 files changed

Lines changed: 211 additions & 104 deletions

File tree

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and Test
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
DEBIAN_FRONTEND: noninteractive
7+
DIST_DIR: dist
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
container:
13+
image: ubuntu:22.04
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install build dependencies
18+
run: |
19+
apt-get update -qq
20+
apt-get install -yqq --no-install-recommends \
21+
ca-certificates curl git \
22+
debhelper devscripts dpkg-dev meson pkg-config \
23+
python3-all-dev python3-pip python3-setuptools python3-venv python3-wheel \
24+
libpcre3-dev
25+
curl -sLO https://launchpad.net/~kxstudio-debian/+archive/ubuntu/toolchain/+files/meson_1.9.1-1kxstudio2_all.deb
26+
dpkg -i meson_1.9.1-1kxstudio2_all.deb
27+
28+
- name: Build
29+
run: ./scripts/build.sh
30+
31+
- name: Test
32+
run: ./scripts/test.sh
33+
34+
- name: Upload artifacts
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: lilvlib-packages
38+
path: dist/
39+
retention-days: 30

.github/workflows/pylint.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

Dockerfile

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,73 @@
1-
# This Dockerfile can be used to build lilvlib using:
2-
# - Ubuntu 18
3-
# - Python 3.6
1+
# Multi-stage Dockerfile for building and testing lilvlib
2+
# Usage:
3+
# docker build -t lilvlib-build .
4+
# docker run --rm -v $(pwd)/dist:/dist lilvlib-build
5+
#
6+
# To run only the build stage (skip tests):
7+
# docker build --target builder -t lilvlib-builder .
48

5-
FROM moddevices/devtools:ub18-py36
9+
# =============================================================================
10+
# Stage 1: Builder - compile python3-lilv and build wheel
11+
# =============================================================================
12+
FROM ubuntu:22.04 AS builder
613

7-
LABEL Alexandre Cunha <ale@moddevices.com>
14+
ENV DEBIAN_FRONTEND=noninteractive
815

9-
RUN mkdir /root/.ssh
10-
RUN touch /root/.ssh/known_hosts
11-
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
16+
RUN apt-get update && apt-get install -y --no-install-recommends \
17+
ca-certificates \
18+
curl \
19+
debhelper \
20+
devscripts \
21+
dpkg-dev \
22+
git \
23+
libpcre3-dev \
24+
meson \
25+
pkg-config \
26+
python3-all-dev \
27+
python3-pip \
28+
python3-setuptools \
29+
python3-wheel \
30+
&& rm -rf /var/lib/apt/lists/*
1231

13-
RUN apt-get install --no-install-recommends -qy libpcre3-dev \
14-
devscripts pkg-config swig debhelper python3-numpy \
15-
&& apt-get clean
32+
# Ubuntu 22.04's meson (0.61.2) is incompatible with the build
33+
RUN curl -sLO https://launchpad.net/~kxstudio-debian/+archive/ubuntu/toolchain/+files/meson_1.9.1-1kxstudio2_all.deb \
34+
&& dpkg -i meson_1.9.1-1kxstudio2_all.deb \
35+
&& rm meson_1.9.1-1kxstudio2_all.deb
1636

17-
COPY . /lilvlib
18-
WORKDIR /lilvlib
37+
WORKDIR /src
38+
COPY . .
1939

20-
RUN ./build-python3-lilv.sh
21-
RUN pip3 wheel -w wheelhouse .
40+
ENV DIST_DIR=/artifacts
41+
RUN ./scripts/build.sh
42+
43+
# =============================================================================
44+
# Stage 2: Tester - validate artifacts in a clean environment
45+
# =============================================================================
46+
FROM ubuntu:22.04 AS tester
47+
48+
ENV DEBIAN_FRONTEND=noninteractive
49+
50+
RUN apt-get update && apt-get install -y --no-install-recommends \
51+
python3 \
52+
python3-pip \
53+
python3-venv \
54+
&& rm -rf /var/lib/apt/lists/*
55+
56+
WORKDIR /src
57+
COPY --from=builder /artifacts /artifacts
58+
COPY --from=builder /src/test.py /src/
59+
COPY --from=builder /src/lilvlib /src/lilvlib
60+
COPY --from=builder /src/scripts /src/scripts
61+
62+
ENV DIST_DIR=/artifacts
63+
RUN apt-get update && ./scripts/test.sh && rm -rf /var/lib/apt/lists/*
64+
65+
# =============================================================================
66+
# Final Stage: Artifacts - extract build outputs (runs after tests pass)
67+
# =============================================================================
68+
FROM ubuntu:22.04
69+
70+
WORKDIR /artifacts
71+
COPY --from=tester /artifacts /artifacts
72+
73+
CMD ["sh", "-c", "cp -v /artifacts/* /dist/ 2>/dev/null || echo 'Mount a volume to /dist to extract artifacts: docker run --rm -v $(pwd)/dist:/dist <image>'"]

lilvlib/lilvlib.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def get_plugin_info(world, plugin, useAbsolutePath = True):
692692

693693
elif len(brand) > 16:
694694
brand = brand[:16]
695-
errors.append("plugin brand has more than 11 characters")
695+
errors.append("plugin brand has more than 16 characters")
696696

697697
# --------------------------------------------------------------------------------------------------------
698698
# label
@@ -716,7 +716,7 @@ def get_plugin_info(world, plugin, useAbsolutePath = True):
716716

717717
elif len(label) > 24:
718718
label = label[:24]
719-
errors.append("plugin label has more than 16 characters")
719+
errors.append("plugin label has more than 24 characters")
720720

721721
# --------------------------------------------------------------------------------------------------------
722722
# bundles
@@ -1379,12 +1379,10 @@ def get_plugins_info(bundles):
13791379

13801380
# ------------------------------------------------------------------------------------------------------------
13811381

1382-
if __name__ == '__main__':
1383-
from sys import argv, exit
1382+
def main():
1383+
from sys import argv
13841384
from pprint import pprint
1385-
#get_plugins_info(argv[1:])
1386-
#for i in get_plugins_info(argv[1:]): pprint(i)
1387-
#exit(0)
1385+
13881386
for i in get_plugins_info(argv[1:]):
13891387
warnings = i['warnings'].copy()
13901388

@@ -1408,3 +1406,8 @@ def get_plugins_info(bundles):
14081406
}, width=200)
14091407

14101408
# ------------------------------------------------------------------------------------------------------------
1409+
1410+
if __name__ == '__main__':
1411+
main()
1412+
1413+
# ------------------------------------------------------------------------------------------------------------

lv2_validate_mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ LV2DIR=${PREFIX}/lib/lv2
66
# don't check all lv2 bundles, if atom.lv2 is installed the others should be too
77
if [ ! -d ${LV2DIR}/atom.lv2 ]; then
88
echo "${LV2DIR}/atom.lv2 directory is missing"
9-
exit
9+
exit 1
1010
fi
1111

1212
if [ ! -d ${LV2DIR}/dg-properties.lv2 ]; then
1313
echo "${LV2DIR}/dg-properties.lv2 directory is missing"
14-
exit
14+
exit 1
1515
fi
1616

1717
if [ ! -d ${LV2DIR}/kx-properties.lv2 ]; then
1818
echo "${LV2DIR}/kx-properties.lv2 directory is missing"
19-
exit
19+
exit 1
2020
fi
2121

2222
if [ ! -d ${LV2DIR}/mod-license.lv2 ]; then
2323
echo "${LV2DIR}/mod-license.lv2 directory is missing"
24-
exit
24+
exit 1
2525
fi
2626

2727
if [ -z "${1}" ]; then

pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "mod-lilvlib"
7+
version = "1.1.0"
8+
description = "A set of helper methods to extract plugin and pedalboard data from TTLs using lilv"
9+
readme = "README.md"
10+
license = {text = "MIT"}
11+
authors = [
12+
{ name = "Falktx", email = "falktx@mod.audio" }
13+
]
14+
classifiers = [
15+
"Intended Audience :: Developers",
16+
"License :: OSI Approved :: MIT License",
17+
"Natural Language :: English",
18+
"Operating System :: OS Independent",
19+
"Programming Language :: Python",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
]
25+
26+
[project.urls]
27+
Homepage = "https://github.com/mod-audio/lilvlib"
28+
Repository = "https://github.com/mod-audio/lilvlib"
29+
30+
[project.scripts]
31+
lilvlib = "lilvlib.lilvlib:main"
32+
33+
[tool.setuptools.packages.find]
34+
include = ["lilvlib*"]

scripts/build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -e
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
6+
DIST_DIR="${DIST_DIR:-$ROOT_DIR/dist}"
7+
8+
cd "$ROOT_DIR"
9+
10+
echo "==> Building python3-lilv debian package..."
11+
./build-python3-lilv.sh
12+
13+
echo "==> Building wheel..."
14+
mkdir -p "$DIST_DIR"
15+
pip3 install --upgrade pip
16+
pip3 wheel --no-deps -w "$DIST_DIR" .
17+
18+
echo "==> Copying debian package to $DIST_DIR..."
19+
cp python3-lilv_*.deb "$DIST_DIR/"
20+
21+
echo "==> Build complete. Artifacts in $DIST_DIR:"
22+
ls -la "$DIST_DIR"

scripts/test.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
set -e
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
6+
DIST_DIR="${DIST_DIR:-$ROOT_DIR/dist}"
7+
VENV_DIR="${VENV_DIR:-/tmp/test-venv}"
8+
9+
echo "==> Creating virtual environment..."
10+
python3 -m venv --system-site-packages "$VENV_DIR"
11+
source "$VENV_DIR/bin/activate"
12+
pip install --upgrade pip
13+
14+
echo "==> Installing debian package..."
15+
dpkg -i "$DIST_DIR"/python3-lilv_*.deb
16+
17+
echo "==> Installing wheel..."
18+
pip install "$DIST_DIR"/mod_lilvlib-*.whl
19+
20+
echo "==> Testing imports..."
21+
python -c "import lilv; print('lilv import OK')"
22+
python -c "import lilvlib; print('lilvlib import OK, version:', lilvlib.__version__)"
23+
24+
echo "==> Testing CLI..."
25+
which lilvlib
26+
27+
echo "==> Running test script..."
28+
cd "$ROOT_DIR"
29+
python test.py
30+
31+
echo "==> Running pylint..."
32+
pip install pylint
33+
pylint -E lilvlib/lilvlib.py
34+
35+
echo "==> All tests passed"

setup.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)