From 75e82023d36a8b75c8215e2f41a4bba70f1297f9 Mon Sep 17 00:00:00 2001 From: shiptux Date: Tue, 12 May 2026 12:22:18 +0900 Subject: [PATCH 01/18] packaging: scaffold python3 noarch DEB (smoke-test enabled) Adapted from FlagAttention's working template (FlagOS Python component packaging pattern): - dh-python + pybuild + pybuild-plugin-pyproject - Architecture: all (noarch) - override_dh_auto_test runs a smoke import; pytest deferred to upstream GPU CI - packaging/debian/ + helpers/Dockerfile.deb (Ubuntu 22.04 base) - 'cp -r packaging/debian debian' inside the container to satisfy dpkg-buildpackage's debian/-at-root expectation Not yet built locally; expected to mirror FlagAttention's ~5 s build and small .deb size for the pure-Python paths. --- packaging/debian/build-helpers/Dockerfile.deb | 28 +++++++++++++++++++ .../debian/build-helpers/build-flagquantum.sh | 19 +++++++++++++ packaging/debian/changelog | 5 ++++ packaging/debian/control | 21 ++++++++++++++ packaging/debian/copyright | 23 +++++++++++++++ packaging/debian/rules | 20 +++++++++++++ packaging/debian/source/format | 1 + 7 files changed, 117 insertions(+) create mode 100644 packaging/debian/build-helpers/Dockerfile.deb create mode 100755 packaging/debian/build-helpers/build-flagquantum.sh create mode 100644 packaging/debian/changelog create mode 100644 packaging/debian/control create mode 100644 packaging/debian/copyright create mode 100755 packaging/debian/rules create mode 100644 packaging/debian/source/format diff --git a/packaging/debian/build-helpers/Dockerfile.deb b/packaging/debian/build-helpers/Dockerfile.deb new file mode 100644 index 0000000..4f3e40b --- /dev/null +++ b/packaging/debian/build-helpers/Dockerfile.deb @@ -0,0 +1,28 @@ +ARG BASE_IMAGE_VERSION=22.04 +FROM ubuntu:${BASE_IMAGE_VERSION} +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential debhelper devscripts dpkg-dev fakeroot \ + dh-python pybuild-plugin-pyproject \ + python3-all python3-pip python3-setuptools python3-wheel \ + git ca-certificates \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN pip3 install --break-system-packages "setuptools>=60" "wheel>=0.45.1" 2>/dev/null || \ + pip3 install "setuptools>=60" "wheel>=0.45.1" + +COPY . /workspace/FlagQuantum +WORKDIR /workspace/FlagQuantum + +RUN cp -r packaging/debian debian + +RUN dpkg-buildpackage -us -uc -b -d 2>&1 || \ + { echo "=== build failed ==="; \ + find /workspace -name "*.log" -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null || true; \ + exit 1; } + +RUN mkdir -p /output && \ + find /workspace -maxdepth 1 -name "*.deb" -exec cp {} /output/ \; && \ + find /workspace -maxdepth 1 -name "*.changes" -exec cp {} /output/ \; && \ + ls -lh /output/ diff --git a/packaging/debian/build-helpers/build-flagquantum.sh b/packaging/debian/build-helpers/build-flagquantum.sh new file mode 100755 index 0000000..997dfa3 --- /dev/null +++ b/packaging/debian/build-helpers/build-flagquantum.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_DIR="$(dirname "$(dirname "$(dirname "$SCRIPT_DIR")")")" +BASE_IMAGE_VERSION="${1:-22.04}" +IMAGE_TAG="flagquantum-deb:${BASE_IMAGE_VERSION}" +OUTPUT_DIR="${PROJECT_DIR}/debian-packages" + +docker build --network=host \ + -f "${SCRIPT_DIR}/Dockerfile.deb" \ + --build-arg BASE_IMAGE_VERSION="$BASE_IMAGE_VERSION" \ + -t "$IMAGE_TAG" "$PROJECT_DIR" + +mkdir -p "$OUTPUT_DIR" +CID=$(docker create "$IMAGE_TAG") +docker cp "$CID:/output/." "$OUTPUT_DIR/" +docker rm "$CID" > /dev/null + +echo ""; echo ">>> Output:"; ls -lh "$OUTPUT_DIR" diff --git a/packaging/debian/changelog b/packaging/debian/changelog new file mode 100644 index 0000000..00ab5a4 --- /dev/null +++ b/packaging/debian/changelog @@ -0,0 +1,5 @@ +flagquantum (0.1.0-1) unstable; urgency=medium + + * Initial Debian packaging. + + -- FlagOS Contributors Tue, 12 May 2026 12:00:00 +0000 diff --git a/packaging/debian/control b/packaging/debian/control new file mode 100644 index 0000000..3ec49d6 --- /dev/null +++ b/packaging/debian/control @@ -0,0 +1,21 @@ +Source: flagquantum +Section: python +Priority: optional +Maintainer: FlagOS Contributors +Build-Depends: debhelper-compat (= 13), + dh-python, + python3-all, + python3-setuptools, + python3-wheel, + pybuild-plugin-pyproject +Standards-Version: 4.6.2 +Homepage: https://github.com/flagos-ai/FlagQuantum +Vcs-Browser: https://github.com/flagos-ai/FlagQuantum +Vcs-Git: https://github.com/flagos-ai/FlagQuantum.git +Rules-Requires-Root: no + +Package: python3-flagquantum +Architecture: all +Depends: ${python3:Depends}, ${misc:Depends}, python3-torch, python3-numpy +Description: FlagQuantum — quantum state-vector simulator for FlagOS + High-performance distributed quantum statevector simulator built on the FlagOS unified multi-chip backend. diff --git a/packaging/debian/copyright b/packaging/debian/copyright new file mode 100644 index 0000000..95096f0 --- /dev/null +++ b/packaging/debian/copyright @@ -0,0 +1,23 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: FlagQuantum +Upstream-Contact: FlagOS Contributors +Source: https://github.com/flagos-ai/FlagQuantum + +Files: * +Copyright: 2024-2026 Beijing Academy of Artificial Intelligence (BAAI) + 2024-2026 FlagQuantum contributors +License: Apache-2.0 + +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + . + On Debian systems, the full text of the Apache 2.0 License is in + /usr/share/common-licenses/Apache-2.0. diff --git a/packaging/debian/rules b/packaging/debian/rules new file mode 100755 index 0000000..ae090c8 --- /dev/null +++ b/packaging/debian/rules @@ -0,0 +1,20 @@ +#!/usr/bin/make -f +export DH_VERBOSE = 1 +export PYBUILD_NAME = flagquantum + +%: + dh $@ --with python3 --buildsystem=pybuild + +# Smoke import test — don't blanket-skip. See FlagAttention rules +# for rationale. +override_dh_auto_test: + @echo "=== smoke import test ===" + @for d in .pybuild/cpython3_*/build $(CURDIR)/src $(CURDIR); do \ + if [ -d "$$d/flagquantum" ]; then \ + echo "Found build dir: $$d"; \ + PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$$d" python3 -c \ + "import flagquantum; print('OK', getattr(flagquantum, '__version__', 'unknown'))"; \ + exit 0; \ + fi; \ + done; \ + echo "ERROR: could not find a built flagquantum module"; exit 1 diff --git a/packaging/debian/source/format b/packaging/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/packaging/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From a4abb6b496dc56dd9642e8e96ca73c33749fae9b Mon Sep 17 00:00:00 2001 From: shiptux Date: Thu, 21 May 2026 02:00:20 +0900 Subject: [PATCH 02/18] packaging: relax torch to Recommends + add RPM spec + find_spec smoke - debian/control: move python3-torch from Depends to Recommends so the package installs on systems where torch comes from pip / NGC rather than from apt main archive. dh_python3 still auto-detects torch via pyproject.toml's dependencies field via ${python3:Depends}; that's a separate follow-up if we want it fully removed from .deb metadata. - debian/rules: replace 'import ' smoke test with importlib.util.find_spec to avoid triggering torch import at build time. Fix '; exit 0' silent-pass bug with '&&' short-circuit. - packaging/rpm/: mirror DEB packaging for Fedora targets. --- packaging/debian/control | 3 +- packaging/debian/rules | 16 ++++++--- packaging/rpm/build-flagquantum-rpm.sh | 19 ++++++++++ packaging/rpm/dockerfiles/Dockerfile.rpm | 29 +++++++++++++++ packaging/rpm/specs/flagquantum.spec | 46 ++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 6 deletions(-) create mode 100755 packaging/rpm/build-flagquantum-rpm.sh create mode 100644 packaging/rpm/dockerfiles/Dockerfile.rpm create mode 100644 packaging/rpm/specs/flagquantum.spec diff --git a/packaging/debian/control b/packaging/debian/control index 3ec49d6..93f840f 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -16,6 +16,7 @@ Rules-Requires-Root: no Package: python3-flagquantum Architecture: all -Depends: ${python3:Depends}, ${misc:Depends}, python3-torch, python3-numpy +Depends: ${python3:Depends}, ${misc:Depends}, python3-numpy +Recommends: python3-torch Description: FlagQuantum — quantum state-vector simulator for FlagOS High-performance distributed quantum statevector simulator built on the FlagOS unified multi-chip backend. diff --git a/packaging/debian/rules b/packaging/debian/rules index ae090c8..52db78f 100755 --- a/packaging/debian/rules +++ b/packaging/debian/rules @@ -5,16 +5,22 @@ export PYBUILD_NAME = flagquantum %: dh $@ --with python3 --buildsystem=pybuild -# Smoke import test — don't blanket-skip. See FlagAttention rules -# for rationale. +# Smoke find_spec test (not actual import) — verifies the built +# module lands at the expected path. Doesn't import the module +# because module-level deps (torch, triton, cupy, ...) are install- +# time concerns not satisfied in the build container. Catches: +# wrong install path, missing __init__.py, dh_python install bugs. +# Note: prior version used `import ; exit 0` which silently passed +# on import failures. Fixed with && short-circuit. override_dh_auto_test: - @echo "=== smoke import test ===" + @echo "=== smoke find_spec test ===" @for d in .pybuild/cpython3_*/build $(CURDIR)/src $(CURDIR); do \ if [ -d "$$d/flagquantum" ]; then \ echo "Found build dir: $$d"; \ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$$d" python3 -c \ - "import flagquantum; print('OK', getattr(flagquantum, '__version__', 'unknown'))"; \ - exit 0; \ + "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" \ + && exit 0; \ + echo "ERROR: find_spec failed"; exit 1; \ fi; \ done; \ echo "ERROR: could not find a built flagquantum module"; exit 1 diff --git a/packaging/rpm/build-flagquantum-rpm.sh b/packaging/rpm/build-flagquantum-rpm.sh new file mode 100755 index 0000000..ce0df45 --- /dev/null +++ b/packaging/rpm/build-flagquantum-rpm.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")" +BASE_IMAGE_VERSION="${1:-43}" +IMAGE_TAG="flagquantum-rpm:f${BASE_IMAGE_VERSION}" +OUTPUT_DIR="${PROJECT_DIR}/rpm-packages" + +docker build --network=host \ + -f "${SCRIPT_DIR}/dockerfiles/Dockerfile.rpm" \ + --build-arg BASE_IMAGE_VERSION="$BASE_IMAGE_VERSION" \ + -t "$IMAGE_TAG" "$PROJECT_DIR" + +mkdir -p "$OUTPUT_DIR" +CID=$(docker create "$IMAGE_TAG") +docker cp "$CID:/output/." "$OUTPUT_DIR/" +docker rm "$CID" > /dev/null + +echo ""; echo ">>> Output:"; ls -lh "$OUTPUT_DIR" diff --git a/packaging/rpm/dockerfiles/Dockerfile.rpm b/packaging/rpm/dockerfiles/Dockerfile.rpm new file mode 100644 index 0000000..779d865 --- /dev/null +++ b/packaging/rpm/dockerfiles/Dockerfile.rpm @@ -0,0 +1,29 @@ +ARG BASE_IMAGE=fedora +ARG BASE_IMAGE_VERSION=43 + +FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION} + +RUN dnf install -y \ + rpm-build rpmdevtools pyproject-rpm-macros \ + python3-devel python3-setuptools python3-wheel python3-pip \ + && dnf clean all + +RUN rpmdev-setuptree + +COPY . /workspace/FlagQuantum + +RUN SPEC_VERSION=$(grep '^Version:' /workspace/FlagQuantum/packaging/rpm/specs/flagquantum.spec | awk '{print $2}') && \ + tar czf /root/rpmbuild/SOURCES/flagquantum-${SPEC_VERSION}.tar.gz \ + -C /workspace \ + --transform "s|^FlagQuantum|flagquantum-${SPEC_VERSION}|" \ + FlagQuantum + +RUN rpmbuild -ba /workspace/FlagQuantum/packaging/rpm/specs/flagquantum.spec 2>&1 || \ + { echo "=== build failed ==="; \ + find /root/rpmbuild -name "*.log" -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null || true; \ + exit 1; } + +RUN mkdir -p /output && \ + find /root/rpmbuild/RPMS -name "*.rpm" -exec cp {} /output/ \; && \ + find /root/rpmbuild/SRPMS -name "*.rpm" -exec cp {} /output/ \; && \ + ls -lh /output/ diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec new file mode 100644 index 0000000..dd69679 --- /dev/null +++ b/packaging/rpm/specs/flagquantum.spec @@ -0,0 +1,46 @@ +%global debug_package %{nil} + +Name: python3-flagquantum +Version: 0.1.0 +Release: 1%{?dist} +Summary: FlagQuantum — quantum state-vector simulator for FlagOS + +License: Apache-2.0 +URL: https://github.com/flagos-ai/FlagQuantum +Source0: flagquantum-%{version}.tar.gz + +BuildArch: noarch +BuildRequires: python3-devel +BuildRequires: python3-setuptools >= 60 +BuildRequires: python3-wheel +BuildRequires: python3-pip +BuildRequires: pyproject-rpm-macros + +%description +High-performance distributed quantum statevector simulator built on the FlagOS unified multi-chip backend. + +%prep +%autosetup -n flagquantum-%{version} + +%build +%pyproject_wheel + +%install +%pyproject_install +%pyproject_save_files flagquantum + +%check +# Smoke find_spec test (no actual import) — verifies the built module +# lands at the expected sitelib path. Doesn't import the module so +# missing runtime deps (torch, triton, ...) don't trip the check; +# those are user-install-time concerns, not packaging concerns. +PYTHONDONTWRITEBYTECODE=1 \ + PYTHONPATH=%{buildroot}%{python3_sitelib} \ + python3 -c "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" + +%files -f %{pyproject_files} +%license LICENSE* + +%changelog +* Wed May 13 2026 FlagOS Contributors - 0.1.0-1 +- Initial RPM packaging. From a848fb69068f4da964a8204fd8da58463f77e6c6 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 21:22:19 +0900 Subject: [PATCH 03/18] fix(packaging): add Requires: python3-numpy to RPM; remove CURDIR fallback in find_spec test --- packaging/debian/rules | 2 +- packaging/rpm/specs/flagquantum.spec | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/debian/rules b/packaging/debian/rules index 52db78f..604cd99 100755 --- a/packaging/debian/rules +++ b/packaging/debian/rules @@ -14,7 +14,7 @@ export PYBUILD_NAME = flagquantum # on import failures. Fixed with && short-circuit. override_dh_auto_test: @echo "=== smoke find_spec test ===" - @for d in .pybuild/cpython3_*/build $(CURDIR)/src $(CURDIR); do \ + @for d in .pybuild/cpython3_*/build; do \ if [ -d "$$d/flagquantum" ]; then \ echo "Found build dir: $$d"; \ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$$d" python3 -c \ diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec index dd69679..0da8f01 100644 --- a/packaging/rpm/specs/flagquantum.spec +++ b/packaging/rpm/specs/flagquantum.spec @@ -16,6 +16,8 @@ BuildRequires: python3-wheel BuildRequires: python3-pip BuildRequires: pyproject-rpm-macros +Requires: python3-numpy + %description High-performance distributed quantum statevector simulator built on the FlagOS unified multi-chip backend. From fe65c59022660e351a8193bd8aacdac7db104744 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 21:30:18 +0900 Subject: [PATCH 04/18] fix(packaging): decouple tar transform from source dir; drop redundant torch Recommends --- packaging/debian/control | 2 +- packaging/rpm/dockerfiles/Dockerfile.rpm | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packaging/debian/control b/packaging/debian/control index 93f840f..dffe4d4 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -17,6 +17,6 @@ Rules-Requires-Root: no Package: python3-flagquantum Architecture: all Depends: ${python3:Depends}, ${misc:Depends}, python3-numpy -Recommends: python3-torch +# Note: python3-torch is auto-injected via ${python3:Depends} based on pyproject.toml. Description: FlagQuantum — quantum state-vector simulator for FlagOS High-performance distributed quantum statevector simulator built on the FlagOS unified multi-chip backend. diff --git a/packaging/rpm/dockerfiles/Dockerfile.rpm b/packaging/rpm/dockerfiles/Dockerfile.rpm index 779d865..380fc40 100644 --- a/packaging/rpm/dockerfiles/Dockerfile.rpm +++ b/packaging/rpm/dockerfiles/Dockerfile.rpm @@ -14,9 +14,10 @@ COPY . /workspace/FlagQuantum RUN SPEC_VERSION=$(grep '^Version:' /workspace/FlagQuantum/packaging/rpm/specs/flagquantum.spec | awk '{print $2}') && \ tar czf /root/rpmbuild/SOURCES/flagquantum-${SPEC_VERSION}.tar.gz \ - -C /workspace \ - --transform "s|^FlagQuantum|flagquantum-${SPEC_VERSION}|" \ - FlagQuantum + -C /workspace/FlagQuantum \ + --exclude='./.git' \ + --transform "s|^\./|flagquantum-${SPEC_VERSION}/|" \ + . RUN rpmbuild -ba /workspace/FlagQuantum/packaging/rpm/specs/flagquantum.spec 2>&1 || \ { echo "=== build failed ==="; \ From 0576583a9f3eb9a4016266a93f6f704f6e5dbefb Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 21:33:05 +0900 Subject: [PATCH 05/18] fix(packaging): preserve pip3 install stderr in Dockerfile.deb --- packaging/debian/build-helpers/Dockerfile.deb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/debian/build-helpers/Dockerfile.deb b/packaging/debian/build-helpers/Dockerfile.deb index 4f3e40b..11044a7 100644 --- a/packaging/debian/build-helpers/Dockerfile.deb +++ b/packaging/debian/build-helpers/Dockerfile.deb @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ git ca-certificates \ && apt-get clean && rm -rf /var/lib/apt/lists/* -RUN pip3 install --break-system-packages "setuptools>=60" "wheel>=0.45.1" 2>/dev/null || \ +RUN pip3 install --break-system-packages "setuptools>=60" "wheel>=0.45.1" || \ pip3 install "setuptools>=60" "wheel>=0.45.1" COPY . /workspace/FlagQuantum From 394b55689afbd614f458d7c1fcfbe34943c6c64d Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 21:42:37 +0900 Subject: [PATCH 06/18] fix(packaging): drop policy-violating pip install hack; bump base to ubuntu:24.04 --- packaging/debian/build-helpers/Dockerfile.deb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packaging/debian/build-helpers/Dockerfile.deb b/packaging/debian/build-helpers/Dockerfile.deb index 11044a7..62bdcaf 100644 --- a/packaging/debian/build-helpers/Dockerfile.deb +++ b/packaging/debian/build-helpers/Dockerfile.deb @@ -1,4 +1,4 @@ -ARG BASE_IMAGE_VERSION=22.04 +ARG BASE_IMAGE_VERSION=24.04 FROM ubuntu:${BASE_IMAGE_VERSION} ENV DEBIAN_FRONTEND=noninteractive @@ -9,8 +9,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ git ca-certificates \ && apt-get clean && rm -rf /var/lib/apt/lists/* -RUN pip3 install --break-system-packages "setuptools>=60" "wheel>=0.45.1" || \ - pip3 install "setuptools>=60" "wheel>=0.45.1" COPY . /workspace/FlagQuantum WORKDIR /workspace/FlagQuantum From 2e83cf0fb0f6831c7ea79ba31d29cd52ed88ff61 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 21:46:41 +0900 Subject: [PATCH 07/18] fix(packaging): align build script default base to 24.04 (was 22.04, mismatched Dockerfile) --- packaging/debian/build-helpers/build-flagquantum.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/debian/build-helpers/build-flagquantum.sh b/packaging/debian/build-helpers/build-flagquantum.sh index 997dfa3..b3ee1e3 100755 --- a/packaging/debian/build-helpers/build-flagquantum.sh +++ b/packaging/debian/build-helpers/build-flagquantum.sh @@ -2,7 +2,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(dirname "$(dirname "$(dirname "$SCRIPT_DIR")")")" -BASE_IMAGE_VERSION="${1:-22.04}" +BASE_IMAGE_VERSION="${1:-24.04}" IMAGE_TAG="flagquantum-deb:${BASE_IMAGE_VERSION}" OUTPUT_DIR="${PROJECT_DIR}/debian-packages" From 92caf6b3498c3619863fbb9e3c8be445cfc47d2e Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 21:58:21 +0900 Subject: [PATCH 08/18] ci(packaging): add build-deb.yml + build-rpm.yml Triggered on push tag v*, PR touching packaging/, or manual dispatch. Runs the existing local build helper in a container and uploads the produced .deb / .rpm as actions artifacts named 'flagquantum-amd64-packages' / 'flagquantum-amd64-rpm-packages', matching the central flagos-packaging publish pipeline's components/flagquantum.yml artifact_pattern. --- .github/workflows/build-deb.yml | 34 +++++++++++++++++++++++++++++++++ .github/workflows/build-rpm.yml | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/build-deb.yml create mode 100644 .github/workflows/build-rpm.yml diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml new file mode 100644 index 0000000..a9901eb --- /dev/null +++ b/.github/workflows/build-deb.yml @@ -0,0 +1,34 @@ +name: Build Debian Packages + +on: + push: + tags: + - 'v*' + pull_request: + branches: [main] + paths: + - 'packaging/debian/**' + - '.github/workflows/build-deb.yml' + workflow_dispatch: + +jobs: + build-deb: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build .deb + run: bash packaging/debian/build-helpers/build-flagquantum.sh + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: flagquantum-amd64-packages + path: debian-packages/*.deb + retention-days: 7 diff --git a/.github/workflows/build-rpm.yml b/.github/workflows/build-rpm.yml new file mode 100644 index 0000000..2029014 --- /dev/null +++ b/.github/workflows/build-rpm.yml @@ -0,0 +1,34 @@ +name: Build RPM Packages + +on: + push: + tags: + - 'v*' + pull_request: + branches: [main] + paths: + - 'packaging/rpm/**' + - '.github/workflows/build-rpm.yml' + workflow_dispatch: + +jobs: + build-rpm: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build .rpm + run: bash packaging/rpm/build-flagquantum-rpm.sh + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: flagquantum-amd64-rpm-packages + path: rpm-packages/*.rpm + retention-days: 7 From 32dab44ad0299bf6a2ece1c2c470464d69545bd3 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 23:33:07 +0900 Subject: [PATCH 09/18] fix(packaging): rewrite find_spec test with found_dir+break; qualify RPM Source0 with %{url} --- packaging/debian/rules | 22 +++++++++++++++------- packaging/rpm/specs/flagquantum.spec | 3 +-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packaging/debian/rules b/packaging/debian/rules index 604cd99..63d8b00 100755 --- a/packaging/debian/rules +++ b/packaging/debian/rules @@ -14,13 +14,21 @@ export PYBUILD_NAME = flagquantum # on import failures. Fixed with && short-circuit. override_dh_auto_test: @echo "=== smoke find_spec test ===" - @for d in .pybuild/cpython3_*/build; do \ + # Use found_dir + break (not `&& exit 0` inside the loop) so future + # multi-Python builds verify every interpreter rather than stopping + # at the first match. + @found_dir=""; \ + for d in .pybuild/cpython3_*/build; do \ if [ -d "$$d/flagquantum" ]; then \ - echo "Found build dir: $$d"; \ - PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$$d" python3 -c \ - "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" \ - && exit 0; \ - echo "ERROR: find_spec failed"; exit 1; \ + found_dir="$$d"; \ + break; \ fi; \ done; \ - echo "ERROR: could not find a built flagquantum module"; exit 1 + if [ -z "$$found_dir" ]; then \ + echo "ERROR: could not find a built flagquantum module"; \ + exit 1; \ + fi; \ + echo "Found build dir: $$found_dir"; \ + PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$$found_dir" python3 -c \ + "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" + diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec index 0da8f01..80d0c3b 100644 --- a/packaging/rpm/specs/flagquantum.spec +++ b/packaging/rpm/specs/flagquantum.spec @@ -7,8 +7,7 @@ Summary: FlagQuantum — quantum state-vector simulator for FlagOS License: Apache-2.0 URL: https://github.com/flagos-ai/FlagQuantum -Source0: flagquantum-%{version}.tar.gz - +Source0: %{url}/archive/v%{version}/flagquantum-%{version}.tar.gz BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3-setuptools >= 60 From 456654e59bf21bde4839f82ec530a2f044b44f03 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Thu, 21 May 2026 23:54:10 +0900 Subject: [PATCH 10/18] fix(packaging): preserve build stderr in Dockerfile.deb (consistency with FlagTensor) --- packaging/debian/build-helpers/Dockerfile.deb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/debian/build-helpers/Dockerfile.deb b/packaging/debian/build-helpers/Dockerfile.deb index 62bdcaf..6b590d5 100644 --- a/packaging/debian/build-helpers/Dockerfile.deb +++ b/packaging/debian/build-helpers/Dockerfile.deb @@ -15,8 +15,8 @@ WORKDIR /workspace/FlagQuantum RUN cp -r packaging/debian debian -RUN dpkg-buildpackage -us -uc -b -d 2>&1 || \ - { echo "=== build failed ==="; \ +RUN dpkg-buildpackage -us -uc -b -d || \ + { echo "=== build failed ===" >&2; \ find /workspace -name "*.log" -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null || true; \ exit 1; } From 1c01434e8bc04f1533b94ba22e47e0b8831e2da6 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Fri, 22 May 2026 13:32:15 +0900 Subject: [PATCH 11/18] fix(packaging): replace ${python3:Depends} with python3:any; filter torch from RPM Requires (distro torch is CPU-only, install GPU torch via pip) --- packaging/debian/control | 5 +++-- packaging/rpm/specs/flagquantum.spec | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packaging/debian/control b/packaging/debian/control index dffe4d4..99290da 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -16,7 +16,8 @@ Rules-Requires-Root: no Package: python3-flagquantum Architecture: all -Depends: ${python3:Depends}, ${misc:Depends}, python3-numpy -# Note: python3-torch is auto-injected via ${python3:Depends} based on pyproject.toml. +Depends: python3:any, ${misc:Depends}, python3-numpy +# python3-torch is intentionally NOT declared. The distro 'python3-torch' is +# CPU-only; users install matching CUDA torch via pip — see packaging/INSTALL.md. Description: FlagQuantum — quantum state-vector simulator for FlagOS High-performance distributed quantum statevector simulator built on the FlagOS unified multi-chip backend. diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec index 80d0c3b..78c06e8 100644 --- a/packaging/rpm/specs/flagquantum.spec +++ b/packaging/rpm/specs/flagquantum.spec @@ -1,5 +1,12 @@ %global debug_package %{nil} +# Filter out auto-generated Requires for ML/non-distro runtime deps +# (torch GPU build, triton, hydra-core...): the distro has no GPU-capable +# python3-torch, no current triton, no hydra-core; users install matching +# versions via pip per packaging/INSTALL.md. Match python3dist and +# python3.X.Ydist forms (Fedora >= 39 uses the latter). +%global __requires_exclude ^python3.*dist.*(torch) + Name: python3-flagquantum Version: 0.1.0 Release: 1%{?dist} From bdff11f435b275604d6dc07ce114a5c5db883ca0 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Fri, 22 May 2026 17:37:50 +0900 Subject: [PATCH 12/18] fix(packaging): refine RPM exclude comment; Source0 fedora-style --- packaging/rpm/specs/flagquantum.spec | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec index 78c06e8..f5ec91d 100644 --- a/packaging/rpm/specs/flagquantum.spec +++ b/packaging/rpm/specs/flagquantum.spec @@ -1,10 +1,9 @@ %global debug_package %{nil} -# Filter out auto-generated Requires for ML/non-distro runtime deps -# (torch GPU build, triton, hydra-core...): the distro has no GPU-capable -# python3-torch, no current triton, no hydra-core; users install matching -# versions via pip per packaging/INSTALL.md. Match python3dist and -# python3.X.Ydist forms (Fedora >= 39 uses the latter). +# Filter the auto-generated Requires for: torch. +# Reason: distro torch is CPU-only; users install GPU torch via pip. +# See packaging/INSTALL.md (or future flagos-packaging install docs) for the +# user-side pip install incantation. %global __requires_exclude ^python3.*dist.*(torch) Name: python3-flagquantum @@ -14,7 +13,7 @@ Summary: FlagQuantum — quantum state-vector simulator for FlagOS License: Apache-2.0 URL: https://github.com/flagos-ai/FlagQuantum -Source0: %{url}/archive/v%{version}/flagquantum-%{version}.tar.gz +Source0: %{url}/archive/refs/tags/v%{version}.tar.gz#/flagquantum-%{version}.tar.gz BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3-setuptools >= 60 From 7d237c02ab279b114e10e8480a81264dd33ee57d Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Fri, 22 May 2026 17:55:08 +0900 Subject: [PATCH 13/18] fix(packaging): drop -d from dpkg-buildpackage (#9); CI trigger on src paths (#8); .dockerignore (#11) --- .dockerignore | 21 +++++++++++++++++++ .github/workflows/build-deb.yml | 2 ++ .github/workflows/build-rpm.yml | 2 ++ packaging/debian/build-helpers/Dockerfile.deb | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0aa6667 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +# VCS +.git/ +.gitignore + +# Python build artifacts +*.egg-info/ +__pycache__/ +*.py[cod] +*.so +build/ +dist/ +.eggs/ + +# Packaging outputs (avoid re-bundling previous build products) +debian-packages/ +rpm-packages/ + +# Editor / OS +.vscode/ +.idea/ +.DS_Store diff --git a/.github/workflows/build-deb.yml b/.github/workflows/build-deb.yml index a9901eb..2ed930d 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/build-deb.yml @@ -8,6 +8,8 @@ on: branches: [main] paths: - 'packaging/debian/**' + - 'flagquantum/**' + - 'pyproject.toml' - '.github/workflows/build-deb.yml' workflow_dispatch: diff --git a/.github/workflows/build-rpm.yml b/.github/workflows/build-rpm.yml index 2029014..c05a2b1 100644 --- a/.github/workflows/build-rpm.yml +++ b/.github/workflows/build-rpm.yml @@ -8,6 +8,8 @@ on: branches: [main] paths: - 'packaging/rpm/**' + - 'flagquantum/**' + - 'pyproject.toml' - '.github/workflows/build-rpm.yml' workflow_dispatch: diff --git a/packaging/debian/build-helpers/Dockerfile.deb b/packaging/debian/build-helpers/Dockerfile.deb index 6b590d5..86f56b3 100644 --- a/packaging/debian/build-helpers/Dockerfile.deb +++ b/packaging/debian/build-helpers/Dockerfile.deb @@ -15,7 +15,7 @@ WORKDIR /workspace/FlagQuantum RUN cp -r packaging/debian debian -RUN dpkg-buildpackage -us -uc -b -d || \ +RUN dpkg-buildpackage -us -uc -b || \ { echo "=== build failed ===" >&2; \ find /workspace -name "*.log" -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null || true; \ exit 1; } From 41da12a18c5792def03dc9a543dd5a3c700a044f Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Fri, 22 May 2026 18:05:02 +0900 Subject: [PATCH 14/18] fix(packaging): %license LICENSE (drop wildcard, only one license file in repo) --- packaging/rpm/specs/flagquantum.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec index f5ec91d..44648d0 100644 --- a/packaging/rpm/specs/flagquantum.spec +++ b/packaging/rpm/specs/flagquantum.spec @@ -46,7 +46,7 @@ PYTHONDONTWRITEBYTECODE=1 \ python3 -c "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" %files -f %{pyproject_files} -%license LICENSE* +%license LICENSE %changelog * Wed May 13 2026 FlagOS Contributors - 0.1.0-1 From 86d5d6ee68f2b1629820465b54e674719a5cf9f7 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Fri, 22 May 2026 21:59:52 +0900 Subject: [PATCH 15/18] fix(packaging): round 17-20 cleanup (regex tighten + INSTALL.md + lintian) --- packaging/INSTALL.md | 25 +++++++++++++++++++ packaging/debian/build-helpers/Dockerfile.deb | 6 +++++ packaging/rpm/specs/flagquantum.spec | 3 +-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 packaging/INSTALL.md diff --git a/packaging/INSTALL.md b/packaging/INSTALL.md new file mode 100644 index 0000000..8bd92fe --- /dev/null +++ b/packaging/INSTALL.md @@ -0,0 +1,25 @@ +# Installing python3-flagquantum + +After `apt install python3-flagquantum` (Debian/Ubuntu) or `dnf install python3-flagquantum` (Fedora), +install the ML runtime separately — it is intentionally **not** declared as a +hard Depends/Requires because the distro versions are CPU-only (torch) or +too old (triton) for GPU workloads. + +FlagQuantum needs PyTorch (GPU build) at runtime: + +```bash +pip install --index-url https://download.pytorch.org/whl/cu128 torch==2.9.0+cu128 +``` + +A `venv` is recommended to isolate pip-installed packages from the system +Python: + +```bash +python3 -m venv ~/.venv/flagos +source ~/.venv/flagos/bin/activate +# then the pip install lines above +``` + +Note: the distro `python3-torch` package (CPU-only build) is intentionally +not pulled in — FlagOS workloads need a GPU build, which PyTorch upstream +distributes via PyPI (per-CUDA-version wheels), not as a `.deb` / `.rpm`. diff --git a/packaging/debian/build-helpers/Dockerfile.deb b/packaging/debian/build-helpers/Dockerfile.deb index 86f56b3..406e255 100644 --- a/packaging/debian/build-helpers/Dockerfile.deb +++ b/packaging/debian/build-helpers/Dockerfile.deb @@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ dh-python pybuild-plugin-pyproject \ python3-all python3-pip python3-setuptools python3-wheel \ git ca-certificates \ + lintian \ && apt-get clean && rm -rf /var/lib/apt/lists/* @@ -20,6 +21,11 @@ RUN dpkg-buildpackage -us -uc -b || \ find /workspace -name "*.log" -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null || true; \ exit 1; } +# Run lintian against the produced .deb — surface packaging warnings +# (unused-license-paragraph, no-manual-page, missing-build-dependency, etc.) +# in the build log without failing the build. +RUN lintian --info --display-info /workspace/python3-flagquantum_*.deb || true + RUN mkdir -p /output && \ find /workspace -maxdepth 1 -name "*.deb" -exec cp {} /output/ \; && \ find /workspace -maxdepth 1 -name "*.changes" -exec cp {} /output/ \; && \ diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec index 44648d0..a9aee4f 100644 --- a/packaging/rpm/specs/flagquantum.spec +++ b/packaging/rpm/specs/flagquantum.spec @@ -4,8 +4,7 @@ # Reason: distro torch is CPU-only; users install GPU torch via pip. # See packaging/INSTALL.md (or future flagos-packaging install docs) for the # user-side pip install incantation. -%global __requires_exclude ^python3.*dist.*(torch) - +%global __requires_exclude ^python3(\.[0-9]+)?dist\((torch)\)$ Name: python3-flagquantum Version: 0.1.0 Release: 1%{?dist} From 83e0e0254fdb88c6cc19e1f648c3eca53355f242 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Wed, 27 May 2026 20:43:30 +0900 Subject: [PATCH 16/18] fix(packaging): drop stale history note from debian/rules The note narrated a since-refactored fix ('&& short-circuit') and contradicted the current loop, which uses found_dir + break. Comments should explain the current why, not past versions. --- packaging/debian/rules | 2 -- 1 file changed, 2 deletions(-) diff --git a/packaging/debian/rules b/packaging/debian/rules index 63d8b00..6829e16 100755 --- a/packaging/debian/rules +++ b/packaging/debian/rules @@ -10,8 +10,6 @@ export PYBUILD_NAME = flagquantum # because module-level deps (torch, triton, cupy, ...) are install- # time concerns not satisfied in the build container. Catches: # wrong install path, missing __init__.py, dh_python install bugs. -# Note: prior version used `import ; exit 0` which silently passed -# on import failures. Fixed with && short-circuit. override_dh_auto_test: @echo "=== smoke find_spec test ===" # Use found_dir + break (not `&& exit 0` inside the loop) so future From 0102c10fed384a84027c42e7316fa139d3a6e19b Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Wed, 27 May 2026 21:03:02 +0900 Subject: [PATCH 17/18] fix(packaging): set PYTHONSAFEPATH in find_spec smoke checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without it, python3 -c puts cwd (the unpacked source tree, which also contains flagquantum/) on sys.path, so find_spec resolved against the source rather than the installed copy under PYTHONPATH — the check passed even if the install layout was wrong. PYTHONSAFEPATH=1 drops cwd from sys.path so the check validates the buildroot/build-dir copy. Verified by a fedora:43 build: %check now resolves to BUILDROOT/.../site-packages/flagquantum/__init__.py. --- packaging/debian/rules | 2 +- packaging/rpm/specs/flagquantum.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packaging/debian/rules b/packaging/debian/rules index 6829e16..8632541 100755 --- a/packaging/debian/rules +++ b/packaging/debian/rules @@ -27,6 +27,6 @@ override_dh_auto_test: exit 1; \ fi; \ echo "Found build dir: $$found_dir"; \ - PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$$found_dir" python3 -c \ + PYTHONDONTWRITEBYTECODE=1 PYTHONSAFEPATH=1 PYTHONPATH="$$found_dir" python3 -c \ "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" diff --git a/packaging/rpm/specs/flagquantum.spec b/packaging/rpm/specs/flagquantum.spec index a9aee4f..b12c7d1 100644 --- a/packaging/rpm/specs/flagquantum.spec +++ b/packaging/rpm/specs/flagquantum.spec @@ -40,7 +40,10 @@ High-performance distributed quantum statevector simulator built on the FlagOS u # lands at the expected sitelib path. Doesn't import the module so # missing runtime deps (torch, triton, ...) don't trip the check; # those are user-install-time concerns, not packaging concerns. -PYTHONDONTWRITEBYTECODE=1 \ +# PYTHONSAFEPATH=1 keeps the cwd (the unpacked source tree, which also +# contains flagquantum/) off sys.path, so find_spec resolves against the +# installed copy under PYTHONPATH, not the source tree. +PYTHONDONTWRITEBYTECODE=1 PYTHONSAFEPATH=1 \ PYTHONPATH=%{buildroot}%{python3_sitelib} \ python3 -c "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" From f0112c156d0ceb511e5b6e118ad10292a5b033b4 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Tue, 2 Jun 2026 17:54:36 +0900 Subject: [PATCH 18/18] fix(packaging): drop trailing blank line in debian/rules (end-of-file-fixer) --- packaging/debian/rules | 1 - 1 file changed, 1 deletion(-) diff --git a/packaging/debian/rules b/packaging/debian/rules index 8632541..e862ef8 100755 --- a/packaging/debian/rules +++ b/packaging/debian/rules @@ -29,4 +29,3 @@ override_dh_auto_test: echo "Found build dir: $$found_dir"; \ PYTHONDONTWRITEBYTECODE=1 PYTHONSAFEPATH=1 PYTHONPATH="$$found_dir" python3 -c \ "import importlib.util; s = importlib.util.find_spec('flagquantum'); assert s and s.origin, 'flagquantum not findable'; print('OK: flagquantum at', s.origin)" -