Build, packaging, and release validation
The build and release system turns the Python chart API, the Rust compute core, and the browser render client into usable source distributions and platform wheels. It also checks that those artifacts preserve the public API, load the expected backend, support the Matplotlib compatibility surface, render in supported browser environments, and move from changelog entry to approved publication as one validated release.
Build and packaging model
The project uses three build layers that meet at packaging time. Python defines the distribution, its public packages, and its optional Matplotlib and Reflex integration surfaces. Rust supplies the native compute library. TypeScript supplies the browser client that is built into static assets. A Hatch build hook joins the generated assets and the native library with the Python packages, while allowing an intentional pure-Python build for environments without Rust.
| Build layer | Product role | Distribution result |
|---|---|---|
| Python | Public chart API, exports, widget host, framework integration, and optional pyplot compatibility | xy distribution with bundled reflex_xy package and optional integration dependencies |
| Rust | Native compute and raster work behind the Python API | One platform-specific library in a native wheel |
| JavaScript | Browser-side chart rendering for widgets and standalone HTML | ESM and IIFE bundles in the package static assets |
The normal user path is a prebuilt wheel. It includes the native library and both JavaScript bundles, so an end user does not need Rust or Node. A source install can build the native library when Rust is available. If Rust is missing, the package can still install as a pure wheel, but compute fails with a clear error because there is no silent Python fallback. The render client is different: it is required in normal distributions, so a missing bundle fails packaging unless a deliberate build override is used. (See home/…/pyproject.toml• L97-118, home/…/hatch_build.py• L1-26.)
The matplotlib extra enables the supported pyplot compatibility path without making Matplotlib a base runtime dependency. The reflex extra selects the supported Reflex version while the adapter source stays in the same xy distribution. This keeps the framework integration and render client on one release line without forcing either optional dependency on plain xy users. (See home/…/pyproject.toml• L17-28, home/…/pyproject.toml• L275-284.)
The version follows the Git release tag rather than a checked-in version field. The release process first selects a version from CHANGELOG.md, then creates the tag only after the upload succeeds. Untagged builds get a development version that is not suitable for upload. This keeps the Python package, the bundled framework integration, and the published artifact metadata on one version line. (See home/…/pyproject.toml• L72-95, home/…/publish.yml• L171-179, home/…/publish.yml• L419-465.)
Native core packaging
The native core exposes a stable C interface to the Python layer. The build system compiles one shared library for each target platform and places it inside the wheel with a platform tag. The C interface is independent of the CPython version, so the release matrix can use py3-none-<platform> wheels instead of one wheel for each Python version. See Rust acceleration engine for the compute role that this artifact carries. (See home/…/Cargo.toml• L1-24, home/…/hatch_build.py• L143-197.)
Release builds cover Linux glibc and musl targets, macOS Intel and Apple Silicon, and Windows Intel, x64, and arm64 targets. The release build workflow also produces a PyEmscripten wheel for browser Python and a source distribution. Cross builds pass the target and the matching wheel tag to the packaging hook. The hook then finds the target library and includes it without copying generated binaries into the source tree. (See home/…/build_release_artifacts.yml• L94-205, home/…/build_release_artifacts.yml• L207-275, home/…/pyproject.toml• L294-323.)
The native backend is a required runtime capability for compute. The Python kernel layer reports the active backend as native and raises an actionable import error when the library is absent or its ABI version does not match. This makes a coreless install visible instead of making performance or feature loss look like normal behavior. (See home/…/kernels.py• L1-27, home/…/_native.py• L1-11, home/…/_native.py• L72-83.)
References: home/…/pyproject.toml• L72-118 home/…/pyproject.toml• L275-323 home/…/Cargo.toml• L1-24 home/…/hatch_build.py• L143-197 home/…/build_release_artifacts.yml• L94-205 home/…/build_release_artifacts.yml• L207-275
JavaScript asset build
The JavaScript build produces the browser client that serves both live notebook widgets and standalone HTML. The source is TypeScript compiled as an ES2022 browser client. The development-only xy-dev-tools package supplies the Vite, TypeScript, and browser test toolchain through the build and typecheck commands. The build checks the source first, checks the renderer's shader conventions, and then creates two minified formats from the same public entry point. (See home/…/package.json• L1-18, home/…/tsconfig.json• L1-23, home/…/build.mjs• L1-13.)
The two outputs have distinct hosts but share the same client surface:
- index.js is the ESM bundle used by the widget host.
- standalone.js is the IIFE bundle exposed as
window.xyfor inline HTML.
The bundles are generated and ignored by version control. A source checkout builds them before use. A wheel or source distribution carries them already built, so installation from a published artifact does not need Node. The Hatch hook reuses existing bundles when present and otherwise runs the Node build during artifact creation. (See home/…/package.json• L5-8, home/…/build.mjs• L5-13, home/…/build.mjs• L81-127, home/…/hatch_build.py• L199-259.)
The asset contract reaches both browser entry points. The widget reads the ESM bundle from the package. HTML export reads the standalone bundle and embeds it in a self-contained document. The source distribution and wheel checks confirm that these assets exist and expose the required render surface. See browser rendering runtime for the client-side runtime that consumes these bundles. (See home/…/widget.py• L1-7, home/…/widget.py• L25-49, home/…/export.py• L105-116, home/…/60_entries.ts• L18-20, home/…/60_entries.ts• L65-99.)
References: home/…/package.json• L1-18 home/…/tsconfig.json• L1-23 home/…/build.mjs• L1-13 home/…/build.mjs• L81-127 home/…/hatch_build.py• L199-259 home/…/60_entries.ts• L18-20 home/…/60_entries.ts• L65-99 home/…/widget.py• L25-49 home/…/export.py• L105-116
Distribution checks
Distribution checks test the artifact rather than trusting a successful source-tree test run. The source distribution check confirms that a fresh source package contains the files needed to rebuild the client and native core, includes the prebuilt client, preserves package typing markers, and excludes caches, local native binaries, repository-only material, and the vendored gallery. (See home/…/verify_sdist.py• L1-9, home/…/verify_sdist.py• L29-121, home/…/verify_sdist.py• L255-305, home/…/pyproject.toml• L120-170.)
The wheel check confirms package shape, metadata, version consistency, archive records, JavaScript assets, and native-wheel tagging. It can require either a native wheel or an intentional pure wheel. In both cases it rejects accidental mixtures such as a native library in a pure wheel or a non-pure tag without a native library. (See home/…/verify_wheel.py• L1-7, home/…/verify_wheel.py• L292-415.)
After content checks, CI installs artifacts in clean environments. Native sdist and wheel checks load the Rust backend and compare the Python and framework integration versions with distribution metadata. Coreless checks confirm that the framework integration still imports and that compute fails with the expected guidance. These checks cover the two supported source-build outcomes without treating a missing Rust toolchain as a silent feature downgrade. (See home/…/ci.yml• L817-895, home/…/ci.yml• L897-1053.)
The main local commands map to the same artifact flow:
make check-sdistbuilds and verifies a source distribution.make check-wheelbuilds and verifies a wheel.make check-artifacts SDIST=... WHEEL=...verifies artifacts that already exist.make check-fulladds JavaScript, Rust, and ABI checks to the fast local gate.
(See /home/user/repo/Makefile#L10-L43, /home/user/repo/Makefile#L107-L130.)
The checks also protect the package surface that downstream Python users import. See Python chart API for that public API and its relationship to the packaged distribution.
References: home/…/verify_sdist.py• L1-9 home/…/verify_sdist.py• L255-305 home/…/verify_wheel.py• L292-415 home/…/ci.yml• L817-895 home/…/ci.yml• L897-1053 home/…/Makefile• L107-130
Repository automation
Repository automation separates fast code checks, browser checks, benchmark evidence, artifact checks, compatibility checks, changelog checks, and release work. Pull requests do not run every lane unconditionally: the changes job reads the complete pull-request diff and selects runtime, pyplot, packaging, benchmark, and browser-conformance groups. Workflow and CI-wiring changes select the correctness and packaging groups, while a build job is selected whenever any group is selected. (See home/…/ci.yml• L20-81, home/…/ci_scope.py• L9-59.)
CI uses full Git history because version derivation depends on tags. It also cancels an older run for the same ref when a newer commit arrives, so stale results do not consume the runner pool or obscure the newest commit. The final result job still evaluates every selected job and fails the workflow when a selected check fails or is cancelled. (See home/…/ci.yml• L9-18, home/…/ci.yml• L1340-1356.)
The shared Linux wheel job builds the native package and render client once. Downstream compatibility, browser, test, benchmark, and packaging jobs restore that build when they need it. This keeps the checks aligned to one artifact while allowing each job to validate a different product contract. (See home/…/ci.yml• L49-81, home/…/ci.yml• L96-116, home/…/ci.yml• L398-420.)
The local verification wrapper gives contributors the same checks with tool detection and useful setup messages. Its quick mode covers the Python floor, public API, workflow wiring, lint, type checks, and Python tests. Full mode adds the JavaScript bundle, Rust tests and lint, the release native build, and the C ABI smoke. Browser and packaging modes add the checks that need a browser or an artifact path. (See home/…/verify_local.py• L51-212, home/…/verify_local.py• L284-310, home/…/verify_local.py• L567-658.)
CI treats the Matplotlib compatibility surface as a release-relevant product contract. It checks both the pinned 3.11.0 reference and the newest declared 3.11 patch, then runs the pyplot modes, public protocols, gallery contract, and reference corpus checks. The gallery runs in eight standard shards and one strict extended environment, with a pull-request baseline ratchet and no-waiver completion for the extended set. (See home/…/ci.yml• L83-357.)
The main test and Python-floor jobs install the supported Matplotlib version and run the compatibility tests with the native and browser paths. This keeps compatibility failures visible even when the wider test suite would otherwise skip an optional dependency. (See home/…/ci.yml• L321-420, home/…/ci.yml• L690-751.) See Matplotlib pyplot compatibility for the supported behavior.
The CI workflow verifier protects required CI and CodSpeed jobs, their production-facing gates, full tag history, and the browser and artifact checks. The release workflow shape is checked by the pinned reflex-release tool instead. The changelog workflow runs that tool's heading, news-fragment, and generated-workflow checks so release configuration drift fails during review. (See home/…/verify_ci_workflow.py• L1-12, home/…/verify_ci_workflow.py• L723-1123, home/…/changelog.yml• L1-77.)
Performance automation complements correctness checks. The regular CI workflow records benchmark reports and runs regression checks. The CodSpeed workflow measures native kernel paths in simulation mode. Browser, install, and cross-library wall-clock work stays in the regular benchmark flows because it needs real browser or process timing. See performance benchmarks for the measurement model and report use. (See home/…/ci.yml• L569-1069, home/…/codspeed.yml• L39-76.)
References: home/…/ci.yml• L1-81 home/…/ci.yml• L83-357 home/…/ci.yml• L321-420 home/…/ci.yml• L1340-1356 home/…/ci_scope.py• L9-59 home/…/verify_local.py• L284-310 home/…/verify_local.py• L567-658 home/…/verify_ci_workflow.py• L723-1123 home/…/changelog.yml• L1-77 home/…/codspeed.yml• L39-76
Documentation image delivery
The documentation deployment path turns a selected XY source revision into a versioned frontend and backend image pair. It then proposes those image tags to the internal Helm chart, where the chart repository and its Flux consumers control deployment.
flowchart LR
S[XY source ref] --> B[Build and validate docs images]
B --> R[Push frontend and backend tags]
R --> H[Update environment values]
H --> P[Open Helm chart pull request]
P --> D[Flux deployment after merge]
Documentation image build
The reusable image workflow builds the browser frontend and the Python-backed service from one exact source ref. It installs the JavaScript, Python, and Rust toolchains so the backend image uses the native compute path, then exports the frontend and pushes both images for Linux AMD64 and ARM64 to Harbor and Azure Container Registry. (See home/…/_build-docs-images.yml• L57-107, home/…/_build-docs-images.yml• L124-160.)
The workflow resolves the XY version before the backend image build because the Docker build context does not include Git metadata. This keeps the package version inside the docs backend aligned with the checked-out source instead of allowing a fallback version. It validates image tags, source refs, and the Depot project before any image build starts. (See home/…/_build-docs-images.yml• L38-55, home/…/_build-docs-images.yml• L80-86.)
References: home/…/_build-docs-images.yml• L38-107 home/…/_build-docs-images.yml• L124-181
Helm chart promotion
The reusable Helm workflow converts an image build into an environment-specific change in reflex-dev/helm-charts. It maps dev to the live tenant-dev values file and maps stg and prod to their matching files. It updates both XY image tags and increments the chart patch version so Flux can reconcile the new chart. (See home/…/_helm-docs-pr.yml• L91-109, home/…/_helm-docs-pr.yml• L129-144.)
The workflow uses a stable branch name for each environment and image tag. An existing branch is not recreated, and an unchanged values file does not produce an empty pull request. A new change records the source commit and workflow run in the pull request, while optional auto-merge leaves deployment control with the chart repository. (See home/…/_helm-docs-pr.yml• L111-127, home/…/_helm-docs-pr.yml• L146-224.)
References: home/…/_helm-docs-pr.yml• L44-70 home/…/_helm-docs-pr.yml• L91-109 home/…/_helm-docs-pr.yml• L111-224
Release validation flow
The release system uses CHANGELOG.md as its source of truth. A version heading with no matching Git tag becomes release work. The system materializes news fragments into that changelog, builds the complete artifact set, verifies the files and version, waits for human approval, uploads to PyPI, and pushes the tag only after the upload succeeds. (See home/…/pyproject.toml• L252-323, home/…/release_from_changelog.yml• L6-15, home/…/publish.yml• L8-34.)
The release sequence is:
flowchart TD
N[News fragments] --> D[Dispatch release action]
D --> C[Materialize CHANGELOG.md or prerelease branch]
C --> H[Changelog push or prerelease result]
H --> X[Detect untagged changelog versions]
X --> P[Prepare version and branch checks]
P --> B[Build complete artifact set]
B --> V[Verify names, versions, contents, and checksums]
V --> A{Human approval in pypi environment}
A -->|Approved| U[Publish artifacts to PyPI]
A -->|Rejected or missing| F[Stop without publishing or tagging]
U --> T[Push tag and create GitHub release]
T --> R[Dispatch post-release workflow]
The Dispatch workflow has two release paths. Prerelease actions write versions to release branches and can publish them after approval. Final-release actions open a pull request that carries the changelog change. Merging that pull request puts the final version on main or a permitted hotfix branch, where the changelog workflow detects it for publication. The default action is continued prerelease to reduce accidental final releases. (See home/…/dispatch_release.yml• L6-38, home/…/dispatch_release.yml• L52-130.)
The changelog workflow protects the input to this process. It rejects hand-written new version headings unless an approved release branch or label provides the exception. It also requires a news fragment for changes under the Python, Rust, or JavaScript source roots. The release configuration and generated workflows must stay synchronized with the pinned reflex-release version. (See home/…/changelog.yml• L6-23, home/…/changelog.yml• L60-77, home/…/pyproject.toml• L262-284.)
The publish workflow validates the release before it builds. It checks the changelog, branch rules, existing tags, lockstep rules, and development dependency pins. For xy, it calls the repository-owned build workflow instead of using one local build runner. The custom workflow builds eleven platform wheels, a PyEmscripten wheel, and a source distribution. Every leg must succeed and upload a file that matches the expected artifact set. (See home/…/publish.yml• L89-132, home/…/publish.yml• L199-225, home/…/build_release_artifacts.yml• L1-21, home/…/pyproject.toml• L290-323.)
The custom build verifies native wheels on host-compatible runners and verifies cross-built wheels by their contents. It loads the PyEmscripten wheel in Pyodide and runs a native probe because a successful cross-build does not prove that browser Python can load it. It also builds the sdist with the client included, then checks both native and coreless install paths. (See home/…/build_release_artifacts.yml• L180-205, home/…/build_release_artifacts.yml• L243-275, home/…/build_release_artifacts.yml• L306-360.)
The collect stage turns build output into the approval payload. It gathers the artifacts from the normal or custom build path, verifies their names and versions, runs repository-specific post-build checks when present, extracts release notes, and writes checksums. The gated publish stage checks those checksums and uploads only the collected files. The tag and GitHub release are created only after PyPI accepts the upload, so a failed build or upload can be fixed by pushing a new commit without removing a misleading tag. (See home/…/publish.yml• L221-331, home/…/publish.yml• L333-417, home/…/publish.yml• L419-478.)
Release tags use the canonical vX.Y.Z form with optional aN, bN, rcN, or .postN suffixes. Development versions, local versions, and documentation CalVer tags stay outside the package release line. The release build validates the computed tag shape before starting the slow matrix. A manual custom-build run can exercise the matrix without publishing, while the actual publish path requires the pypi environment's human approval. (See home/…/check_release_version.py• L14-27, home/…/check_release_version.py• L47-69, home/…/build_release_artifacts.yml• L47-92, home/…/publish.yml• L333-417.)
The repository tests the part of the release contract it owns. They check that changelog headings can be read back, versions stay in order, news fragments use configured types, source roots require release notes, the tag prefix agrees with version derivation, and the artifact list agrees with the custom build matrix. They also check that the post-release workflow accepts the dispatch inputs used after a successful publication. (See home/…/test_release_process.py• L1-16, home/…/test_release_process.py• L49-228.)
References: home/…/pyproject.toml• L252-323 home/…/dispatch_release.yml• L6-38 home/…/dispatch_release.yml• L83-130 home/…/release_from_changelog.yml• L6-15 home/…/release_from_changelog.yml• L43-167 home/…/publish.yml• L89-132 home/…/publish.yml• L199-225 home/…/publish.yml• L221-478 home/…/build_release_artifacts.yml• L1-21 home/…/build_release_artifacts.yml• L94-365 home/…/check_release_version.py• L47-69 home/…/test_release_process.py• L149-228
Change checklist
When these files or sections are changed, remember to consider these:
- Change the JavaScript entry exports or development toolchain and update both bundle checks. The ESM and IIFE outputs must keep equivalent public render surfaces.
- Change pyproject.toml package, optional dependency, or sdist selection and update the required-file and forbidden-content rules in both artifact verifiers.
- Change the vendored Matplotlib gallery or its baseline and update the gallery contract, shard expectations, compatibility inventory, and monotonic baseline checks together.
- Change the version tag pattern or dynamic version settings and update the changelog parser, release configuration, generated workflows, and release tag gate together.
- Change native target names or wheel tags and update the cross-build matrix, Hatch target resolution, custom-build
expect-artifacts, and release-process agreement test together. - Change the Rust, Pyodide, or Emscripten toolchain set and update the runtime probe as one tested group.
- Change CI scope groups, path rules, required jobs, compatibility gates, or concurrency behavior and update scripts/ci_scope.py, scripts/verify_ci_workflow.py, and the final result gate together.
- Change generated release workflows through the pinned
reflex-release syncpath instead. - Change news-fragment source roots, types, or changelog heading format and update the changelog workflow, pyproject.toml, and tests/test_release_process.py contract.
- Change the meaning of a coreless install and update both the source-distribution and no-Rust wheel smoke contracts.
- Change the publish or post-release workflow inputs and update the caller, the approval-stage artifact contract, and the post-release dispatch checks.
- Change the docs image inputs, image names, build platforms, or XY version handoff and update both image tags, registry destinations, and the native-core validation together.
- Change the docs environment mapping or Helm value keys and update the live values-file rule, branch naming, chart-version bump, and pull-request summary together.
- Change the docs image tag reuse or auto-merge behavior and preserve the existing-branch and no-op safeguards so repeated deployments do not create conflicting chart changes.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Build runs from a shallow checkout | Version derivation can fall back to the wrong development or fallback version | Build and CI workflows require fetch-depth: 0; workflow validation checks CI checkouts. |
| A new changelog heading is malformed or is added outside the release path | Release detection can miss the version or publish work can enter the pipeline without the intended review | Changelog checks reject manual headings; tests/test_release_process.py checks the heading format and order. |
| Generated release workflows drift from pyproject.toml | Dispatch, detection, or publish jobs can use a stale package or artifact contract | changelog.yml runs reflex-release sync --check on pull requests. |
| A custom-build matrix leg or expected artifact pattern is missing | PyPI can receive an incomplete platform set, or collection can stop forever on an artifact that no build produces | The build fails on lost legs; expect-artifacts and test_release_process.py compare the matrix with the required set. |
| A cross-built wheel has the host tag or the wrong native contents | Install tools can select an unusable wheel for a target machine | The build passes explicit target and platform values; wheel verification checks tags and native contents. |
| A PyEmscripten wheel builds but does not load in browser Python | A broken browser-Python backend can reach the release batch | The release workflow loads the exact wheel in pinned Pyodide and runs the native probe. |
The pypi environment has no required reviewers | An upload could run without human approval | The publish job checks the environment and fails closed before uv publish. |
| Build or upload fails before tagging | The changelog version remains detectable and can be retried without removing a tag | Tag creation runs only after successful publication. |
| JavaScript source changes without a successful client build | Widgets or standalone HTML lack a usable render client | The JavaScript build runs before packaging; artifact checks require both bundles. |
| Matplotlib compatibility changes without a gallery or patch-range check | Supported pyplot behavior can regress while the basic package tests pass | CI runs the pinned reference, declared-range patch smoke, standard gallery ratchet, and strict extended gallery gate. |
| A path change is not covered by the CI scope map | A needed lane can be skipped, or an unrelated expensive lane can run | ci_scope.py maps path classes to explicit groups, and the workflow verifier checks the required CI wiring. |
| A newer run supersedes an older run for the same ref | The older run is cancelled and its partial status cannot validate the newest commit | CI groups runs by ref and the final result job rejects cancelled selected checks. |
| The docs image workflow receives an unsafe tag or source ref | The build could address an unintended source or registry reference | Input validation allows only bounded tag and ref characters before checkout or push. |
| The docs backend build cannot resolve the XY version | The deployed docs service can report a fallback package version | The image workflow resolves the version while full Git tags are available and passes it into the backend build. |
| The Helm workflow uses the retired dev values path | The image update can target a missing or wrong environment configuration | The environment resolver maps dev to values-tenant-dev.yaml and checks that the file exists. |
| A chart version does not change with a new image tag | Flux can fail to repackage the chart, so the new images do not deploy | The promotion workflow bumps the chart patch version with each values update. |
Key files
| File | Why to read it |
|---|---|
| home/…/pyproject.toml | Defines distribution metadata, optional compatibility dependencies, version derivation, package selection, source contents, and changelog-driven release configuration. |
| home/…/hatch_build.py | Shows how generated JavaScript and platform native libraries enter artifacts. |
| home/…/package.json | Defines the private JavaScript build and browser test toolchain with its build and type-check commands. |
| home/…/build.mjs | Defines the browser asset build and its two output formats. |
| home/…/verify_sdist.py | Defines the source distribution content and installability contract. |
| home/…/verify_wheel.py | Defines wheel metadata, asset, purity, and native-library checks. |
| home/…/ci_scope.py | Maps changed paths to the CI groups that must run. |
| home/…/verify_local.py | Maps contributor commands to local correctness, build, browser, and packaging checks. |
| home/…/verify_ci_workflow.py | Protects the structure and release-critical checks in CI and CodSpeed automation. |
| home/…/check_release_version.py | Defines the allowed package release tag shapes. |
| home/…/test_release_process.py | Checks the repository-owned changelog, source-root, version, artifact, and post-release contracts. |
| home/…/ci.yml | Selects required checks, builds the shared Linux artifact, and runs the normal multi-language, browser, Matplotlib compatibility, gallery, benchmark, and artifact gates. |
| home/…/build_release_artifacts.yml | Builds and verifies the complete xy artifact set for normal releases and dry runs. |
| home/…/changelog.yml | Checks news fragments, changelog headings, and generated release workflow sync. |
| home/…/dispatch_release.yml | Starts prerelease or final-release preparation from a manual release action. |
| home/…/release_from_changelog.yml | Detects untagged changelog versions and starts the package publish flow. |
| home/…/publish.yml | Coordinates preparation, artifact collection, human approval, PyPI upload, tagging, and post-release dispatch. |
| home/…/_build-docs-images.yml | Builds, validates, and pushes the multi-architecture documentation frontend and backend images. |
| home/…/_helm-docs-pr.yml | Maps documentation image tags to environment values and opens the internal Helm chart pull request. |