Skip to content

Commit

Permalink
chore: migrate to pyproject.toml
Browse files Browse the repository at this point in the history
Use pyproject.toml instead of setup.py to configure metadata,
dependencies and build process.
  • Loading branch information
nijel committed Mar 18, 2024
1 parent 794cb1d commit 7596aa1
Show file tree
Hide file tree
Showing 29 changed files with 261 additions and 284 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
python-version: '3.11'
cache: pip
cache-dependency-path: requirements*.txt
cache-dependency-path: pyproject.toml
- name: Used versions
run: ./ci/print-versions
- name: Install pip dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
with:
python-version: '3.11'
cache: pip
cache-dependency-path: '**/requirements*.txt'
cache-dependency-path: docs/requirements.txt
- name: Install pip dependencies
run: pip install -r docs/requirements.txt
- name: Sphinx linkcheck
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/licenses-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ jobs:
path: |
~/.cache/pip
~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/requirements*.txt') }}-${{ hashFiles('.pre-commit-config.yaml') }}
key: ${{ runner.os }}-pre-commit-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements-lint.txt
python -m pip install $(sed -n 's/.*"\(pip==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(wheel==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(pre-commit==\([^"]*\)\)".*/\1/p' pyproject.toml)
- run: ./scripts/generate-license-data
- name: Update renovate branch
if: github.ref != 'refs/heads/main'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ jobs:
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: |-
3.11
python-version: 3.11
cache: pip
cache-dependency-path: '**/requirements*.txt'
cache-dependency-path: pyproject.toml
- name: Install pip dependencies
run: ./ci/pip-install migrations
- name: Check missing migrations
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
python-version: '3.11'
cache: pip
cache-dependency-path: requirements*.txt
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: ./ci/pip-install mypy

Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ jobs:
with:
python-version: '3.11'
cache: pip
cache-dependency-path: |
requirements-lint.txt
requirements-ci.txt
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install -r requirements-ci.txt
pip install -r requirements-lint.txt
python -m pip install $(sed -n 's/.*"\(pip==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(wheel==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(pylint==\([^"]*\)\)".*/\1/p' pyproject.toml)
- name: Add pylint annotator
uses: pr-annotators/pylint-pr-annotator@v0.0.1

Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/schema-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- main
paths:
- .github/workflows/schema-update.yml
- requirements.txt
- pyproject.toml
- docs/Makefile

jobs:
Expand All @@ -28,7 +28,12 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install $(grep -E '^(weblate-schemas)==' requirements.txt) -r requirements-lint.txt
- name: Install pip dependencies
run: |
python -m pip install $(sed -n 's/.*"\(pip==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(wheel==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(weblate-schemas==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(pre-commit==\([^"]*\)\)".*/\1/p' pyproject.toml)
- run: make -C docs update-schemas
- run: pre-commit run --files $(git diff --name-only)
continue-on-error: true
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
python-version: '3.11'
cache: pip
cache-dependency-path: requirements*.txt
cache-dependency-path: pyproject.toml
- name: Used versions
run: ./ci/print-versions
- name: Install pip dependencies
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
with:
python-version: '3.11'
cache: pip
cache-dependency-path: '**/requirements*.txt'
cache-dependency-path: pyproject.toml
- name: Used versions
run: ./ci/print-versions
- name: Install pip dependencies
Expand All @@ -95,9 +95,13 @@ jobs:
with:
python-version: '3.11'
cache: pip
cache-dependency-path: requirements-ci.txt
cache-dependency-path: pyproject.toml
- name: Install pip dependencies
run: pip install -r requirements-ci.txt
run: |
python -m pip install $(sed -n 's/.*"\(pip==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(wheel==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(twine==\([^"]*\)\)".*/\1/p' pyproject.toml)
pip install $(sed -n 's/.*"\(build==\([^"]*\)\)".*/\1/p' pyproject.toml)
- name: build
run: python -m build
- name: Twine check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: '**/requirements*.txt'
cache-dependency-path: pyproject.toml
- name: Used versions
run: ./ci/print-versions
- name: Install pip dependencies
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ weblate-*.tar.*
/dev-docker/data/
/dev-docker/weblate-dev/requirements.txt
*~
# Generated minimal deps
requirements-min.txt
/.dmypy.json
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ repos:
- id: check-yaml
- id: check-xml
- id: check-toml
- id: requirements-txt-fixer
- id: check-merge-conflict
- id: check-json
- id: debug-statements
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ include ChangeLog
include README.rst
include BACKERS.rst
include CONTRIBUTING.md
include requirements-*.txt
include requirements.txt
include manage.py
recursive-include weblate *.py
recursive-include weblate/static *
Expand Down
35 changes: 12 additions & 23 deletions ci/pip-install
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,30 @@
set -e -x

# Install CI requirements
python -m pip install -r requirements-ci.txt
# shellcheck disable=SC2046
python -m pip install $(sed -n 's/.*"\(pip==\([^"]*\)\)".*/\1/p' pyproject.toml)
# shellcheck disable=SC2046
pip install $(sed -n 's/.*"\(wheel==\([^"]*\)\)".*/\1/p' pyproject.toml)

# Workaround for
# SystemError: ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)
pip install --no-binary :all: cffi

