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 160 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
19 changes: 3 additions & 16 deletions .ci/scripts/test_old_deps.sh → .ci/scripts/prepare_old_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,8 @@
# - creates a venv with these old versions using poetry; and finally
# - invokes `trial` to run the tests with old deps.

# Prevent tzdata from asking for user input
export DEBIAN_FRONTEND=noninteractive

set -ex

apt-get update
apt-get install -y \
python3 python3-dev python3-pip python3-venv pipx \
libxml2-dev libxslt-dev xmlsec1 zlib1g-dev libjpeg-dev libwebp-dev

export LANG="C.UTF-8"

# Prevent virtualenv from auto-updating pip to an incompatible version
export VIRTUALENV_NO_DOWNLOAD=1

Expand Down Expand Up @@ -55,7 +45,7 @@ sed -i \
# toml file. This means we don't have to ensure compatibility between old deps and
# dev tools.

pip install --user toml
pip install toml wheel

REMOVE_DEV_DEPENDENCIES="
import toml
Expand All @@ -69,15 +59,12 @@ with open('pyproject.toml', 'w') as f:
"
python3 -c "$REMOVE_DEV_DEPENDENCIES"

pipx install poetry==1.1.14
~/.local/bin/poetry lock
pip install poetry==1.2.0
poetry lock

echo "::group::Patched pyproject.toml"
cat pyproject.toml
echo "::endgroup::"
echo "::group::Lockfile after patch"
cat poetry.lock
echo "::endgroup::"

~/.local/bin/poetry install -E "all test"
~/.local/bin/poetry run trial --jobs=2 tests
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__
43 changes: 38 additions & 5 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,17 +89,50 @@ jobs:
name: debs
path: debs/*

build-sdist:
name: "Build pypi distribution files"
uses: "matrix-org/backend-meta/.github/workflows/packaging.yml@v1"
build_wheels:
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-10.15]

steps:
- 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

- 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

- name: Build sdist
if: matrix.os == 'ubuntu' && matrix.python-version == 'cp310'
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
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved


# 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-sdist
- build_wheels
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
Expand Down
56 changes: 49 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,47 @@ jobs:
# Note: sqlite only; no postgres
if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
needs: linting-done
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Test with old deps
uses: docker://ubuntu:focal # For old python and sqlite
# Note: focal seems to be using 3.8, but the oldest is 3.7?
# See https:/matrix-org/synapse/issues/12343
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

# There aren't wheels for some of the older deps, so we need to install
# their build dependencies
- run: |
sudo apt-get -qq install build-essential libffi-dev python-dev \
libxml2-dev libxslt-dev xmlsec1 zlib1g-dev libjpeg-dev libwebp-dev

- uses: actions/setup-python@v4
with:
python-version: '3.7'

# Calculating the old-deps actually takes a bunch of time, so we cache the
# pyproject.toml / poetry.lock.
- uses: actions/cache@v3
id: cache-poetry-old-deps
name: Cache poetry.lock
with:
workdir: /github/workspace
entrypoint: .ci/scripts/test_old_deps.sh
path: |
poetry.lock
pyproject.toml
key: poetry-old-deps2-${{ hashFiles('pyproject.toml') }}
- name: Prepare old deps
if: steps.cache-poetry-old-deps.outputs.cache-hit != 'true'
run: .ci/scripts/prepare_old_deps.sh

# We only now install poetry so that `setup-python-poetry` caches the
# right poetry.lock's dependencies.
- uses: matrix-org/setup-python-poetry@v1
with:
python-version: '3.7'
extras: "all test"

- run: poetry run trial -j 2 tests
- name: Dump logs
# Logs are most useful when the command fails, always include them.
if: ${{ always() }}
Expand Down Expand Up @@ -252,6 +283,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: stable
override: true
- name: Run SyTest
run: /bootstrap.sh synapse
working-directory: /src
Expand Down Expand Up @@ -358,6 +394,12 @@ jobs:
with:
path: synapse

- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

- 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
19 changes: 19 additions & 0 deletions build_rust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# A build script for poetry that adds the rust extension.

import os

from setuptools_rust import Binding, RustExtension


def build(setup_kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is mypy going to check this file? Type hints would be nice, but I won't block this on having them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively stick it in scripts-dev and it'll be covered with everything else 👼

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it can go in scripts-dev as it needs to be in the source to build the package?

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.
1 change: 1 addition & 0 deletions changelog.d/13707.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update trial old deps CI to use poetry 1.2.0.
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 <[email protected]> Tue, 23 Aug 2022 17:17:00 +0100

matrix-synapse-py3 (1.66.0~rc2) stable; urgency=medium
Expand Down
3 changes: 3 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 Expand Up @@ -49,6 +51,7 @@ override_dh_shlibdeps:
-X site-packages/PIL/.libs \
-X site-packages/Pillow.libs \
-X site-packages/psycopg2
# TODO: Do we need to add our rust package here?
babolivier marked this conversation as resolved.
Show resolved Hide resolved

override_dh_virtualenv:
./debian/build_virtualenv
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 its in the PATH
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
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
2 changes: 2 additions & 0 deletions docker/complement/conf/start_for_complement.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ openssl x509 -in /conf/server.tls.crt -noout -text | grep DNS:
export SYNAPSE_TLS_CERT=/conf/server.tls.crt
export SYNAPSE_TLS_KEY=/conf/server.tls.key

pip install -U setuptools
babolivier marked this conversation as resolved.
Show resolved Hide resolved

# Run the script that writes the necessary config files and starts supervisord, which in turn
# starts everything else
exec /configure_workers_and_start.py
12 changes: 12 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 the latest released Rust
version, and so people building from source must be able to fetch the latest
version of Rust (e.g. by using [rustup](https://rustup.rs/)).


Context
-------

Expand All @@ -31,3 +37,9 @@ 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,
Synapse will unlikely ever require the absolute latest Rust version, but
babolivier marked this conversation as resolved.
Show resolved Hide resolved
introducing a formal policy is hard given the constraints of the ecosystem.
Loading