Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribute buildstream Wheel packages that contain BuildBox #1712

Closed
ssssam opened this issue Aug 3, 2022 · 3 comments · Fixed by #1723
Closed

Distribute buildstream Wheel packages that contain BuildBox #1712

ssssam opened this issue Aug 3, 2022 · 3 comments · Fixed by #1723

Comments

@ssssam
Copy link
Contributor

ssssam commented Aug 3, 2022

Intro

Bst2 is available in PyPI, but only as a source distribution. Many packages on PyPI can be installed simply with pip3 install $package. Installing BuildStream is not so simple:

  • A working cc or gcc must be available, along with CPython headers and libraries, so Cython modules can be compiled to binaries
  • BuildBox must be installed, this currently implies building from source (see: buildbox issue about releasing binaries)

The Python Wheel format can be used to bundle and distribute binaries for our target platforms. When you run pip3 install buildstream and a suitable buildstream-*.whl is available on PyPI, the install should work even in a 'stock' container image:

  • Cython modules are prebuilt so GCC isn't needed
  • BuildBox binaries can be bundled in the wheel and installed in '$prefix/bin/' by Pip

Goals

The goal is a way to install BuildStream 2 in a single command on a wide range of machines, assuming:

  • the OS doesn't provide its own BuildStream package (we prefer distro packages where available)
  • the user trusts PyPI and the BuildStream release team

Non goals:

  • replace distro builds. Anyone redistributing BuildStream should use the sdist or Git repo and build from source.

What about Docker?

