diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml new file mode 100644 index 000000000..e59176def --- /dev/null +++ b/.github/actions/setup-env/action.yml @@ -0,0 +1,38 @@ +name: Setup enviroment +description: Setup python environment with uv and install apt depdendencies + +inputs: + install-texlive: + description: "Whether to install texlive dependencies" + required: false + # Composite actions don't support boolean inputs yet. + # See https://github.com/actions/runner/issues/2238 + default: "false" + +runs: + using: "composite" + + steps: + - name: Install apt dependencies + run: | + sudo apt-get update + sudo apt-get install -y curl libpq-dev libdb-dev + shell: sh + + - name: Install texlive + if: inputs.install-texlive == 'true' + run: | + sudo apt-get install -y texlive-latex-base texlive-lang-polish texlive-lang-czechslovak texlive-latex-extra texlive-pstricks texlive-luatex + shell: sh + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + version: "latest" + python-version: "3.11" + activate-environment: true + + - name: Install python dependencies + run: | + uv pip install -r requirements.txt + shell: sh diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 96c841b39..25e2579d3 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -10,22 +10,12 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Install apt dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl libpq-dev libdb-dev + - uses: ./.github/actions/setup-env - - name: Install pip dependencies + - name: Install python dependencies for generating docs run: | - python -m pip install --upgrade pip wheel setuptools - python setup.py install_egg_info - pip install --upgrade -r rst/requirements.txt - pip install --upgrade -r requirements.txt + uv pip install --upgrade -r rst/requirements.txt + uv pip install --upgrade -r requirements.txt - name: Run Sphinx run: | @@ -52,4 +42,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c558f2979..bdad3f174 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -12,22 +12,9 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.11 - uses: actions/setup-python@v5 + - uses: ./.github/actions/setup-env with: - python-version: '3.11' - - - name: Install apt dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl libpq-dev libdb-dev - sudo apt-get install -y texlive-latex-base texlive-lang-polish texlive-lang-czechslovak texlive-latex-extra texlive-pstricks texlive-luatex - - - name: Install pip dependencies - run: | - python -m pip install --upgrade pip wheel setuptools - python setup.py install_egg_info - pip install --upgrade -r requirements.txt + install-texlive: "true" - name: Run tests run: | diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 3cca3f0dd..9dfea7d6b 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -14,22 +14,9 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.11 - uses: actions/setup-python@v5 + - uses: ./.github/actions/setup-env with: - python-version: '3.11' - - - name: Install apt dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl libpq-dev libdb-dev - sudo apt-get install -y texlive-latex-base texlive-lang-polish texlive-latex-extra texlive-pstricks texlive-luatex - - - name: Install pip dependencies - run: | - python -m pip install --upgrade pip wheel setuptools - python setup.py install_egg_info - pip install --upgrade -r requirements.txt + install-texlive: "true" - name: Run tests run: | diff --git a/.github/workflows/translations-download.yml b/.github/workflows/translations-download.yml index c40e32bdb..8db56aab4 100644 --- a/.github/workflows/translations-download.yml +++ b/.github/workflows/translations-download.yml @@ -17,21 +17,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' + - uses: ./.github/actions/setup-env - - name: Install apt dependencies + - name: Install gettext run: | - sudo apt-get update - sudo apt-get install -y curl libpq-dev libdb-dev gettext - - - name: Install pip dependencies - run: | - python -m pip install --upgrade pip wheel setuptools - python setup.py install_egg_info - pip install --upgrade -r requirements.txt + sudo apt-get install -y gettext - name: Install TX client run: | diff --git a/.github/workflows/translations-upload.yml b/.github/workflows/translations-upload.yml index 9ae9519ed..ff437db82 100644 --- a/.github/workflows/translations-upload.yml +++ b/.github/workflows/translations-upload.yml @@ -17,21 +17,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' + - uses: ./.github/actions/setup-env - - name: Install apt dependencies + - name: Install gettext run: | - sudo apt-get update - sudo apt-get install -y curl libpq-dev libdb-dev gettext - - - name: Install pip dependencies - run: | - python -m pip install --upgrade pip wheel setuptools - python setup.py install_egg_info - pip install --upgrade -r requirements.txt + sudo apt-get install -y gettext - name: Install TX client run: | diff --git a/Dockerfile b/Dockerfile index d154e5408..58d9f6d11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,19 +48,25 @@ RUN sed -i -e "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen && \ locale-gen # Installing python dependencies +RUN pip3 install uv + USER oioioi -ENV PATH $PATH:/home/oioioi/.local/bin/ +ENV UV_NO_CACHE 1 +ENV VIRTUAL_ENV /home/oioioi/venv +RUN uv venv $VIRTUAL_ENV +# The python executable from the venv must have priority over the system one. +ENV PATH $VIRTUAL_ENV/bin/:$PATH ENV BERKELEYDB_DIR /usr -RUN pip3 install --user psycopg2-binary twisted uwsgi -RUN pip3 install --user bsddb3==6.2.7 +RUN uv pip install psycopg2-binary twisted uwsgi +RUN uv pip install bsddb3==6.2.7 WORKDIR /sio2/oioioi COPY --chown=oioioi:oioioi . ./ -RUN pip3 install --user -r requirements.txt filetracker[server] -RUN pip3 install --user -r requirements_static.txt +RUN uv pip install -r requirements.txt filetracker[server] +RUN uv pip install -r requirements_static.txt # Installing node dependencies ENV PATH $PATH:/sio2/oioioi/node_modules/.bin diff --git a/GUIDE.md b/GUIDE.md index 8922389a4..b9b90a58e 100644 --- a/GUIDE.md +++ b/GUIDE.md @@ -130,7 +130,7 @@ We only need to build (here comes the magic word) SIO dependent images. Once you built the image, you can set the container up. Remember - things like dependencies (`requirements[_static].txt`, `setup.py`) are downloaded during the built, so if you changed something in those places you either need to build the image again, -or apply these changes by hand (e.g. do `pip install`). +or apply these changes by hand (e.g. do `uv pip install`). If you have good internet connection and adequate CPU, it shouldn't be hard to build the image again, especially that it is more stable approach. diff --git a/rst/requirements.txt b/rst/requirements.txt index 7c0acf930..16f21b280 100644 --- a/rst/requirements.txt +++ b/rst/requirements.txt @@ -1,5 +1,6 @@ sphinx>7.1.0 furo -sphinx-autoapi==3.0.0 # sphinx extension https://sphinx-autoapi.readthedocs.io/en/latest/index.html -pydantic==2.5.2 -pydantic-settings \ No newline at end of file +# sphinx extension https://sphinx-autoapi.readthedocs.io/en/latest/index.html +sphinx-autoapi>3.5.0 +pydantic +pydantic-settings