Skip to content

Commit deadcbc

Browse files
committed
Migrate project to use pyproject.toml instead of setup.py
- Replaced setup.py with pyproject.toml as the primary configuration file. - Updated build and installation process to leverage PEP 517/518 standards. - Configured package metadata, dependencies, and optional dependencies in pyproject.toml. - Removed legacy setup.py and its references across the project. - Updated MANIFEST.in to ensure proper inclusion/exclusion of files in source distributions. - Adjusted GitHub Actions workflows and deployment script to use modern build commands (e.g., `python -m build`). - Updating .gitignore to include pyenv and some build dirs This commit modernizes the package and aligns it with current Python packaging standards, improving maintainability and compatibility with tools like pip, build, and twine.
1 parent 8dff2a3 commit deadcbc

File tree

10 files changed

+69
-41
lines changed

10 files changed

+69
-41
lines changed

β€Ž.github/workflows/test.ymlβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Install dependencies
2727
run: |
28-
python -m pip install --upgrade pip setuptools wheel
28+
python -m pip install --upgrade pip setuptools wheel build
2929
pip install pytest pytest-xdist # Testing packages
30-
python setup.py install_egg_info # Workaround https://github.com/pypa/pip/issues/4537
31-
pip install -e . # Run pytest
30+
python -m build --sdist --wheel
31+
pip install dist/*.whl # Run pytest
3232
- name: Import language_tool_python
3333
run: |
3434
printf "import language_tool_python\n" | python

β€Ž.gitignoreβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ __pycache__/
88
build/
99
dist/
1010
language_tool_python/LanguageTool-*/
11+
language_tool_python-*/
12+
pytest-cache-files-*/
13+
.env
14+
.venv
15+
env/
16+
venv/
17+
ENV/
18+
env.bak/
19+
venv.bak/

β€ŽMANIFEST.inβ€Ž

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
exclude Makefile
2-
include COPYING
3-
include README.rst
41
include run_doctest.py
5-
include test.bash
6-
include test.py
7-
include test_remote.bash
8-
include requirements.txt
9-
exclude language_tool_python/Language-Tool-*
2+
include tests/test_local.bash
3+
include tests/test_remote.bash
4+
prune pytest-cache-files-*/
5+
prune env/
6+
prune .env
7+
prune .venv
8+
prune env/
9+
prune venv/
10+
prune ENV/
11+
prune env.bak/
12+
prune venv.bak/

β€ŽMakefileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ check:
1515
./language_tool_python \
1616
$(wildcard ./language_tool_python/*.py) \
1717
$(wildcard *.py)
18-
python setup.py --long-description | rstcheck -
18+
python extract_long_description.py | rstcheck -

β€Žbuild_and_publish.shβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
rm -rf build/ dist/
2-
python setup.py sdist bdist_wheel
1+
rm -rf build/ dist/ *.egg-info/
2+
python -m pip install --upgrade pip setuptools wheel build
3+
python -m build
34
twine check dist/*
45
twine upload dist/* --verbose

β€Žextract_long_description.pyβ€Ž

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import tomllib
2+
import os
3+
4+
with open("pyproject.toml", "rb") as f:
5+
pyproject = tomllib.load(f)
6+
7+
readme_path = pyproject["project"]["readme"]
8+
9+
if os.path.exists(readme_path):
10+
with open(readme_path, "r", encoding="utf-8") as readme_file:
11+
print(readme_file.read())
12+
else:
13+
raise FileNotFoundError(f"{readme_path} not found.")

β€Žpyproject.tomlβ€Ž

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[project]
2+
name = "language_tool_python"
3+
version = "2.8.2"
4+
description = "Checks grammar using LanguageTool."
5+
readme = "README.md"
6+
license = { file = "LICENSE" }
7+
authors = [
8+
{ name = "Jack Morris", email = "jxmorris12@gmail.com" }
9+
]
10+
urls = { Homepage = "https://github.com/jxmorris12/language_tool_python" }
11+
12+
dependencies = [
13+
"pip",
14+
"requests",
15+
"tqdm",
16+
"wheel"
17+
]
18+
19+
[project.optional-dependencies]
20+
dev = [
21+
"pytest",
22+
"pytest-xdist",
23+
"pytest-cov",
24+
"pytest-runner"
25+
]
26+
27+
[build-system]
28+
requires = ["setuptools>=61.0", "wheel"]
29+
build-backend = "setuptools.build_meta"

β€Žrequirements.txtβ€Ž

Lines changed: 0 additions & 4 deletions
This file was deleted.

β€Žrequirements_dev.txtβ€Ž

Lines changed: 0 additions & 3 deletions
This file was deleted.

β€Žsetup.pyβ€Ž

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
Β (0)