-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add a stub Rust crate #12595
Add a stub Rust crate #12595
Changes from all commits
178d866
09bc570
b4f8dcd
e9a887e
6f7d07c
9e50d78
7c6c3fc
fb841d4
7ae6651
d1216ff
d29b599
0ce8a1d
bc119dd
1036994
0c21782
7f3924b
6bf07a5
18f9052
4f868cf
792da37
d268681
88bd752
77088ab
176a3c9
fcf4b4e
a7721b5
2fe560a
bbb13b6
8befab2
73c9af9
58cc839
d84eade
fce0ea8
70d860c
3e72a1c
6564423
d632a40
017176a
2177d3f
1ebd913
1df9d07
fa0c98d
fc02d33
9df5d41
edbc9ea
2f4e01b
c8b9209
7073bee
66e0568
e78aeba
ef1b7e2
fa36b74
6f28d8e
bf3e845
ae3ef4c
171d0b0
5b21216
24deebc
5e44342
1e5056c
673d14d
025953e
fc899fc
334ab75
4aa84fe
bb753a1
571470c
a0673ac
d5af3e5
72ab0c4
717b8b4
3573887
d2796b2
19d0a2a
b39669b
1e04a3c
0577408
03c6fa2
2c17042
60461d4
5da41e6
85e85c2
1ed7322
6a06805
871caa4
11b0ded
68d63b5
93fd366
6283b47
830b061
4785cfe
b8a291e
2b81696
519cc2c
08c464b
f2a8668
48186b3
aa5bb1c
bfeab18
349bb96
bdfec46
54894b5
680681d
40c8f9c
1a275b4
00fcc83
6ff918b
3c19a48
2126cf7
479a595
60bbd62
eddf98e
ac7269d
1b504aa
96c7cdb
c74a7af
20f90b1
d5234f7
3953ab0
19279b4
bff7fb4
22ea18b
70f3ffd
4604d51
646e4b0
ca584b4
86248cf
0359401
1c25715
1818f14
7c5d4ad
f62405a
24360df
e11f2ba
6225fd5
362ab60
74b015e
eae0143
dbdb3b0
435342d
77eada8
702818a
f5b21f3
96b8bb0
54d4a10
bb2a6df
c9acee4
9353e82
e829e94
25cf13f
7f47134
4fe4bc4
5205d05
fb1364d
737a827
f4b582d
4756c35
12378a3
e407242
b401fe1
de3af72
38c1019
d9f3ff5
d39dba2
aa216fc
45864b8
0687d7f
53bbe54
f6f3d4f
c32cc41
0eb1aa7
2a8e23d
88edb96
0b833c2
1c7929d
5eab0cd
62847c5
2cad84d
a4574b7
4925f6f
5a5fb3d
641ed32
1a601fa
fa8f079
bbd3d09
43e38a9
fa57b03
bc8f80a
19c6a5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ on: | |
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: write | ||
|
||
|
@@ -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" | ||
|
||
steps: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should whatever changed here be folded back into the backend-meta repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yup, probably. The change is using |
||
- 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/') }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work? Do you need to setup-python or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sigh, good point. Lets test that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Erm, I think you're missing an There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After toolchain installation, I recommend adding There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | | ||
|
@@ -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() }} | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,10 @@ book/ | |
# complement | ||
/complement-* | ||
/master.tar.gz | ||
|
||
# rust | ||
/target/ | ||
/synapse/*.so | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we care about ... dylibs? dlls? Whatever those other OS people do :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, probably I guess? Though do we support other OSes? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, pretty much There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On macOS this did seem to only generate a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# Poetry will create a setup.py, which we don't want to include. | ||
/setup.py |
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` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No corresponding There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a stub Rust crate. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
------- | ||
|
||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
@@ -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. | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.