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

Build Rust redwood wheel during packaging process #6884

Merged
merged 4 commits into from
Aug 8, 2023
Merged

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Jun 27, 2023

Status

Ready for review

Description of Changes

  • Properly exclude custom_logo.png from package and fix test (mostly unrelated, but discovered while working on this so I'm throwing it in...)
  • Drop dh-virtualenv from packaging process
  • Build redwood wheel without maturin
  • Build Rust redwood wheel during packaging process

Fixes #6538.
Fixes #6817.

Testing

How should the reviewer test this PR?

Largely focusing on the dh-virtualenv change.

  • cp securedrop/static/i/logo.png securedrop/static/i/custom_logo.png (this should still be excluded from the build)
  • Check out this PR and run make build-debs
  • Download https://apt.freedom.press/pool/main/s/securedrop/securedrop-app-code_2.6.0%2Bfocal_amd64.deb, then run debdiff between the two files, you should see https://gist.github.com/legoktm/170f170e01437ba49671306df4425912
    • One intentional change is that /opt/venvs/securedrop-app-code/lib/python3.8/site-packages/securedrop_app_code-2.6.0-py3.8.egg-info/ is gone, we're no longer installing an empty securedrop-app-code Python package because dh_virtualenv mandates it.

For the Rust stuff:

  • deb-tests CI passes, which means the redwood.so is included in the package
  • staging CI passes, which means the redwood wheel is installed and usable for generating a key pair
  • review the make build-debs log from earlier, verify there's no garbage output (escape codes or progress bars) caused by Rust/cargo stuff

Verify Rust reproducibility:

  • Copy the securedrop-app-code.deb from your first make build-debs to something like first.deb
  • Re-run make build-debs, save the securedrop-app-code deb as something like second.deb
  • For each deb, extract the files. ar x first.deb, then tar xvf data.tar.xz
  • For each extracted deb, run sha256sum opt/venvs/securedrop-app-code/lib/python3.8/site-packages/redwood/redwood.cpython-38-x86_64-linux-gnu.so - the checksum should be 152d90961bf1cf44fcbc5c0275e31c68ca6a16f1b0c42895fe9272a53e2f1685 for both.

Deployment

Any special considerations for deployment? Just the packaging changes.

Checklist

  • Linting (make lint) and tests (make test) pass in the development container
  • Configuration tests pass
  • I have written a test plan and validated it for this PR

@legoktm
Copy link
Member Author

legoktm commented Jun 27, 2023

Leaving as WIP because we need to figure out whether we want to re-use upstream maturin wheels, build it from source, or what. And whether we need to audit dependencies of that too.

@legoktm legoktm force-pushed the stg-rust-packaging branch 2 times, most recently from a68c6a7 to 39424d3 Compare June 29, 2023 21:21
@legoktm legoktm marked this pull request as ready for review June 29, 2023 21:24
@legoktm legoktm requested a review from a team as a code owner June 29, 2023 21:24
@legoktm legoktm force-pushed the stg-rust-packaging branch from 39424d3 to 91a7289 Compare June 30, 2023 23:41
@legoktm
Copy link
Member Author

legoktm commented Jun 30, 2023

I realized the build wasn't reproducible because we weren't building with the lockfile and using --locked. That's now part of the test plan.

legoktm added 2 commits August 2, 2023 15:59
The test to verify custom_logo.png was not included in the package was
using the wrong path and missed that if a custom_logo.png existed in the
local source tree, it would be included in the package (not an issue for
releases since we always use a clean source tree).

Fix the inclusion by deleting any custom logo if it exists.
dh-virtualenv is responsible for creating the virtualenv, installing
dependencies from requirements.txt, and then munging the virtualenv to
use the path that it will be installed to.

There are a number of issues with it however:
* largely unmaintained in Debian (missed focal)
* incompatible with debhelper compat 12
* cannot use --require-hashes
* hides deprecation warnings and error messages

It is now getting in the way of Rust packaging since we want to install
a wheel into the virtualenv, however it needs to happen before the
munging step, which dh-virtualenv doesn't really support.

Since we already want to get rid of it, let's just do it now.

Fixes #6538.
@legoktm legoktm force-pushed the stg-rust-packaging branch 2 times, most recently from c47f0fe to 00c0b6e Compare August 2, 2023 20:10
@cfm cfm self-assigned this Aug 8, 2023
Copy link
Member

@cfm cfm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, Kunal. In addition to the test plan, I've left one request inline, plus:

  • make dev succeeds, including building libredwood via your scripting rather than maturin.
  • This branch isn't fully signed.
  • Noting for the record: 8f884ea removes build-requirements.{in,txt}, because they were added in Add "redwood" Sequoia Rust/Python bridge  #6828 exclusively to pull in maturin.

Comment on lines 53 to 56
# Yes the name is wrong, but it doesn't matter, this is only an intermediate step anyways
whl = Path("redwood-0.1.0-py3-none-any.whl")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify this comment? I can guess which name you're referring to, how it's wrong, and why it doesn't matter; but I can't actually tell for sure from the comment. :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

legoktm added 2 commits August 8, 2023 18:44
maturin is really great, but has a significant dependency tree that
doesn't really make sense for us to review and figure out how to install
into the builder environment right now.

It is relatively straightforward to build the wheel ourselves using only
setuptools, we just need to copy the Rust-built libredwood.so into the
right place in the Python package (see
<https://pyo3.rs/v0.19.0/building_and_distribution.html#manual-builds>).
The new build-wheel.py script does that and produces a functionally
equivalent wheel to what maturin would have generated.

Probably we should switch back to maturin once it's packaged in Debian
(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=999850).
Use our script to build the redwood wheel and then install it into the
virtualenv shipped in the Debian package.

A testinfra check is added that verifies the redwood wheel is importable
and is able to generate a key pair.

Fixes #6817.
@legoktm legoktm force-pushed the stg-rust-packaging branch from 00c0b6e to 42ff407 Compare August 8, 2023 22:45
Copy link
Member

@cfm cfm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @legoktm!

@cfm cfm merged commit 1e16d38 into develop Aug 8, 2023
@legoktm legoktm deleted the stg-rust-packaging branch January 9, 2025 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Packaging process builds Rust code Drop dh-virtualenv
2 participants