Skip to content

Commit cadb867

Browse files
committed
chore: replace poetry by uv
Updates dependencies and use uv as dependency manager. Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>
1 parent 522d803 commit cadb867

18 files changed

Lines changed: 4565 additions & 7963 deletions

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ docker-compose-dev.yml
1515
Procfile*
1616

1717
celerybeat-schedule
18+
19+
.venv/

.github/workflows/continuous-integration-test.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: CI
22
on: [push, pull_request, workflow_dispatch]
33

44
env:
@@ -28,34 +28,30 @@ jobs:
2828
- name: Docker compose up
2929
run: docker compose up -d
3030

31-
- name: Setup Python 3.9
32-
uses: actions/setup-python@v5
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v5
3333
with:
34-
python-version: 3.9
34+
enable-cache: true
35+
cache-dependency-glob: uv.lock
3536

36-
- name: Install Poetry
37-
uses: snok/install-poetry@v1
38-
39-
- name: Run Bootstrap
40-
run: |
41-
poetry run ./scripts/bootstrap
42-
pip install --upgrade coveralls
37+
- name: Set up Python
38+
run: uv python install 3.9
4339

4440
- name: Bootstrap
4541
if: ${{ matrix.dependencies == 'dev' }}
4642
run: |
47-
poetry run ./scripts/bootstrap --ci
48-
pip install --upgrade coveralls
43+
uv run ./scripts/bootstrap --ci
4944
5045
- name: Bootstrap deploy
5146
if: ${{ matrix.dependencies == 'deploy' }}
5247
run: |
53-
poetry run ./scripts/bootstrap --ci --deploy E2E=yes
48+
uv run ./scripts/bootstrap --ci --deploy
5449
5550
- name: Run Test
56-
run: poetry run ./scripts/test
51+
run: uv run poe run_tests
5752

5853
- name: Code Coverage
54+
if: ${{ matrix.dependencies == 'development' }}
5955
env:
6056
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6157
COVERALLS_SERVICE_NAME: github

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
*.so
1010

1111
# Distribution / packaging
12+
.venv/
1213
.Python
1314
env/
1415
build/

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Ready to contribute? Here's how to set up `sonar` for local development.
9292

9393
.. code-block:: console
9494
95-
$ poetry run ./scripts/test
95+
$ uv run ./scripts/test
9696
9797
The tests will provide you with test coverage and also check PEP8
9898
(code style), PEP257 (documentation), flake8 as well as build the Sphinx

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ ENV TERM=xterm-256color
4545
ENV UWSGI_PROFILE_OVERRIDE="xml=no"
4646
ARG UI_TGZ=""
4747
ENV INVENIO_COLLECT_STORAGE='flask_collect.storage.file'
48-
RUN poetry run ./scripts/bootstrap --deploy --ui ${UI_TGZ}
48+
RUN uv run --no-sync ./scripts/bootstrap --deploy --ui ${UI_TGZ}
4949

5050
ENTRYPOINT [ "bash", "-c"]

Dockerfile.base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ FROM python:3.9-slim-bookworm
2828
RUN apt-get upgrade -y && apt-get update -y
2929
RUN apt-get install --no-install-recommends -y git vim-tiny curl gcc g++ pkg-config gnupg libc6-dev libxml2-dev libxmlsec1-dev libxmlsec1-openssl xpdf xpdf-utils ghostscript imagemagick && rm -rf /var/lib/apt/lists/*
3030
RUN sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read" pattern="PDF" \/>/g' /etc/ImageMagick-6/policy.xml
31-
RUN pip install --upgrade wheel pip poetry
31+
RUN pip install --upgrade wheel pip uv
3232

3333
# Install Node
3434
RUN apt-get update && apt-get install -y ca-certificates curl gnupg

INSTALL.rst

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,15 @@ First, create your working directory and ``cd`` into it. Clone the project into
2424
2525
$ git clone https://github.com/rero/sonar.git
2626
27-
You need to install `poetry`, it will handle the virtual environment creation for the project
28-
in order to sandbox our Python environment, as well as manage the dependency installation,
29-
among other things.
30-
31-
.. code-block:: console
32-
33-
$ pyenv install 3.9.9
34-
$ cd sonar
35-
$ pyenv local 3.9.9
36-
$ pip install poetry
27+
You need to `install uv <https://docs.astral.sh/uv/getting-started/installation/>`, it will handle the versions of Python and the virtual environment creation for the project in order to sandbox our Python environment, as well as manage the dependency installation, among other things.
3728

3829
Next, ``cd`` into the project directory and bootstrap the instance (this will install
3930
all Python dependencies and build all static assets):
4031

4132
.. code-block:: console
4233
4334
$ cd sonar
44-
$ poetry run ./scripts/bootstrap
35+
$ uv run ./scripts/bootstrap
4536
4637
Start all dependent services using docker-compose (this will start PostgreSQL,
4738
Elasticsearch 6, RabbitMQ and Redis):
@@ -70,36 +61,36 @@ Next, create database tables, search indexes and message queues:
7061

7162
.. code-block:: console
7263
73-
$ poetry run ./scripts/setup
64+
$ uv run poe setup
7465
7566
Running
7667
-------
7768
Start the webserver and the celery worker:
7869

7970
.. code-block:: console
8071
81-
$ poetry run ./scripts/server
72+
$ uv run poe server
8273
8374
Start a Python shell:
8475

8576
.. code-block:: console
8677
87-
$ poetry run ./scripts/console
78+
$ uv run poe console
8879
8980
Testing
9081
-------
9182
Run the test suite via the provided script:
9283

9384
.. code-block:: console
9485
95-
$ poetry run ./scripts/test
86+
$ uv run poe run_tests
9687
9788
By default, end-to-end tests are skipped. You can include the E2E tests like
9889
this:
9990

10091
.. code-block:: console
10192
102-
$ env E2E=yes poetry run ./scripts/test
93+
$ env E2E=yes uv run poe run_tests
10394
10495
For more information about end-to-end testing see `pytest-invenio
10596
<https://pytest-invenio.readthedocs.io/en/latest/usage.html#running-e2e-tests>`_.
@@ -121,7 +112,7 @@ already done:
121112

122113
.. code-block:: console
123114
124-
$ docker compose -f docker-compose.full.yml run --rm web-ui "poetry run ./scripts/setup"
115+
$ docker compose -f docker-compose.full.yml run --rm web-ui "uv run ./scripts/setup"
125116
126117
In addition to the normal ``docker-compose.yml``, this one will start:
127118

docker/build-images.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
# You should have received a copy of the GNU Affero General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19-
lock_file="$(dirname "$0")/../poetry.lock"
19+
lock_file="$(dirname "$0")/../uv.lock"
2020

2121

2222
if [ ! -f $lock_file ]; then
23-
echo "Lock file not found. Generate it by running 'poetry lock'."
23+
echo "Lock file not found. Generate it by running 'uv sync'."
2424
exit 1
2525
fi
2626

27-
# Extract poetry.lock hash to use as the docker image tag
27+
# Extract uv.lock hash to use as the docker image tag
2828
deps_ver="$(sed -n 's/content-hash = "\(.*\)"/\1/p' $lock_file)"
2929

3030
# Build dependencies image

0 commit comments

Comments
 (0)