-
-
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 22 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 | ||
|
||
|
@@ -91,7 +91,34 @@ jobs: | |
|
||
build-sdist: | ||
name: "Build pypi distribution files" | ||
uses: "matrix-org/backend-meta/.github/workflows/packaging.yml@v1" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
|
||
- name: Install tools | ||
run: python -m pip install build twine | ||
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 don't think you need No objections to using 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. For whatever reason |
||
|
||
- name: Build wheel and sdist | ||
run: poetry build | ||
|
||
# This checks that the "long description" fields renders correctly on PyPI. | ||
# We don't upload to PyPI, but the two steps below only upload artifacts to GitHub. | ||
- name: Run twine check | ||
run: python -m twine check dist/* | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Wheel | ||
path: dist/*.whl | ||
|
||
- 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: | ||
|
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,16 @@ | ||
# A build script for poetry that adds the rust extension. | ||
|
||
import os | ||
|
||
from setuptools_rust import Binding, RustExtension | ||
|
||
|
||
def build(setup_kwargs): | ||
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. Is mypy going to check this file? Type hints would be nice, but I won't block this on having them. 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. Alternatively stick it in 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 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 | ||
) | ||
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 |
---|---|---|
|
@@ -46,17 +46,8 @@ RUN \ | |
|
||
# We install poetry in its own build stage to avoid its dependencies conflicting with | ||
# synapse's dependencies. | ||
# We use a specific commit from poetry's master branch instead of our usual 1.1.14, | ||
# to incorporate fixes to some bugs in `poetry export`. This commit corresponds to | ||
# https://github.com/python-poetry/poetry/pull/5156 and | ||
# https://github.com/python-poetry/poetry/issues/5141 ; | ||
# without it, we generate a requirements.txt with incorrect environment markers, | ||
# which causes necessary packages to be omitted when we `pip install`. | ||
# | ||
# NB: In poetry 1.2 `poetry export` will be moved into a plugin; we'll need to also | ||
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. Did this end up happening in poetry 1.2? 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, except 1.2 pulls it in automatically (there is a fun circular dependency between poetry and poetry export plugin...) |
||
# pip install poetry-plugin-export (https://github.com/python-poetry/poetry-plugin-export). | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
pip install --user "poetry-core==1.1.0a7" "git+https://github.com/python-poetry/poetry.git@fb13b3a676f476177f7937ffa480ee5cff9a90a5" | ||
pip install --user "poetry==1.2.0rc1" | ||
|
||
WORKDIR /synapse | ||
|
||
|
@@ -101,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 | ||
|
@@ -117,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 | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 thanpip build