Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
75e8202
packaging: scaffold python3 noarch DEB (smoke-test enabled)
shiptux May 12, 2026
a4abb6b
packaging: relax torch to Recommends + add RPM spec + find_spec smoke
shiptux May 20, 2026
a848fb6
fix(packaging): add Requires: python3-numpy to RPM; remove CURDIR fal…
shiptux May 21, 2026
fe65c59
fix(packaging): decouple tar transform from source dir; drop redundan…
shiptux May 21, 2026
0576583
fix(packaging): preserve pip3 install stderr in Dockerfile.deb
shiptux May 21, 2026
394b556
fix(packaging): drop policy-violating pip install hack; bump base to …
shiptux May 21, 2026
2e83cf0
fix(packaging): align build script default base to 24.04 (was 22.04, …
shiptux May 21, 2026
92caf6b
ci(packaging): add build-deb.yml + build-rpm.yml
shiptux May 21, 2026
32dab44
fix(packaging): rewrite find_spec test with found_dir+break; qualify …
shiptux May 21, 2026
456654e
fix(packaging): preserve build stderr in Dockerfile.deb (consistency …
shiptux May 21, 2026
1c01434
fix(packaging): replace ${python3:Depends} with python3:any; filter t…
shiptux May 22, 2026
bdff11f
fix(packaging): refine RPM exclude comment; Source0 fedora-style
shiptux May 22, 2026
7d237c0
fix(packaging): drop -d from dpkg-buildpackage (#9); CI trigger on sr…
shiptux May 22, 2026
41da12a
fix(packaging): %license LICENSE (drop wildcard, only one license fil…
shiptux May 22, 2026
86d5d6e
fix(packaging): round 17-20 cleanup (regex tighten + INSTALL.md + lin…
shiptux May 22, 2026
83e0e02
fix(packaging): drop stale history note from debian/rules
shiptux May 27, 2026
0102c10
fix(packaging): set PYTHONSAFEPATH in find_spec smoke checks
shiptux May 27, 2026
f0112c1
fix(packaging): drop trailing blank line in debian/rules (end-of-file…
shiptux Jun 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Debian Packages

on:
push:
tags:
- 'v*'
pull_request:
branches: [main]
paths:
- 'packaging/debian/**'
- 'flagquantum/**'
- 'pyproject.toml'
- '.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
36 changes: 36 additions & 0 deletions .github/workflows/build-rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build RPM Packages

on:
push:
tags:
- 'v*'
pull_request:
branches: [main]
paths:
- 'packaging/rpm/**'
- 'flagquantum/**'
- 'pyproject.toml'
- '.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
25 changes: 25 additions & 0 deletions packaging/INSTALL.md
Original file line number Diff line number Diff line change
@@ -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`.
32 changes: 32 additions & 0 deletions packaging/debian/build-helpers/Dockerfile.deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG BASE_IMAGE_VERSION=24.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 \
lintian \
&& apt-get clean && rm -rf /var/lib/apt/lists/*


COPY . /workspace/FlagQuantum
WORKDIR /workspace/FlagQuantum

RUN cp -r packaging/debian debian

RUN dpkg-buildpackage -us -uc -b || \
{ echo "=== build failed ===" >&2; \
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/ \; && \
ls -lh /output/
19 changes: 19 additions & 0 deletions packaging/debian/build-helpers/build-flagquantum.sh
Original file line number Diff line number Diff line change
@@ -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:-24.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"
5 changes: 5 additions & 0 deletions packaging/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flagquantum (0.1.0-1) unstable; urgency=medium

* Initial Debian packaging.

-- FlagOS Contributors <contact@flagos.io> Tue, 12 May 2026 12:00:00 +0000
23 changes: 23 additions & 0 deletions packaging/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Source: flagquantum
Section: python
Priority: optional
Maintainer: FlagOS Contributors <contact@flagos.io>
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: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.
23 changes: 23 additions & 0 deletions packaging/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: FlagQuantum
Upstream-Contact: FlagOS Contributors <contact@flagos.io>
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.
31 changes: 31 additions & 0 deletions packaging/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export PYBUILD_NAME = flagquantum

%:
dh $@ --with python3 --buildsystem=pybuild

# 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.
override_dh_auto_test:
@echo "=== smoke find_spec test ==="
# 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 \
found_dir="$$d"; \
break; \
fi; \
done; \
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 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)"
1 change: 1 addition & 0 deletions packaging/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
19 changes: 19 additions & 0 deletions packaging/rpm/build-flagquantum-rpm.sh
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 30 additions & 0 deletions packaging/rpm/dockerfiles/Dockerfile.rpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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/FlagQuantum \
--exclude='./.git' \
--transform "s|^\./|flagquantum-${SPEC_VERSION}/|" \
.

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/
55 changes: 55 additions & 0 deletions packaging/rpm/specs/flagquantum.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
%global debug_package %{nil}

# 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(\.[0-9]+)?dist\((torch)\)$
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: %{url}/archive/refs/tags/v%{version}.tar.gz#/flagquantum-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-setuptools >= 60
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.

%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.
# 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)"

%files -f %{pyproject_files}
%license LICENSE

%changelog
* Wed May 13 2026 FlagOS Contributors <contact@flagos.io> - 0.1.0-1
- Initial RPM packaging.