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

Commit b88cfe6

Browse files
David Robertsonsquahtx
andauthored
Require poetry>=1.3.2 (#14860)
* Upgrade to new lockfile format Now requires poetry >= 1.2.2 to read and poetry >= 1.3.0 to write. Cheat sheet: ``` poetry --version poetry show > scratch/before pipx upgrade poetry poetry --version poetry show > scratch/after diff scratch{before,after} && echo "no change!" ``` * Use Poetry 1.3.2 when reading or writing lockfile * Remove unneeded(?) poetry dep for cibuildwheel * Update docs * Remove redundant call to setup-python * Remove outdated comments related to Poetry 1.x * Remove outdated docs line was fixed in #13082 * Minor improvements to poetry cheat sheet * Invoke setup-python-poetry with explicit version Not sure about this. It's hardcoding versions everywhere. * Changelog * Check the lockfile is version 2.0 Might one day incorporate other checks like #14742 * Typo fixes, thanks Sean Co-authored-by: Sean Quah <[email protected]> Co-authored-by: Sean Quah <[email protected]>
1 parent f820740 commit b88cfe6

File tree

14 files changed

+1548
-1493
lines changed

14 files changed

+1548
-1493
lines changed

.ci/scripts/check_lockfile.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#! /usr/bin/env python
2+
import sys
3+
4+
if sys.version_info < (3, 11):
5+
raise RuntimeError("Requires at least Python 3.11, to import tomllib")
6+
7+
import tomllib
8+
9+
with open("poetry.lock", "rb") as f:
10+
lockfile = tomllib.load(f)
11+
12+
try:
13+
lock_version = lockfile["metadata"]["lock-version"]
14+
assert lock_version == "2.0"
15+
except Exception:
16+
print(
17+
"""\
18+
Lockfile is not version 2.0. You probably need to upgrade poetry on your local box
19+
and re-run `poetry lock --no-update`. See the Poetry cheat sheet at
20+
https://matrix-org.github.io/synapse/develop/development/dependencies.html
21+
"""
22+
)
23+
raise

.ci/scripts/prepare_old_deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ with open('pyproject.toml', 'w') as f:
5353
"
5454
python3 -c "$REMOVE_DEV_DEPENDENCIES"
5555

56-
pip install poetry==1.2.0
56+
pip install poetry==1.3.2
5757
poetry lock
5858

5959
echo "::group::Patched pyproject.toml"

.github/workflows/latest_deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- uses: matrix-org/setup-python-poetry@v1
3838
with:
3939
python-version: "3.x"
40-
poetry-version: "1.2.0"
40+
poetry-version: "1.3.2"
4141
extras: "all"
4242
# Dump installed versions for debugging.
4343
- run: poetry run pip list > before.txt

.github/workflows/release-artifacts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
python-version: "3.x"
128128

129129
- name: Install cibuildwheel
130-
run: python -m pip install cibuildwheel==2.9.0 poetry==1.2.0
130+
run: python -m pip install cibuildwheel==2.9.0
131131

132132
- name: Set up QEMU to emulate aarch64
133133
if: matrix.arch == 'aarch64'

.github/workflows/tests.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- uses: actions/checkout@v3
36-
- uses: actions/setup-python@v4
37-
with:
38-
python-version: "3.x"
3936
- uses: matrix-org/setup-python-poetry@v1
4037
with:
38+
python-version: "3.x"
39+
poetry-version: "1.3.2"
4140
extras: "all"
4241
- run: poetry run scripts-dev/generate_sample_config.sh --check
4342
- run: poetry run scripts-dev/config-lint.sh
@@ -52,6 +51,15 @@ jobs:
5251
- run: "pip install 'click==8.1.1' 'GitPython>=3.1.20'"
5352
- run: scripts-dev/check_schema_delta.py --force-colors
5453

54+
check-lockfile:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v3
58+
- uses: actions/setup-python@v4
59+
with:
60+
python-version: "3.x"
61+
- run: .ci/scripts/check_lockfile.py
62+
5563
lint:
5664
uses: "matrix-org/backend-meta/.github/workflows/python-poetry-ci.yml@v2"
5765
with:
@@ -88,6 +96,7 @@ jobs:
8896
ref: ${{ github.event.pull_request.head.sha }}
8997
- uses: matrix-org/setup-python-poetry@v1
9098
with:
99+
poetry-version: "1.3.2"
91100
extras: "all"
92101
- run: poetry run scripts-dev/check_pydantic_models.py
93102

@@ -163,6 +172,7 @@ jobs:
163172
- lint-pydantic
164173
- check-sampleconfig
165174
- check-schema-delta
175+
- check-lockfile
166176
- lint-clippy
167177
- lint-rustfmt
168178
runs-on: ubuntu-latest
@@ -219,6 +229,7 @@ jobs:
219229
- uses: matrix-org/setup-python-poetry@v1
220230
with:
221231
python-version: ${{ matrix.job.python-version }}
232+
poetry-version: "1.3.2"
222233
extras: ${{ matrix.job.extras }}
223234
- name: Await PostgreSQL
224235
if: ${{ matrix.job.postgres-version }}
@@ -294,6 +305,7 @@ jobs:
294305
- uses: matrix-org/setup-python-poetry@v1
295306
with:
296307
python-version: '3.7'
308+
poetry-version: "1.3.2"
297309
extras: "all test"
298310

299311
- run: poetry run trial -j6 tests
@@ -328,6 +340,7 @@ jobs:
328340
- uses: matrix-org/setup-python-poetry@v1
329341
with:
330342
python-version: ${{ matrix.python-version }}
343+
poetry-version: "1.3.2"
331344
extras: ${{ matrix.extras }}
332345
- run: poetry run trial --jobs=2 tests
333346
- name: Dump logs
@@ -419,6 +432,7 @@ jobs:
419432
- run: sudo apt-get -qq install xmlsec1 postgresql-client
420433
- uses: matrix-org/setup-python-poetry@v1
421434
with:
435+
poetry-version: "1.3.2"
422436
extras: "postgres"
423437
- run: .ci/scripts/test_export_data_command.sh
424438
env:
@@ -470,6 +484,7 @@ jobs:
470484
- uses: matrix-org/setup-python-poetry@v1
471485
with:
472486
python-version: ${{ matrix.python-version }}
487+
poetry-version: "1.3.2"
473488
extras: "postgres"
474489
- run: .ci/scripts/test_synapse_port_db.sh
475490
id: run_tester_script

.github/workflows/twisted_trunk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
run: |
149149
set -x
150150
DEBIAN_FRONTEND=noninteractive sudo apt-get install -yqq python3 pipx
151-
pipx install poetry==1.2.0
151+
pipx install poetry==1.3.2
152152
153153
poetry remove -n twisted
154154
poetry add -n --extras tls git+https://github.com/twisted/twisted.git#trunk

changelog.d/14860.removal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Poetry 1.3.2 or higher is now required when `poetry install`ing from source.

debian/build_virtualenv

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ case $(dpkg-architecture -q DEB_HOST_ARCH) in
3131
esac
3232

3333
# Manually install Poetry and export a pip-compatible `requirements.txt`
34-
# We need a Poetry pre-release as the export command is buggy in < 1.2
3534
TEMP_VENV="$(mktemp -d)"
3635
python3 -m venv "$TEMP_VENV"
3736
source "$TEMP_VENV/bin/activate"
3837
pip install -U pip
39-
pip install poetry==1.2.0
38+
pip install poetry==1.3.2
4039
poetry export \
4140
--extras all \
4241
--extras test \

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
matrix-synapse-py3 (1.75.1) UNRELEASED; urgency=medium
2+
3+
* Use Poetry 1.3.2 to manage the bundled virtualenv included with this package.
4+
5+
-- Synapse Packaging team <[email protected]> Tue, 17 Jan 2023 15:08:00 +0000
6+
17
matrix-synapse-py3 (1.75.0) stable; urgency=medium
28

39
* New Synapse release 1.75.0.

docker/Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,8 @@
1717

1818
# Irritatingly, there is no blessed guide on how to distribute an application with its
1919
# poetry-managed environment in a docker image. We have opted for
20-
# `poetry export | pip install -r /dev/stdin`, but there are known bugs in
21-
# in `poetry export` whose fixes (scheduled for poetry 1.2) have yet to be released.
22-
# In case we get bitten by those bugs in the future, the recommendations here might
23-
# be useful:
24-
# https://github.com/python-poetry/poetry/discussions/1879#discussioncomment-216865
25-
# https://stackoverflow.com/questions/53835198/integrating-python-poetry-with-docker?answertab=scoredesc
26-
27-
20+
# `poetry export | pip install -r /dev/stdin`, but beware: we have experienced bugs in
21+
# in `poetry export` in the past.
2822

2923
ARG PYTHON_VERSION=3.9
3024

@@ -49,7 +43,7 @@ RUN \
4943
# We install poetry in its own build stage to avoid its dependencies conflicting with
5044
# synapse's dependencies.
5145
RUN --mount=type=cache,target=/root/.cache/pip \
52-
pip install --user "poetry==1.2.0"
46+
pip install --user "poetry==1.3.2"
5347

5448
WORKDIR /synapse
5549

0 commit comments

Comments
 (0)