From 7596aa12b29786ca0fe7a4d4eb9ebf25b2591724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Mar 2024 13:02:15 +0100 Subject: [PATCH] chore: migrate to pyproject.toml Use pyproject.toml instead of setup.py to configure metadata, dependencies and build process. --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/licenses-update.yml | 7 +- .github/workflows/migrations.yml | 5 +- .github/workflows/mypy.yml | 2 +- .github/workflows/pylint.yml | 10 +- .github/workflows/schema-update.yml | 9 +- .github/workflows/setup.yml | 12 +- .github/workflows/test.yml | 2 +- .gitignore | 2 - .pre-commit-config.yaml | 1 - MANIFEST.in | 2 - ci/pip-install | 35 ++-- ci/run-migrate | 10 +- docs/admin/upgrade.rst | 4 +- docs/contributing/modules.rst | 2 +- docs/contributing/snippets/pre-commit.rst | 2 +- docs/contributing/start.rst | 16 +- docs/contributing/tests.rst | 2 +- pyproject.toml | 209 +++++++++++++++++++++- requirements-ci.txt | 8 - requirements-dev.txt | 11 -- requirements-lint.txt | 2 - requirements-mypy.txt | 14 -- requirements-optional.txt | 25 --- requirements-test.txt | 4 - requirements.txt | 57 ------ rundev.sh | 2 +- setup.py | 86 +-------- 29 files changed, 261 insertions(+), 284 deletions(-) delete mode 100644 requirements-ci.txt delete mode 100644 requirements-dev.txt delete mode 100644 requirements-lint.txt delete mode 100644 requirements-mypy.txt delete mode 100644 requirements-optional.txt delete mode 100644 requirements-test.txt delete mode 100644 requirements.txt diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index adab56149316..1b080c10e445 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6b68769885d4..97dfa9a7d01c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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 diff --git a/.github/workflows/licenses-update.yml b/.github/workflows/licenses-update.yml index 8b940fdd5921..2d68a30c38fd 100644 --- a/.github/workflows/licenses-update.yml +++ b/.github/workflows/licenses-update.yml @@ -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' diff --git a/.github/workflows/migrations.yml b/.github/workflows/migrations.yml index 9cf0f09b59a3..00583add439c 100644 --- a/.github/workflows/migrations.yml +++ b/.github/workflows/migrations.yml @@ -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 diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 1f356bbd1cdd..5114f6dd9c2e 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -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 diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 9cb74c75a2d8..182adc9a6e00 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -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 diff --git a/.github/workflows/schema-update.yml b/.github/workflows/schema-update.yml index 7fec31359357..31ec78374e23 100644 --- a/.github/workflows/schema-update.yml +++ b/.github/workflows/schema-update.yml @@ -12,7 +12,7 @@ on: - main paths: - .github/workflows/schema-update.yml - - requirements.txt + - pyproject.toml - docs/Makefile jobs: @@ -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 diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index dfdfc64e35c2..77e588a35c0a 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 858c2045209e..8033f287458f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.gitignore b/.gitignore index 5cca6d387e14..8908649510f2 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,4 @@ weblate-*.tar.* /dev-docker/data/ /dev-docker/weblate-dev/requirements.txt *~ -# Generated minimal deps -requirements-min.txt /.dmypy.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 65b6a9243f47..e5e631483e53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in index 25059600415e..d3be4867f6d2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 * diff --git a/ci/pip-install b/ci/pip-install index ca53210d31b1..1d5c32208292 100755 --- a/ci/pip-install +++ b/ci/pip-install @@ -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 diff --git a/ci/run-migrate b/ci/run-migrate index ee267d2af55a..cf4f4b9ba21a 100755 --- a/ci/run-migrate +++ b/ci/run-migrate @@ -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 diff --git a/docs/admin/upgrade.rst b/docs/admin/upgrade.rst index 4a30bc337861..6d21bff2ea53 100644 --- a/docs/admin/upgrade.rst +++ b/docs/admin/upgrade.rst @@ -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. diff --git a/docs/contributing/modules.rst b/docs/contributing/modules.rst index 7afc9e2ee930..981f134182bf 100644 --- a/docs/contributing/modules.rst +++ b/docs/contributing/modules.rst @@ -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: diff --git a/docs/contributing/snippets/pre-commit.rst b/docs/contributing/snippets/pre-commit.rst index 1309d6e61d4e..0de4d5aa908a 100644 --- a/docs/contributing/snippets/pre-commit.rst +++ b/docs/contributing/snippets/pre-commit.rst @@ -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: diff --git a/docs/contributing/start.rst b/docs/contributing/start.rst index 0aecdb0055f2..279fdbab1bad 100644 --- a/docs/contributing/start.rst +++ b/docs/contributing/start.rst @@ -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 diff --git a/docs/contributing/tests.rst b/docs/contributing/tests.rst index 979adfde41b4..bbc72d9a5062 100644 --- a/docs/contributing/tests.rst +++ b/docs/contributing/tests.rst @@ -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: diff --git a/pyproject.toml b/pyproject.toml index eb9f1be30e23..39985008c8f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,204 @@ [build-system] -# Minimum requirements for the build system to execute. -requires = ["setuptools", "wheel", "translate-toolkit"] # PEP 508 specifications. +build-backend = "setuptools.build_meta" +requires = ["setuptools>=61.2", "translate-toolkit"] + +[project] +authors = [{name = "Michal Čihař", email = "michal@weblate.org"}] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Framework :: Django", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Software Development :: Internationalization", + "Topic :: Software Development :: Localization", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content" +] +dependencies = [ + "aeidon>=1.10,<1.14", + "ahocorasick-rs>=0.16.0,<0.23.0", + "borgbackup>=1.2.5,<1.3", + "celery[redis]>=5.3.5,<5.4", + "certifi>=2023.7.22", + "charset-normalizer>=2.0.12,<4.0", + "crispy-bootstrap3==2024.1", + "cryptography>=42.0.2", + "cssselect>=1.2,<1.3", + "Cython>=0.29.14,<3.1", + "diff-match-patch==20230430", + "django-appconf>=1.0.3,<1.1", + "django-celery-beat>=2.5.0,<2.7", + "django-compressor>=4.0,<5", + "django-cors-headers>=3.13.0,<4.4", + "django-crispy-forms>=2.0.0,<2.2", + "django-filter>=21.1,<24.2", + "django-redis>=5.0.0,<6.0", + "Django[argon2]>=4.2,<5.1", + "djangorestframework>=3.14.0,<3.15", + "filelock<4,>=3.12.2", + "fluent.syntax>=0.18.1,<0.20", + "GitPython>=3.1.0,<3.2", + "hiredis>=1.0.1,<2.4", + "html2text>=2024.2.25,<2024.2.27", + "iniparse==0.5", + "jsonschema>=4.5,<5", + "lxml>=5.0.0,<5.2", + "misaka>=2.1.0,<2.2", + "mistletoe>=1.1.0,<1.4", + "nh3>=0.2.14,<0.3", + "openpyxl>=2.6.0,<3.2,!=3.0.2", + "packaging>=22,<24.1", + "phply>=1.2.6,<1.3", + "Pillow>=10.0.1,<10.3", + "pycairo>=1.20.0", + "Pygments>=2.15.0,<3.0", + "PyGObject>=3.40.1", + "pyicumessageformat>=1.0.0,<1.1", + "pyparsing>=3.1.1,<3.2", + "python-dateutil>=2.8.2", + "python-redis-lock[django]>=4,<4.1", + "rapidfuzz>=2.6.0,<3.7", + "redis>=4.6.0,!=5.0.1", + "requests>=2.31.0,<2.32", + "ruamel.yaml>=0.17.2,<0.19.0", + "sentry-sdk>=1.25.0,<2,!=1.32.0", + "siphashc>=2.1,<3.0", + "social-auth-app-django>=5.0.0,<6.0.0", + "social-auth-core>=4.3.0,<5.0.0", + "tesserocr>=2.6.1,<2.7.0", + "translate-toolkit>=3.12.2,<3.13", + "translation-finder>=2.15,<3.0", + "user-agents>=2.0,<2.3", + "weblate-language-data>=2023.9", + "weblate-schemas==2023.3" +] +description = "A web-based continuous localization system with tight version control integration" +keywords = [ + "i18n", + "l10n", + "gettext", + "git", + "mercurial", + "translate" +] +license = {text = "GPLv3+"} +name = "Weblate" +requires-python = ">=3.9" +version = "5.5" + +[project.optional-dependencies] +alibaba = [ + "aliyun-python-sdk-alimt>=3.2.0,<4.0.0" +] +all = [ + "aliyun-python-sdk-alimt>=3.2.0,<4.0.0", + "boto3>=1.28.62,<1.35.0", + "django-auth-ldap>=4.1.0,<5.0.0", + "git-review>=2.2.0,<2.4.0", + "google-cloud-translate>=3.8.0,<3.16.0", + "mercurial>=6.2,<7.0", + "openai>=1.3.0,<1.15", + "psycopg[binary]>=3.1.8,<4", + "python-akismet>=0.4.2,<0.5", + "python3-saml>=1.2.1" +] +amazon = [ + "boto3>=1.28.62,<1.35.0" +] +antispam = [ + "python-akismet>=0.4.2,<0.5" +] +ci = [ + "build==1.1.1", + "coverage==7.4.4", + "pip==24.0", + "setuptools==69.2.0", + "twine==5.0.0", + "virtualenv==20.25.1", + "wheel==0.43.0" +] +dev = [ + "django-debug-toolbar==4.3.0", + "PyICU==2.12", + "reuse==3.0.1", + "scour==0.38.2", + "tinyunicodeblock==1.3" +] +gerrit = [ + "git-review>=2.2.0,<2.4.0" +] +google = [ + "google-cloud-translate>=3.8.0,<3.16.0" +] +ldap = [ + "django-auth-ldap>=4.1.0,<5.0.0" +] +lint = [ + "pre-commit==3.6.2", + "pylint==3.1.0" +] +mercurial = [ + "mercurial>=6.2,<7.0" +] +mypy = [ + "boto3-stubs==1.34.56", + "celery-types==0.22.0", + "celery-types==0.22.0", + "django-stubs-ext==4.2.7", + "django-stubs[compatible-mypy]==4.2.7", + "djangorestframework-stubs[compatible-mypy]==3.14.5", + "lxml-stubs==0.5.1", + "mypy==1.7.1", + "types-jsonschema==4.21.0.20240311", + "types-openpyxl==3.1.0.20240311", + "types-Pillow==10.2.0.20240311", + "types-python-dateutil==2.9.0.20240316", + "types-requests==2.31.0.20240311" +] +mysql = [ + "mysqlclient>=2.1.1,<3" +] +openai = [ + "openai>=1.3.0,<1.15" +] +postgres = [ + "psycopg[binary]>=3.1.8,<4" +] +saml = [ + "python3-saml>=1.2.1" +] +test = [ + "responses==0.25.0", + "respx==0.20.2", + "selenium==4.18.1" +] +zxcvbn = ["django-zxcvbn-password==2.1.1"] + +[project.readme] +content-type = "text/x-rst" +file = "README.rst" + +[project.scripts] +weblate = "weblate.runner:main" +weblate-generate-secret-key = "weblate.utils.generate_secret_key:main" + +[project.urls] +Documentation = "https://docs.weblate.org/" +Download = "https://weblate.org/download/" +Funding = "https://weblate.org/donate/" +Homepage = "https://weblate.org/" +"Issue Tracker" = "https://github.com/WeblateOrg/weblate/issues" +"Release Notes" = "https://docs.weblate.org/en/latest/changes.html" +"Source Code" = "https://github.com/WeblateOrg/weblate" +Twitter = "https://twitter.com/WeblateOrg" [tool.black] target-version = ['py39'] @@ -186,3 +384,10 @@ max-positional-args = 8 max-public-methods = 180 max-returns = 21 max-statements = 100 + +[tool.setuptools] +include-package-data = true +zip-safe = false + +[tool.setuptools.packages] +find = {namespaces = false} diff --git a/requirements-ci.txt b/requirements-ci.txt deleted file mode 100644 index 4ff857e5eb37..000000000000 --- a/requirements-ci.txt +++ /dev/null @@ -1,8 +0,0 @@ -build==1.1.1 -coverage==7.4.4 -pip==24.0 -requirements-builder==0.4.4 -setuptools==69.2.0 -twine==5.0.0 -virtualenv==20.25.1 -wheel==0.43.0 diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index e5bccfee6c83..000000000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,11 +0,0 @@ --r docs/requirements.txt --r requirements-lint.txt --r requirements-optional.txt --r requirements-test.txt --r requirements-ci.txt --r requirements-mypy.txt -django-debug-toolbar==4.3.0 -PyICU==2.12 -reuse==3.0.1 -scour==0.38.2 -tinyunicodeblock==1.3 diff --git a/requirements-lint.txt b/requirements-lint.txt deleted file mode 100644 index ce7ab825fd59..000000000000 --- a/requirements-lint.txt +++ /dev/null @@ -1,2 +0,0 @@ -pre-commit==3.6.2 -pylint==3.1.0 diff --git a/requirements-mypy.txt b/requirements-mypy.txt deleted file mode 100644 index 79896cf948c0..000000000000 --- a/requirements-mypy.txt +++ /dev/null @@ -1,14 +0,0 @@ --r requirements-test.txt -boto3-stubs==1.34.56 -celery-types==0.22.0 -celery-types==0.22.0 -django-stubs-ext==4.2.7 -django-stubs[compatible-mypy]==4.2.7 -djangorestframework-stubs[compatible-mypy]==3.14.5 -lxml-stubs==0.5.1 -mypy==1.7.1 -types-jsonschema==4.21.0.20240311 -types-openpyxl==3.1.0.20240311 -types-Pillow==10.2.0.20240311 -types-python-dateutil==2.9.0.20240316 -types-requests==2.31.0.20240311 diff --git a/requirements-optional.txt b/requirements-optional.txt deleted file mode 100644 index 7e2cf4f1db59..000000000000 --- a/requirements-optional.txt +++ /dev/null @@ -1,25 +0,0 @@ --r requirements.txt -# Alibaba -aliyun-python-sdk-alimt>=3.2.0,<4.0.0 -# Amazon -boto3>=1.28.62,<1.35.0 -# LDAP -django-auth-ldap>=4.1.0,<5.0.0 -# zxcvbn -django-zxcvbn-password==2.1.1 -# Gerrit -git-review>=2.2.0,<2.4.0 -# Google -google-cloud-translate>=3.8.0,<3.16.0 -# Mercurial -mercurial>=6.2,<7.0 -# MySQL -mysqlclient>=2.1.1,<3 -# OpenAI -openai>=1.3.0,<1.15 -# Postgres -psycopg[binary]>=3.1.8,<4 -# Antispam -python-akismet>=0.4.2,<0.5 -# SAML -python3-saml>=1.2.1 diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index a496d7f5fba2..000000000000 --- a/requirements-test.txt +++ /dev/null @@ -1,4 +0,0 @@ --r requirements-optional.txt -responses==0.25.0 -respx==0.20.2 -selenium==4.18.1 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b74cd58f61e3..000000000000 --- a/requirements.txt +++ /dev/null @@ -1,57 +0,0 @@ -aeidon>=1.10,<1.14 -ahocorasick-rs>=0.16.0,<0.23.0 -borgbackup>=1.2.5,<1.3 -celery[redis]>=5.3.5,<5.4 -certifi>=2023.7.22 -charset-normalizer>=2.0.12,<4.0 -crispy-bootstrap3==2024.1 -cryptography>=42.0.2 -cssselect>=1.2,<1.3 -Cython>=0.29.14,<3.1 -diff-match-patch==20230430 -django-appconf>=1.0.3,<1.1 -django-celery-beat>=2.5.0,<2.7 -django-compressor>=4.0,<5 -django-cors-headers>=3.13.0,<4.4 -django-crispy-forms>=2.0.0,<2.2 -django-filter>=21.1,<24.2 -django-redis>=5.0.0,<6.0 -Django[argon2]>=4.2,<5.1 -djangorestframework>=3.14.0,<3.15 -filelock<4,>=3.12.2 -fluent.syntax>=0.18.1,<0.20 -GitPython>=3.1.0,<3.2 -hiredis>=1.0.1,<2.4 -html2text>=2024.2.25,<2024.2.27 -iniparse==0.5 -jsonschema>=4.5,<5 -lxml>=5.0.0,<5.2 -misaka>=2.1.0,<2.2 -mistletoe>=1.1.0,<1.4 -nh3>=0.2.14,<0.3 -openpyxl>=2.6.0,<3.2,!=3.0.2 -packaging>=22,<24.1 -phply>=1.2.6,<1.3 -Pillow>=10.0.1,<10.3 -pycairo>=1.20.0 -Pygments>=2.15.0,<3.0 -PyGObject>=3.40.1 -pyicumessageformat>=1.0.0,<1.1 -pyparsing>=3.1.1,<3.2 -python-dateutil>=2.8.2 -python-redis-lock[django]>=4,<4.1 -rapidfuzz>=2.6.0,<3.7 -# Avoid redis incompatible with Celery, see https://github.com/WeblateOrg/weblate/issues/11000 -redis>=4.6.0,!=5.0.1 -requests>=2.31.0,<2.32 -ruamel.yaml>=0.17.2,<0.19.0 -sentry-sdk>=1.25.0,<2,!=1.32.0 -siphashc>=2.1,<3.0 -social-auth-app-django>=5.0.0,<6.0.0 -social-auth-core>=4.3.0,<5.0.0 -tesserocr>=2.6.1,<2.7.0 -translate-toolkit>=3.12.2,<3.13 -translation-finder>=2.15,<3.0 -user-agents>=2.0,<2.3 -weblate-language-data>=2023.9 -weblate-schemas==2023.3 diff --git a/rundev.sh b/rundev.sh index 1e237b83193f..afed153b5b91 100755 --- a/rundev.sh +++ b/rundev.sh @@ -24,7 +24,7 @@ cd dev-docker/ build() { mkdir -p data # Build single requirements file - sed '/^-r/D' ../requirements.txt ../requirements-optional.txt ../requirements-test.txt > weblate-dev/requirements.txt + sed -n 's/^ "\([][a-zA-Z._0-9-]\+[<>=].*\)".*/\1/p' ../pyproject.toml > weblate-dev/requirements.txt # Build the container docker compose build --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" diff --git a/setup.py b/setup.py index c87883653543..ac081fad80af 100755 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from glob import glob from itertools import chain -from setuptools import find_packages, setup +from setuptools import setup from setuptools.command.build_py import build_py from translate.tools.pocompile import convertmo @@ -20,38 +20,6 @@ "weblate/locale/*/LC_MESSAGES/*.po", ] -# allow setup.py to be run from any path -os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) - -with open("README.rst") as readme: - README = readme.read() - -with open("requirements.txt") as requirements: - REQUIRES = requirements.read().splitlines() - -EXTRAS = {"all": [], "test": []} -with open("requirements-optional.txt") as requirements: - section = None - for line in requirements: - line = line.strip() - if line.startswith("-r") or not line: - continue - if line.startswith("#"): - section = line[2:] - else: - dep = line.split(";")[0].strip() - EXTRAS[section] = dep - if section not in {"MySQL", "zxcvbn"}: - EXTRAS["all"].append(dep) -with open("requirements-test.txt") as requirements: - section = None - for line in requirements: - line = line.strip() - if line.startswith(("-r", "#")) or not line: - continue - dep = line.split(";")[0].strip() - EXTRAS["test"].append(dep) - class WeblateBuildPy(build_py): def find_package_modules(self, package, package_dir): @@ -91,57 +59,5 @@ class WeblateBuild(build): setup( - name="Weblate", - version="5.5", - python_requires=">=3.9", - packages=find_packages(), - include_package_data=True, - description=( - "A web-based continuous localization system with " - "tight version control integration" - ), - long_description=README, - long_description_content_type="text/x-rst", - license="GPLv3+", - keywords="i18n l10n gettext git mercurial translate", - url="https://weblate.org/", - download_url="https://weblate.org/download/", - project_urls={ - "Issue Tracker": "https://github.com/WeblateOrg/weblate/issues", - "Documentation": "https://docs.weblate.org/", - "Source Code": "https://github.com/WeblateOrg/weblate", - "Twitter": "https://twitter.com/WeblateOrg", - "Release Notes": "https://docs.weblate.org/en/latest/changes.html", - "Funding": "https://weblate.org/donate/", - }, - author="Michal Čihař", - author_email="michal@weblate.org", - install_requires=REQUIRES, - zip_safe=False, - extras_require=EXTRAS, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "Framework :: Django", - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Software Development :: Internationalization", - "Topic :: Software Development :: Localization", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: Dynamic Content", - ], - entry_points={ - "console_scripts": [ - "weblate = weblate.runner:main", - "weblate-generate-secret-key = weblate.utils.generate_secret_key:main", - ] - }, cmdclass={"build_py": WeblateBuildPy, "build_mo": BuildMo, "build": WeblateBuild}, )