if [ "${1:-latest}" = migrations ] ; then
# shellcheck disable=SC2046
pip install $(grep -E '^(Cython|pycairo)[>=<]' requirements.txt)
# shellcheck disable=SC2046
pip install $(grep -E '^(psycopg|mysqlclient)' requirements-optional.txt)
# shellcheck disable=SC2046
pip install $(grep -E '^coverage[>=<]' requirements-ci.txt)
pip install -r requirements.txt
elif [ "${1:-latest}" = minimal ] ; then
# Build list of minimal requirements
requirements-builder --req requirements-test.txt --level min > requirements-min.txt

# Install cython and pycairo first, these are needed during install of others
# shellcheck disable=SC2046
pip install $(grep -E '^(Cython|pycairo)[>=<]' requirements-min.txt)

pip install -r requirements-min.txt
pip install -e ".[all,mysql,ci]"
else
# Install cython and pycairo first, these are needed during install of others
# shellcheck disable=SC2046
pip install $(grep -E '^(Cython|pycairo)[>=<]' requirements.txt)
if [ "${1:-latest}" = minimal ] ; then
# Adjust deps to force minimal version
sed 's/>=/==/' pyproject.toml
fi

if [ "${1:-latest}" = mypy ] ; then
pip install -r requirements-mypy.txt
pip install -e ".[all,mysql,ci,mypy,test]"
else
pip install -r requirements-test.txt
pip install -e ".[all,mysql,ci,test]"
fi
if [ "${1:-latest}" = edge ] ; then
pip install --upgrade-strategy eager -U -r requirements-test.txt -r requirements-ci.txt
pip install --upgrade-strategy eager -U -e ".[all,mysql,test,ci]"
# Install from git / pre-release
pip install --no-deps --upgrade --force-reinstall https://github.com/translate/translate/archive/master.zip
pip install --no-deps --upgrade --force-reinstall https://github.com/WeblateOrg/language-data/archive/main.zip
Expand Down
10 changes: 1 addition & 9 deletions ci/run-migrate
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@ check
. ".venv-$TAG/bin/activate"
# Workaround for SystemError: ffi_prep_closure(): bad user_data
pip install --no-binary :all: cffi
# Use older psycopg2 for compatibility with older Django releases
pip install psycopg2-binary==2.7.7
# Use specific Selenium versions to avoid issues with pip resolver
pip install selenium==4.0.0a6.post2
# The 5.0.0 release removed some compatibility shims used by Celery
pip install importlib-metadata==4.12.0
pip install -r requirements.txt
# shellcheck disable=SC2046
pip install $(grep -E '^(psycopg|mysqlclient)' requirements-optional.txt)
pip install -e ".[all,mysql]"
check
echo "DATABASES['default']['HOST'] = '$CI_DB_HOST'" >> weblate/settings_test.py
check
Expand Down
4 changes: 2 additions & 2 deletions docs/admin/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ work, but is not as well tested as single version upgrades.
# Update Weblate inside your virtualenv
. ~/weblate-env/bin/pip install -e '.[all]'
# Install dependencies directly when not using virtualenv
pip install --upgrade -r requirements.txt
pip install --upgrade -e .
# Install optional dependencies directly when not using virtualenv
pip install --upgrade -r requirements-optional.txt
pip install --upgrade -e '.[all]'
#. New Weblate release might have new :ref:`python-deps`, please check if they cover
features you want.
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The tests are executed using :program:`py.test`. First you need to install test

.. code-block:: sh
pip install -r requirements-test.txt
pip install -e '.[test,lint]'
You can then execute the testsuite in the repository checkout:

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/snippets/pre-commit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ stored in :file:`pyproject.toml`.
The easiest approach to enforce all this is to install `pre-commit`_. The
repository contains configuration for it to verify the committed files are sane.
After installing it (it is already included in the
:file:`requirements-lint.txt`) turn it on by running ``pre-commit install`` in
:file:`pyproject.toml`) turn it on by running ``pre-commit install`` in
Weblate checkout. This way all your changes will be automatically checked.

You can also trigger check manually, to check all files run:
Expand Down
16 changes: 5 additions & 11 deletions docs/contributing/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,25 @@ sources.
virtualenv .venv
. .venv/bin/activate
3. Install Weblate (for this you need some system dependencies, see :doc:`../admin/install/source`):
3. Install Weblate (for this you need some system dependencies, see :doc:`../admin/install/source`) and all dependencies useful for development:

.. code-block:: sh
pip install -e '.[all]'
pip install -e '.[all,dev,ci,test,mypy,lint]'
3. Install all dependencies useful for development:

.. code-block:: sh
pip install -r requirements-dev.txt
4. Start a development server:
3. Start a development server:

.. code-block:: sh
weblate runserver
5. Depending on your configuration, you might also want to start Celery workers:
4. Depending on your configuration, you might also want to start Celery workers:

.. code-block:: sh
./weblate/examples/celery start
6. To run a test (see :ref:`local-tests` for more details):
5. To run a test (see :ref:`local-tests` for more details):

.. code-block:: sh
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The simple execution can look like:
Local testing
+++++++++++++

Before running test, please ensure test dependencies are installed. This can be done by `pip install -r requirements-dev.txt` or `pip install -e .[test]`.
Before running test, please ensure test dependencies are installed. This can be done by ``pip install -e .[test]``.

To run a testsuite locally, use:

Expand Down
Loading

0 comments on commit 7596aa1

Please sign in to comment.