diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index a5140f2..847ebc3 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -35,6 +35,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - pip install -r requirements-lint.txt + pip install -e .[lint] - name: pre-commit run: pre-commit run --all diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index e2590d3..0a0d8e8 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -11,23 +11,16 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-setup-${{ hashFiles('**/requirements*.txt') }} + - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 with: - python-version: '3.11' - - name: Install dependencies - run: | - python -m pip install --upgrade pip wheel - pip install -r requirements-test.txt + python-version: '3.12' + cache: pip - name: build - run: python ./setup.py sdist bdist_wheel + run: pipx build - name: twine - run: twine check dist/* + run: pipx twine check dist/* - name: Publish package if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }} uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14f2e00..eaac5e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,20 +38,17 @@ jobs: name: ${{ matrix.os }}, Python ${{ matrix.python-version }} steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 - - name: Cache pip - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }} + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: pyproject.toml - name: Install pip dependencies run: | python -m pip install --upgrade pip wheel - pip install -r requirements.txt -r requirements-test.txt + pip install -e .[test] - name: Test run: | py.test --cov=wlc wlc diff --git a/Dockerfile b/Dockerfile index 0817ed1..a9cbffc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ LABEL org.opencontainers.image.title="wlc" LABEL org.opencontainers.image.description="Command-line client for Weblate" LABEL org.opencontainers.image.licenses="GPL-3.0-or-later" -COPY README.md LICENSE setup.cfg setup.py requirements.txt /app/ +COPY README.md LICENSE pyproject.toml /app/ COPY ./wlc/ /app/wlc # This hack is widely applied to avoid python printing issues in docker containers. diff --git a/pyproject.toml b/pyproject.toml index bb13e96..0bc4e68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,77 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=61.2"] + +[project] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "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 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Internationalization", + "Topic :: Software Development :: Localization", + "Topic :: Utilities" +] +dependencies = [ + "argcomplete", + "python-dateutil", + "pyxdg", + "requests>=2.25.0", + "urllib3>=1.26" +] +description = "A command-line utility for Weblate, translation tool with tight version control integration" +dynamic = ["version"] +keywords = [ + "i18n", + "l10n", + "gettext", + "git", + "mercurial", + "translate" +] +name = "wlc" +requires-python = ">=3.8" + +[[project.authors]] +email = "michal@cihar.com" +name = "Michal Čihař" + +[project.license] +text = "GPL-3.0-or-later" + +[project.optional-dependencies] +lint = ["pre-commit==3.4.0"] +test = [ + "pytest", + "pytest-cov", + "responses>=0.10.1,<0.24.0", + "twine==4.0.2" +] + +[project.readme] +content-type = "text/markdown" +file = "README.md" + +[project.scripts] +wlc = "wlc.main:main" + +[project.urls] +Documentation = "https://docs.weblate.org/" +Download = "https://github.com/WeblateOrg/wlc" +Funding = "https://weblate.org/donate/" +Homepage = "https://weblate.org/" +"Issue Tracker" = "https://github.com/WeblateOrg/wlc/issues" +"Source Code" = "https://github.com/WeblateOrg/wlc" +Twitter = "https://twitter.com/WeblateOrg" + [tool.isort] profile = "black" @@ -52,3 +126,15 @@ target-version = "py38" [tool.ruff.mccabe] max-complexity = 16 + +[tool.setuptools] +include-package-data = true +license-files = ["LICENSE"] +packages = ["wlc"] +platforms = ["any"] + +[tool.setuptools.dynamic.version] +attr = "wlc.__version__" + +[tool.setuptools.package-dir] +wlc = "wlc" diff --git a/requirements-lint.txt b/requirements-lint.txt deleted file mode 100644 index 42517ef..0000000 --- a/requirements-lint.txt +++ /dev/null @@ -1 +0,0 @@ -pre-commit==3.4.0 diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 2b95f1f..0000000 --- a/requirements-test.txt +++ /dev/null @@ -1,5 +0,0 @@ --r requirements.txt -pytest -pytest-cov -responses>=0.10.1,<0.24.0 -twine==4.0.2 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c292ad9..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -argcomplete -python-dateutil -pyxdg -requests>=2.25.0 -urllib3>=1.26 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9fbb641..0000000 --- a/setup.cfg +++ /dev/null @@ -1,65 +0,0 @@ -[metadata] -name = wlc -version = attr: wlc.__version__ -description = A command-line utility for Weblate, translation tool with tight version control integration -long_description = file: README.md -long_description_content_type = text/markdown -url = https://weblate.org/ -author = Michal Čihař -author_email = michal@cihar.com -license = GPL-3.0-or-later -license_file = LICENSE -platforms = any -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - 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 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Topic :: Software Development :: Internationalization - Topic :: Software Development :: Localization - Topic :: Utilities -download_url = https://github.com/WeblateOrg/wlc -keywords = i18n l10n gettext git mercurial translate -project_urls = - Issue Tracker=https://github.com/WeblateOrg/wlc/issues - Documentation=https://docs.weblate.org/ - Source Code=https://github.com/WeblateOrg/wlc - Twitter=https://twitter.com/WeblateOrg - Funding=https://weblate.org/donate/ - -[options] -packages = wlc -python_requires = >=3.8 -package_dir = wlc=wlc -include_package_data = 1 - -[options.entry_points] -console_scripts = - wlc = wlc.main:main - -[flake8] -max-complexity = 16 -extend-select = E,W1,W2,W3,W504,W505,W6 -enable-extensions = B,C,D,F,G,I,M,N,R,SF -# Should be fixed: -# D10 - we are missing many docstrings -# D20* - wrong docstring formatting -# D40* - many strings need rephrasing -# N818 - we do not want all exceptions to end up their name with Error -# T201 - we intentionally use print() -extend-ignore = D10,D200,D202,D204,D205,D209,D401,N818,T201 -exclude = .git,docs,.venv,build,.eggs -max-line-length = 88 - -[pycodestyle] -extend-select = E,W1,W2,W3,W504,W505,W6 -exclude = .git,docs,.venv,build,.eggs -max-line-length = 88 diff --git a/setup.py b/setup.py index c1aea25..146260e 100755 --- a/setup.py +++ b/setup.py @@ -8,7 +8,4 @@ from setuptools import setup -with open("requirements.txt") as handle: - REQUIRES = handle.read().split() - -setup(install_requires=REQUIRES) +setup()