Skip to content

Commit

Permalink
chore: switch to pyproject.toml based build
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Oct 12, 2023
1 parent bf2225a commit fb55e57
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 100 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ 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('**/requirements*.txt') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pyproject.toml') }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Update pip
run: python -m pip install --upgrade pip wheel
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements-lint.txt
if [ -f requirements-lint.txt ] ; then
pip install -r requirements-lint.txt
else
pip install -e .[lint]
fi
- name: pre-commit
run: pre-commit run --all
14 changes: 6 additions & 8 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ 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'
python-version: '3.12'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements-test.txt
pip install -e .[test]
- name: build
run: python ./setup.py sdist bdist_wheel
run: pyproject-build
- name: twine
run: twine check dist/*
- name: Publish package
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: requirements-txt-fixer
- id: check-merge-conflict
- id: check-json
- id: debug-statements
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 setup.py /app/
COPY ./wlc/ /app/wlc

# This hack is widely applied to avoid python printing issues in docker containers.
Expand Down
90 changes: 90 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
[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 = "[email protected]"
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",
"build==1.0.3",
"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"

Expand Down Expand Up @@ -52,3 +127,18 @@ target-version = "py38"

[tool.ruff.mccabe]
max-complexity = 16

[tool.setuptools]
include-package-data = true
license-files = ["LICENSE"]
platforms = ["any"]

[tool.setuptools.dynamic.version]
attr = "wlc.__version__"

[tool.setuptools.package-dir]
wlc = "wlc"

[tool.setuptools.packages.find]
include = ["translate*"]
namespaces = true
1 change: 0 additions & 1 deletion requirements-lint.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements-test.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

65 changes: 0 additions & 65 deletions setup.cfg

This file was deleted.

5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@

from setuptools import setup

with open("requirements.txt") as handle:
REQUIRES = handle.read().split()

setup(install_requires=REQUIRES)
setup()

0 comments on commit fb55e57

Please sign in to comment.