The Bst 1.6 install instructions recommend running in Docker via bst-here. The Bst 1.9.95 install instructions also link to the buildstream-docker-images instructions. (At time of writing the buildstream.build website doesn't mention Docker directly).

Provisioning Bst via a container image is sensible for many situations and we will always ensure it is possible. Recommending it as the best way to use BuildStream is more nuanced.

Advantages of recommending users obtain Bst via Docker:

Disadvantages of recommending users obtain Bst via Docker:

  • Dependency on a container host (we use hub.docker.io at the moment, but could use Github container hosting)
  • Requirement that user can start a container - not easy if they're already in a container, or don't have the necessary privileges
  • Builds have different requirements for host tools depending on what plugins are used, so there's no 'one size fits all' container
  • Most build tools don't require a separate container to run, so this makes bst look like a 'heavyweight' tool
  • Docker images are larger than wheels
ssssam added a commit to ssssam/buildstream that referenced this issue Aug 3, 2022
This allows using [cibuildwheel](https://cibuildwheel.readthedocs.io)
locally to produce various Wheel packages of BuildStream.

These Wheel packages contain prebuilt binaries of Cython modules, so
`pip3 install buildstream` on compatible systems does not require a
C compiler and Python headers on the target machine.

apache#1712
@ssssam
Copy link
Contributor Author

ssssam commented Aug 3, 2022

Steps for "first cut"

Additional tasks

  • Investigate if we can and should strip debug info
    • See: Strip debug symbols of wheels pypa/cibuildwheel#331
    • Difference seems to be: 2.5MB (-g) vs. 1MB (-g0)
    • With the addition of BuildBox binaries the wheel is up to about 20MB (example), the buildbox binaries are already stripped. So the Cython debug info is a small % of the total and not worth the worry.
  • Investigate if we can build wheels for aarch64, riscv
  • Auto updates of cibuildwheel version
  • Revisit musl support
    • If buildbox binaries don't support musl, then don't ship wheels for musllinux platform either.
    • buildbox-integration is building binaries that dynamically link to glibc 2.28. there are no plans to build separate musl binaries right now.

Verification

  • buildstream-2.0.0-....whl can be installed and used in a venv, with bst 1.x installed on the host
  • buildstream-2.0.0.....whl can be installed on the host, with bst 1.x in a venv
  • Wheel can be installed and used on a stock container image of Ubuntu, Fedora, Debian without needing extra packages
  • Test each wheel that we release on the platform it expects to run (e.g. the python3.7 wheel on an OS with python3.7)

ssssam added a commit to ssssam/buildstream that referenced this issue Aug 3, 2022
This updates the CI config to:

  * build wheel packages on each update of 'master', which can be
    downloaded as Action artifacts
  * build sdist and wheel packages on each release tag, and upload
    them to Test PyPI at https://test.pypi.org/project/BuildStream/

The new workflows are based on examples at
https://cibuildwheel.readthedocs.io/en/stable/setup/ and use some
GitHub Actions to call the relevant commandline toling.

apache#1712
@ssssam
Copy link
Contributor Author

ssssam commented Aug 4, 2022

Some progress on this in https://github.com/ssssam/buildstream/tree/sam/fat-wheels:

  • using bundled BuildBox binaries works in my limited testing
  • bundling the binaries into .whl packages works when calling setup.py directly, but not when using pip or build to produce a wheel. More investigation needed into why these tools all behave differently.

ssssam added a commit to ssssam/buildstream that referenced this issue Aug 10, 2022
This allows using [cibuildwheel](https://cibuildwheel.readthedocs.io)
locally to produce various Wheel packages of BuildStream.

These Wheel packages contain prebuilt binaries of Cython modules, so
`pip3 install buildstream` on compatible systems does not require a
C compiler and Python headers on the target machine.

apache#1712
ssssam added a commit to ssssam/buildstream that referenced this issue Aug 12, 2022
This allows using [cibuildwheel](https://cibuildwheel.readthedocs.io)
locally to produce various Wheel packages of BuildStream.

These Wheel packages contain prebuilt binaries of Cython modules, so
`pip3 install buildstream` on compatible systems does not require a
C compiler and Python headers on the target machine.

apache#1712
@gtristan
Copy link
Contributor

Note that this appears to be related to long standing epic #332

gtristan pushed a commit that referenced this issue Aug 17, 2022
BuildBox is not widely distributed in binary form yet. For convience,
add a mechanism to bundle prebuilt binaries in the Python wheel
packages.

Setting BST_BUNDLE_BUILDBOX=1 when setup.py runs, causes the bundled
binaries to be included in the binary package. Its up to the packager
to make appropriate binaries available in
`src/buildstream/subprojects/buildbox/`.

BuildStream will search the package subprojects/ dir when looking for
BuildBox binaries on the host in all cases, prioritizing any bundled
binaries above other ones on the host.

Related to #1712
gtristan pushed a commit that referenced this issue Aug 17, 2022
BuildBox is not widely distributed in binary form yet. For convience,
add a mechanism to bundle prebuilt binaries in the Python wheel
packages.

Setting BST_BUNDLE_BUILDBOX=1 when setup.py runs, causes the bundled
binaries to be included in the binary package. Its up to the packager
to make appropriate binaries available in
`src/buildstream/subprojects/buildbox/`.

BuildStream will search the package subprojects/ dir when looking for
BuildBox binaries on the host in all cases, prioritizing any bundled
binaries above other ones on the host.

Related to #1712
gtristan pushed a commit that referenced this issue Aug 23, 2022
BuildBox is not widely distributed in binary form yet. For convience,
add a mechanism to bundle prebuilt binaries in the Python wheel
packages.

Setting BST_BUNDLE_BUILDBOX=1 when setup.py runs, causes the bundled
binaries to be included in the binary package. Its up to the packager
to make appropriate binaries available in
`src/buildstream/subprojects/buildbox/`.

BuildStream will search the package subprojects/ dir when looking for
BuildBox binaries on the host in all cases, prioritizing any bundled
binaries above other ones on the host.

Related to #1712
gtristan pushed a commit that referenced this issue Aug 23, 2022
BuildBox is not widely distributed in binary form yet. For convience,
add a mechanism to bundle prebuilt binaries in the Python wheel
packages.

Setting BST_BUNDLE_BUILDBOX=1 when setup.py runs, causes the bundled
binaries to be included in the binary package. Its up to the packager
to make appropriate binaries available in
`src/buildstream/subprojects/buildbox/`.

BuildStream will search the package subprojects/ dir when looking for
BuildBox binaries on the host in all cases, prioritizing any bundled
binaries above other ones on the host.

Related to #1712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants