Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add a stub Rust crate #12595

Merged
merged 189 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
178d866
Add a stub Rust crate
erikjohnston Apr 29, 2022
09bc570
Ignore the .so lib
erikjohnston Apr 29, 2022
b4f8dcd
Add explicit setuptools_rust dep
erikjohnston Aug 18, 2022
e9a887e
Merge remote-tracking branch 'origin/develop' into erikj/rust_app
erikjohnston Aug 18, 2022
6f7d07c
Fix lock file
erikjohnston Aug 18, 2022
9e50d78
Use poetry build
erikjohnston Aug 18, 2022
7c6c3fc
Fix type hints
erikjohnston Aug 18, 2022
fb841d4
Fix debian packaging
erikjohnston Aug 18, 2022
7ae6651
Newsfile
erikjohnston Aug 18, 2022
d1216ff
Make a workspace
erikjohnston Aug 18, 2022
d29b599
Add rust to docker build deps
erikjohnston Aug 18, 2022
0ce8a1d
Use recent poetry
erikjohnston Aug 23, 2022
bc119dd
Install rust toolchains
erikjohnston Aug 24, 2022
1036994
Set toolchain
erikjohnston Aug 24, 2022
0c21782
Move setuptools_rust to main dep
erikjohnston Aug 24, 2022
7f3924b
Fix complement
erikjohnston Aug 25, 2022
6bf07a5
Fix up Dockerfile-dhvirtualenv
erikjohnston Aug 25, 2022
18f9052
Lock file
erikjohnston Aug 25, 2022
4f868cf
Fix trial-olddeps
erikjohnston Aug 25, 2022
792da37
Use poetry 1.2.0rc1 in docker
erikjohnston Aug 25, 2022
d268681
Drop explicit setuptools dep
erikjohnston Aug 25, 2022
88bd752
Reinstate setuptools explicit dependency
erikjohnston Aug 25, 2022
77088ab
Update deprecation policy
erikjohnston Aug 30, 2022
176a3c9
Bump poetry version in trial-olddeps
erikjohnston Aug 30, 2022
fcf4b4e
Merge remote-tracking branch 'origin/develop' into erikj/rust_app
erikjohnston Aug 30, 2022
a7721b5
Bump poetry to 1.2.0rc2
erikjohnston Aug 30, 2022
2fe560a
Bump bcrypt to 3.2.0 to make it work with new poetry
erikjohnston Aug 30, 2022
bbb13b6
Define a minimum version of Rust
erikjohnston Aug 30, 2022
8befab2
Bump lock file
erikjohnston Aug 30, 2022
73c9af9
Fix lockfile
erikjohnston Aug 30, 2022
58cc839
fix lockfile take2
erikjohnston Aug 30, 2022
d84eade
Bump setuptools
erikjohnston Aug 30, 2022
fce0ea8
Restore deps
erikjohnston Aug 30, 2022
70d860c
Lock??
erikjohnston Aug 30, 2022
3e72a1c
Lock???
erikjohnston Aug 30, 2022
6564423
Revert changes to lock file?
erikjohnston Aug 30, 2022
d632a40
Remove spurious setting of python-version
erikjohnston Aug 30, 2022
017176a
Upgrade setuptools
erikjohnston Aug 30, 2022
2177d3f
Fix updating setuptools
erikjohnston Aug 30, 2022
1ebd913
Fix complement docker
erikjohnston Aug 30, 2022
1df9d07
Merge remote-tracking branch 'origin/develop' into erikj/rust_app
erikjohnston Aug 30, 2022
fa0c98d
Try reverting back to using python -m build
erikjohnston Aug 31, 2022
fc02d33
Remove explicit dep on setuptools
erikjohnston Aug 31, 2022
9df5d41
More wheels
erikjohnston Aug 31, 2022
edbc9ea
Fix release gha
erikjohnston Aug 31, 2022
2f4e01b
Fix release gha
erikjohnston Aug 31, 2022
c8b9209
Fix release gha
erikjohnston Aug 31, 2022
7073bee
Fix release gha
erikjohnston Aug 31, 2022
66e0568
Fix release gha
erikjohnston Aug 31, 2022
e78aeba
Fix release gha
erikjohnston Aug 31, 2022
ef1b7e2
Fix release gha
erikjohnston Aug 31, 2022
fa36b74
Fix release gha
erikjohnston Aug 31, 2022
6f28d8e
Fix release gha
erikjohnston Aug 31, 2022
bf3e845
Fix release gha
erikjohnston Aug 31, 2022
ae3ef4c
Fix release gha
erikjohnston Aug 31, 2022
171d0b0
Fix release gha
erikjohnston Aug 31, 2022
5b21216
Fix rust-version
erikjohnston Aug 31, 2022
24deebc
Fix release gha
erikjohnston Aug 31, 2022
5e44342
Fix release gha
erikjohnston Aug 31, 2022
1e5056c
Fix release gha
erikjohnston Aug 31, 2022
673d14d
Try using cibuildwheel
erikjohnston Aug 31, 2022
025953e
Fix release gha
erikjohnston Aug 31, 2022
fc899fc
Fix release gha
erikjohnston Aug 31, 2022
334ab75
Fix release gha
erikjohnston Aug 31, 2022
4aa84fe
Fix release gha
erikjohnston Aug 31, 2022
bb753a1
Fix release gha
erikjohnston Aug 31, 2022
571470c
Fix release gha
erikjohnston Aug 31, 2022
a0673ac
Fix release gha
erikjohnston Aug 31, 2022
d5af3e5
Fix release gha
erikjohnston Aug 31, 2022
72ab0c4
Fix release gha
erikjohnston Aug 31, 2022
717b8b4
Fix release gha
erikjohnston Aug 31, 2022
3573887
Fix release gha
erikjohnston Aug 31, 2022
d2796b2
Fix release gha
erikjohnston Aug 31, 2022
19d0a2a
Add back in setuptools to lock file
erikjohnston Aug 31, 2022
b39669b
Revert "Add back in setuptools to lock file"
erikjohnston Aug 31, 2022
1e04a3c
Try building more wheels
erikjohnston Aug 31, 2022
0577408
Fix debian package
erikjohnston Aug 31, 2022
03c6fa2
Add verbose flag
erikjohnston Aug 31, 2022
2c17042
Fix release gha
erikjohnston Aug 31, 2022
60461d4
Fix release gha
erikjohnston Aug 31, 2022
5da41e6
Fix release gha
erikjohnston Aug 31, 2022
85e85c2
Fix release gha
erikjohnston Aug 31, 2022
1ed7322
Fix release gha
erikjohnston Aug 31, 2022
6a06805
Debian newsfile
erikjohnston Aug 31, 2022
871caa4
Fix release gha
erikjohnston Aug 31, 2022
11b0ded
Fix release gha
erikjohnston Aug 31, 2022
68d63b5
Fix release gha
erikjohnston Aug 31, 2022
93fd366
Fix release gha
erikjohnston Aug 31, 2022
6283b47
Fix debian?
erikjohnston Aug 31, 2022
830b061
Fix debian?
erikjohnston Aug 31, 2022
4785cfe
Fix releases
erikjohnston Aug 31, 2022
b8a291e
Fix releases
erikjohnston Aug 31, 2022
2b81696
Fix releases
erikjohnston Aug 31, 2022
519cc2c
Release
erikjohnston Aug 31, 2022
08c464b
Try fully updating lockfile
erikjohnston Sep 1, 2022
f2a8668
Add notes about needing a rust compiler
erikjohnston Sep 1, 2022
48186b3
Use stable poetry
erikjohnston Sep 1, 2022
aa5bb1c
Update pyproject
erikjohnston Sep 1, 2022
bfeab18
Remove unused build wheels scripts
erikjohnston Sep 1, 2022
349bb96
Use latest poetry in sytest?
erikjohnston Sep 1, 2022
bdfec46
Don't overwrite poetry
erikjohnston Sep 1, 2022
54894b5
Update lock file for Poetry v1.2.0
erikjohnston Sep 1, 2022
680681d
Newsfile
erikjohnston Sep 1, 2022
40c8f9c
Merge branch 'develop' into erikj/update_poetry_lock
erikjohnston Sep 1, 2022
1a275b4
Doc that min version of poetry is 1.2
erikjohnston Sep 1, 2022
00fcc83
Merge remote-tracking branch 'origin/develop' into erikj/update_poetr…
erikjohnston Sep 1, 2022
6ff918b
Forgot to save this file...
erikjohnston Sep 1, 2022
3c19a48
Merge remote-tracking branch 'origin/develop' into erikj/update_poetr…
erikjohnston Sep 1, 2022
2126cf7
Merge branch 'erikj/update_poetry_lock' into erikj/rust_app
erikjohnston Sep 1, 2022
479a595
Fix lock file
erikjohnston Sep 2, 2022
60bbd62
Update trial old deps CI to use poetry 1.2.0
erikjohnston Sep 2, 2022
eddf98e
Newsfile
erikjohnston Sep 2, 2022
ac7269d
Also build source package
erikjohnston Sep 2, 2022
1b504aa
Move cbuildwheel configuration to pyproject.toml
erikjohnston Sep 2, 2022
96c7cdb
Merge branch 'develop' into erikj/old_deps
erikjohnston Sep 2, 2022
c74a7af
Fix?
erikjohnston Sep 2, 2022
20f90b1
Try rejigging old-deps
erikjohnston Sep 2, 2022
d5234f7
Fix?
erikjohnston Sep 2, 2022
3953ab0
fix
erikjohnston Sep 2, 2022
19279b4
Fix??
erikjohnston Sep 2, 2022
bff7fb4
FIX ONESEFLF!!!
erikjohnston Sep 2, 2022
22ea18b
JUST RUN
erikjohnston Sep 2, 2022
70f3ffd
:(
erikjohnston Sep 2, 2022
4604d51
Make it work with maturin
erikjohnston Sep 5, 2022
646e4b0
Limit to ABI3
erikjohnston Sep 5, 2022
ca584b4
Merge branch 'develop' into erikj/old_deps
erikjohnston Sep 5, 2022
86248cf
Add some debugging
erikjohnston Sep 5, 2022
0359401
More debugging details
erikjohnston Sep 5, 2022
1c25715
Try py3.8
erikjohnston Sep 5, 2022
1818f14
Try shelling out
erikjohnston Sep 5, 2022
7c5d4ad
Activate virtual env
erikjohnston Sep 5, 2022
f62405a
Fix?
erikjohnston Sep 5, 2022
24360df
Try the shell again
erikjohnston Sep 5, 2022
e11f2ba
Try just activating the virtualenv
erikjohnston Sep 5, 2022
6225fd5
try uninstall tests
erikjohnston Sep 5, 2022
362ab60
More debugging
erikjohnston Sep 5, 2022
74b015e
Add some caching
erikjohnston Sep 5, 2022
eae0143
Add current directory to path
erikjohnston Sep 5, 2022
dbdb3b0
Try single job
erikjohnston Sep 5, 2022
435342d
Try
erikjohnston Sep 5, 2022
77eada8
Try a different tack
erikjohnston Sep 5, 2022
702818a
Add and populate cache
erikjohnston Sep 5, 2022
f5b21f3
Re-enable tests
erikjohnston Sep 5, 2022
96b8bb0
Update cache
erikjohnston Sep 5, 2022
54d4a10
Fix
erikjohnston Sep 5, 2022
bb2a6df
Run tests
erikjohnston Sep 5, 2022
c9acee4
Install build deps
erikjohnston Sep 5, 2022
9353e82
Update deps
erikjohnston Sep 5, 2022
e829e94
list bcrypt files
erikjohnston Sep 5, 2022
25cf13f
Try manually installing bcrypt
erikjohnston Sep 5, 2022
7f47134
Reinstall bcrypt
erikjohnston Sep 5, 2022
4fe4bc4
fix
erikjohnston Sep 5, 2022
5205d05
Install all deps
erikjohnston Sep 5, 2022
fb1364d
Install all deps
erikjohnston Sep 5, 2022
737a827
Install test deps too
erikjohnston Sep 5, 2022
f4b582d
Try not reinstalling bcrypt
erikjohnston Sep 5, 2022
4756c35
Make it ready for review
erikjohnston Sep 5, 2022
12378a3
Merge remote-tracking branch 'origin/erikj/old_deps' into erikj/rust_app
erikjohnston Sep 5, 2022
e407242
install rust
erikjohnston Sep 5, 2022
b401fe1
Mention maturin
erikjohnston Sep 5, 2022
de3af72
Set minimum rust version to 1.61
erikjohnston Sep 6, 2022
38c1019
Revert bcrypt change
erikjohnston Sep 6, 2022
d9f3ff5
Docstrings
erikjohnston Sep 6, 2022
d39dba2
Remove python-source directive
erikjohnston Sep 6, 2022
aa216fc
Rename build_wheels
erikjohnston Sep 6, 2022
45864b8
Fix contributing guide?
erikjohnston Sep 6, 2022
0687d7f
Remove unneeded setuptools upgrade
erikjohnston Sep 6, 2022
53bbe54
Don't build all the wheels on PR CI
erikjohnston Sep 6, 2022
f6f3d4f
Apply suggestions from code review
erikjohnston Sep 6, 2022
c32cc41
Merge remote-tracking branch 'origin/develop' into erikj/rust_app
erikjohnston Sep 6, 2022
0eb1aa7
Fix release-artifacts?
erikjohnston Sep 6, 2022
2a8e23d
Fix poetry.lock
erikjohnston Sep 6, 2022
88edb96
Temporarily reduce jobs from trial-olddeps for debugging
erikjohnston Sep 6, 2022
0b833c2
Bump minimum bcrypt to see if that compiles
erikjohnston Sep 6, 2022
1c7929d
Update wording
erikjohnston Sep 6, 2022
5eab0cd
Merge remote-tracking branch 'origin/develop' into erikj/rust_app
erikjohnston Sep 6, 2022
62847c5
Apply suggestions from code review
erikjohnston Sep 6, 2022
2cad84d
Fix up line wrapping
erikjohnston Sep 6, 2022
a4574b7
Fix release-artifact.yml
erikjohnston Sep 6, 2022
4925f6f
Move sdist to separate step
erikjohnston Sep 6, 2022
5a5fb3d
Fix release-artifact.yml
erikjohnston Sep 6, 2022
641ed32
Code review
erikjohnston Sep 6, 2022
1a601fa
Use a specific rustc version in tests
erikjohnston Sep 6, 2022
fa8f079
Add typing
erikjohnston Sep 6, 2022
bbd3d09
Temporarily always build sdist
erikjohnston Sep 6, 2022
43e38a9
Fix sdist
erikjohnston Sep 6, 2022
fa57b03
Fix sdist
erikjohnston Sep 6, 2022
bc8f80a
Fix sdist warning
erikjohnston Sep 6, 2022
19c6a5f
Only build sdist on non-PRs CI
erikjohnston Sep 6, 2022
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
# things to include
!docker
!synapse
!rust
!README.rst
!pyproject.toml
!poetry.lock
!build_rust.py

rust/target

**/__pycache__
65 changes: 62 additions & 3 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write

Expand Down Expand Up @@ -89,16 +89,75 @@ jobs:
name: debs
path: debs/*

build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-10.15]
is_pr:
- ${{ startsWith(github.ref, 'refs/pull/') }}

exclude:
# Don't build macos wheels on PR CI.
- is_pr: true
os: "macos-10.15"
babolivier marked this conversation as resolved.
Show resolved Hide resolved

steps:
Copy link
Contributor

Choose a reason for hiding this comment

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

should whatever changed here be folded back into the backend-meta repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yup, probably. The change is using poetry build rather than pip build

- uses: actions/checkout@v3

- uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.9.0 poetry==1.2.0

# Only build a single wheel in CI.
- name: Set env vars.
run: |
echo "CIBW_BUILD="cp37-manylinux_x86_64"" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/pull/')

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
# Skip testing for platforms which various libraries don't have wheels
# for, and so need extra build deps.
CIBW_TEST_SKIP: pp39-* *i686* *musl* pp37-macosx*
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

- uses: actions/upload-artifact@v3
with:
name: Wheel
path: ./wheelhouse/*.whl

build-sdist:
name: "Build pypi distribution files"
uses: "matrix-org/backend-meta/.github/workflows/packaging.yml@v1"
name: Build sdist
runs-on: ubuntu-latest
if: ${{ !startsWith(github.ref, 'refs/pull/') }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. Should we be building the sdist on PRs? (I'm not sure it picks anything hugely important up?)


steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- run: pip install build

- name: Build sdist
run: python -m build --sdist
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work? Do you need to setup-python or pip install build?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sigh, good point. Lets test that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Erm, I think you're missing an actions/checkout too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, fixed now!


- uses: actions/upload-artifact@v2
with:
name: Sdist
path: dist/*.tar.gz


# if it's a tag, create a release and attach the artifacts to it
attach-assets:
name: "Attach assets to release"
if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }}
needs:
- build-debs
- build-wheels
- build-sdist
runs-on: ubuntu-latest
steps:
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.61.0
override: true
Comment on lines +142 to +146
Copy link
Contributor

Choose a reason for hiding this comment

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

After toolchain installation, I recommend adding - uses: Swatinem/rust-cache@v2 as a step, which will take care of caching dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

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

ooooooooooooooooooooooooooooo


# There aren't wheels for some of the older deps, so we need to install
# their build dependencies
- run: |
Expand Down Expand Up @@ -175,7 +181,7 @@ jobs:
python-version: '3.7'
extras: "all test"

- run: poetry run trial -j 2 tests
- run: poetry run trial -j2 tests
- name: Dump logs
# Logs are most useful when the command fails, always include them.
if: ${{ always() }}
Expand Down Expand Up @@ -247,6 +253,11 @@ jobs:
- uses: actions/checkout@v2
- name: Prepare test blacklist
run: cat sytest-blacklist .ci/worker-blacklist > synapse-blacklist-with-workers
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.61.0
override: true
- name: Run SyTest
run: /bootstrap.sh synapse
working-directory: /src
Expand Down Expand Up @@ -353,6 +364,12 @@ jobs:
with:
path: synapse

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.61.0
override: true

- name: Prepare Complement's Prerequisites
run: synapse/.ci/scripts/setup_complement_prerequisites.sh

Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,10 @@ book/
# complement
/complement-*
/master.tar.gz

# rust
/target/
/synapse/*.so
Copy link
Contributor

Choose a reason for hiding this comment

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

do we care about ... dylibs? dlls? Whatever those other OS people do :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, probably I guess? Though do we support other OSes?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @clokep is on Mac at least. Perhaps he can comment about what that looks like over there

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I'm on macOS (and others who occasionally contribute to Synapse use macOS too) -- are you mostly just hoping I run this and make sure it doesn't break / what other files we might need to ignore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, pretty much

Copy link
Member

Choose a reason for hiding this comment

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

On macOS this did seem to only generate a .so file, but it was under the build/ directory. This was when installing an editable install via pip, so might be OK if you use poetry?

Copy link
Member Author

Choose a reason for hiding this comment

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

/build/ is ignored separately fwiw, so thats fine.


# Poetry will create a setup.py, which we don't want to include.
/setup.py
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# We make the whole Synapse folder a workspace so that we can run `cargo`
Copy link
Contributor

Choose a reason for hiding this comment

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

No corresponding Cargo.lock?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good point!

# commands from the root (rather than having to cd into rust/).

[workspace]
members = ["rust"]
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions build_rust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# A build script for poetry that adds the rust extension.

import os
from typing import Any, Dict

from setuptools_rust import Binding, RustExtension


def build(setup_kwargs: Dict[str, Any]) -> None:
original_project_dir = os.path.dirname(os.path.realpath(__file__))
cargo_toml_path = os.path.join(original_project_dir, "rust", "Cargo.toml")

extension = RustExtension(
target="synapse.synapse_rust",
path=cargo_toml_path,
binding=Binding.PyO3,
py_limited_api=True,
)
setup_kwargs.setdefault("rust_extensions", []).append(extension)
setup_kwargs["zip_safe"] = False
1 change: 1 addition & 0 deletions changelog.d/12595.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a stub Rust crate.
7 changes: 6 additions & 1 deletion debian/build_virtualenv
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dh_virtualenv \
--extras="all,systemd,test" \
--requirements="exported_requirements.txt"

PACKAGE_BUILD_DIR="debian/matrix-synapse-py3"
PACKAGE_BUILD_DIR="$(pwd)/debian/matrix-synapse-py3"
VIRTUALENV_DIR="${PACKAGE_BUILD_DIR}${DH_VIRTUALENV_INSTALL_ROOT}/matrix-synapse"
TARGET_PYTHON="${VIRTUALENV_DIR}/bin/python"

Expand All @@ -78,9 +78,14 @@ case "$DEB_BUILD_OPTIONS" in

cp -r tests "$tmpdir"

# To avoid pulling in the unbuilt Synapse in the local directory
pushd /

PYTHONPATH="$tmpdir" \
"${TARGET_PYTHON}" -m twisted.trial --reporter=text -j2 tests

popd

;;
esac

Expand Down
4 changes: 4 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ matrix-synapse-py3 (1.66.0) stable; urgency=medium

matrix-synapse-py3 (1.66.0~rc2+nmu1) UNRELEASED; urgency=medium

[ Jörg Behrmann ]
* Update debhelper to compatibility level 12.
* Drop the preinst script stopping synapse.
* Allocate a group for the system user.
* Change dpkg-statoverride to --force-statoverride-add.

[ Erik Johnston ]
* Disable `dh_auto_configure` as it broke during Rust build.

-- Jörg Behrmann <behrmann@physik.fu-berlin.de> Tue, 23 Aug 2022 17:17:00 +0100

matrix-synapse-py3 (1.66.0~rc2) stable; urgency=medium
Expand Down
2 changes: 2 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ override_dh_installsystemd:
# we don't really want to strip the symbols from our object files.
override_dh_strip:

override_dh_auto_configure:

# many libraries pulled from PyPI have allocatable sections after
# non-allocatable ones on which dwz errors out. For those without the issue the
# gains are only marginal
Expand Down
14 changes: 12 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,20 @@ RUN \
libxml++2.6-dev \
libxslt1-dev \
openssl \
rustc \
zlib1g-dev \
git \
curl \
&& rm -rf /var/lib/apt/lists/*


# Install rust and ensure its in the PATH
ENV RUSTUP_HOME=/rust
ENV CARGO_HOME=/cargo
ENV PATH=/cargo/bin:/rust/bin:$PATH
RUN mkdir /rust /cargo

RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable

# To speed up rebuilds, install all of the dependencies before we copy over
# the whole synapse project, so that this layer in the Docker cache can be
# used while you develop on the source
Expand All @@ -108,8 +117,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \

# Copy over the rest of the synapse source code.
COPY synapse /synapse/synapse/
COPY rust /synapse/rust/
# ... and what we need to `pip install`.
COPY pyproject.toml README.rst /synapse/
COPY pyproject.toml README.rst build_rust.py /synapse/

# Repeat of earlier build argument declaration, as this is a new build stage.
ARG TEST_ONLY_IGNORE_POETRY_LOCKFILE
Expand Down
10 changes: 10 additions & 0 deletions docker/Dockerfile-dhvirtualenv
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ RUN apt-get update -qq -o Acquire::Languages=none \
&& env DEBIAN_FRONTEND=noninteractive apt-get install \
-yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \
build-essential \
curl \
debhelper \
devscripts \
libsystemd-dev \
Expand All @@ -85,6 +86,15 @@ RUN apt-get update -qq -o Acquire::Languages=none \
libpq-dev \
xmlsec1

# Install rust and ensure it's in the PATH
ENV RUSTUP_HOME=/rust
ENV CARGO_HOME=/cargo
ENV PATH=/cargo/bin:/rust/bin:$PATH
RUN mkdir /rust /cargo

RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable


COPY --from=builder /dh-virtualenv_1.2.2-1_all.deb /

# install dhvirtualenv. Update the apt cache again first, in case we got a
Expand Down
13 changes: 13 additions & 0 deletions docs/deprecation_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ documented at [https://endoflife.date/python](https://endoflife.date/python) and
[https://endoflife.date/postgresql](https://endoflife.date/postgresql).


A Rust compiler is required to build Synapse from source. For any given release
the minimum required version may be bumped up to a recent Rust version, and so
people building from source should ensure they can fetch recent versions of Rust
(e.g. by using [rustup](https://rustup.rs/)).


Context
-------

Expand All @@ -31,3 +37,10 @@ long process.
By following the upstream support life cycles Synapse can ensure that its
dependencies continue to get security patches, while not requiring system admins
to constantly update their platform dependencies to the latest versions.

For Rust, the situation is a bit different given that a) the Rust foundation
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be "the Rust project", the foundation only does trademark, financing and PR stuff, it's not involved with maintenance / suppport or such.

does not generally support older Rust versions, and b) the library ecosystem
generally bump their minimum support Rust versions frequently. In general, the
Synapse team will try to avoid updating the dependency on Rust to the absolute
latest version, but introducing a formal policy is hard given the constraints of
the ecosystem.
10 changes: 9 additions & 1 deletion docs/development/contributing_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ The source code of Synapse is hosted on GitHub. You will also need [a recent ver

For some tests, you will need [a recent version of Docker](https://docs.docker.com/get-docker/).

A recent version of the Rust compiler is needed to build the native modules. The
easiest way of installing the latest version is to use [rustup](https://rustup.rs/).


# 3. Get the source.

Expand Down Expand Up @@ -114,6 +117,11 @@ Some documentation also exists in [Synapse's GitHub
Wiki](https://github.com/matrix-org/synapse/wiki), although this is primarily
contributed to by community authors.

When changes are made to any Rust code then you must call either `poetry install`
or `maturin develop` (if installed) to rebuild the Rust code. Using [`maturin`](https://github.com/PyO3/maturin)
is quicker than `poetry install`, so is recommended when making frequent
changes to the Rust code.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe worth thinking down the line: is there a way that someone who only wants to touch the Python code can short-cut this setup step / requirement of a rust compiler, e.g. by first installing a wheel?
Certainly not a blocker, just a though

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no good support for doing that TBH. I think we'd have to have the rust as a separate python package to make that work.



# 8. Test, test, test!
<a name="test-test-test"></a>
Expand Down Expand Up @@ -195,7 +203,7 @@ The database file can then be inspected with:
sqlite3 _trial_temp/test.db
```

Note that the database file is cleared at the beginning of each test run. Thus it
Note that the database file is cleared at the beginning of each test run. Thus it
will always only contain the data generated by the *last run test*. Though generally
when debugging, one is only running a single test anyway.

Expand Down
4 changes: 4 additions & 0 deletions docs/setup/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ System requirements:
- Python 3.7 or later, up to Python 3.10.
- At least 1GB of free RAM if you want to join large public rooms like #matrix:matrix.org

If building on an uncommon architecture for which pre-built wheels are
unavailable, you will need to have a recent Rust compiler installed. The easiest
way of installing the latest version is to use [rustup](https://rustup.rs/).

To install the Synapse homeserver run:

```sh
Expand Down
6 changes: 5 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ files =
docker/,
scripts-dev/,
synapse/,
tests/
tests/,
build_rust.py

# Note: Better exclusion syntax coming in mypy > 0.910
# https://github.com/python/mypy/pull/11329
Expand Down Expand Up @@ -181,3 +182,6 @@ ignore_missing_imports = True

[mypy-incremental.*]
ignore_missing_imports = True

[mypy-setuptools_rust.*]
ignore_missing_imports = True
Loading