Skip to content

Commit ad8c4ea

Browse files
committed
Modernize project to use pyproject.toml
1 parent 6e46eb6 commit ad8c4ea

File tree

8 files changed

+2529
-23
lines changed

8 files changed

+2529
-23
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ repos:
2525
- id: check-yaml
2626
- id: end-of-file-fixer
2727
- id: forbid-submodules
28-
- id: requirements-txt-fixer
2928
- id: trailing-whitespace
3029
- repo: https://github.com/pre-commit/mirrors-clang-format
3130
rev: v18.1.2

DEVELOPMENT.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ install a virtual environment with pre-commmit set up, and then use precommit to
88
install git hooks it to your local repository:
99

1010
```bash
11-
python3 -m venv .venv # Create a Python virtual env
12-
source ./.venv/bin/activate # Activate the virtual env for bash by source.
13-
pip install -r requirements.txt # Install latest requirements including pre-commit
14-
pre-commit install # Use pre-commit to install git hooks into the working repository.
11+
uv sync # Install dependencies
12+
uv run pre-commit install # Use pre-commit to install git hooks into the working repository.
1513
```
1614

1715
pre-commit is configured with .pre-commit-config.yaml which contains some

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ simple Python model of a C++ translation unit.
1919
Currently the environment variable `PY_CPPMODEL_LIBCLANG_PATH` must be defined
2020
to specify where libclang can be found. This may be fixed in the future.
2121

22-
## Testing
22+
## Development
23+
24+
To set up the development environment, execute the following commands:
25+
26+
```sh
27+
uv sync
28+
```
2329

2430
To run the tests, run:
2531

2632
```sh
27-
python3 -m venv .venv # Create a Python virtual env.
28-
source ./.venv/bin/activate # Activate the virtual env for bash by source.
33+
uv run python -m unittest discover .
34+
```
35+
36+
To run type checking:
2937

30-
mypy *.py --check-untyped-defs # Run mypy to check type hints.
31-
unittest discover . # Run tests.
38+
```sh
39+
uv run mypy *.py --check-untyped-defs
3240
```
3341

3442
## Attribution

pyproject.toml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[project]
2+
name = "py-cppmodel"
3+
version = "0.0.1"
4+
description = "A Python wrapper around clang's python bindings to generate a simple Python model of a C++ translation unit."
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
license = { file = "LICENSE" }
8+
authors = [{ name = "J.B. Coe", email = "jonathanbcoe@gmail.com" }]
9+
dependencies = [
10+
"clang>=14.0",
11+
]
12+
13+
[project.urls]
14+
Repository = "https://github.com/jbcoe/py_cppmodel"
15+
16+
[project.optional-dependencies]
17+
dev = [
18+
"mypy",
19+
"parameterized",
20+
"pre-commit",
21+
"pytype",
22+
]
23+
24+
[build-system]
25+
requires = ["hatchling"]
26+
build-backend = "hatchling.build"
27+
28+
[tool.hatch.build.targets.sdist]
29+
include = [
30+
"py_cppmodel.py",
31+
"LICENSE",
32+
"README.md",
33+
]
34+
35+
[tool.hatch.build.targets.wheel]
36+
packages = ["."]
37+
exclude = [
38+
"*.sh",
39+
"*.ipynb",
40+
"test_*.py",
41+
"requirements.txt",
42+
"mypy.ini",
43+
"Sandbox.ipynb",
44+
".github",
45+
]
46+
47+
[dependency-groups]
48+
dev = [
49+
"ipython>=8.12.3",
50+
"jupyter>=1.1.1",
51+
"parameterized>=0.9.0",
52+
"pre-commit>=4.5.1",
53+
"pytest>=8.3.5",
54+
]

requirements.txt

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

test.macos.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env bash
22

3-
# Virtual environment setup
4-
python3 -m venv .venv # Create a Python virtual env
5-
source ./.venv/bin/activate # Activate the virtual env for bash by source.
6-
python3 -m pip install -r requirements.txt # Install latest requirements.
3+
# Install dependencies
4+
uv sync
75

86
# Type checks
9-
python3 -m mypy *.py --check-untyped-defs # Run mypy to check type hints
7+
uv run mypy *.py --check-untyped-defs # Run mypy to check type hints
108

119
# Unit tests
1210
PY_CPPMODEL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib \
13-
python3 -m unittest discover --verbose . # Run tests
11+
uv run python3 -m unittest discover --verbose . # Run tests

test_py_cppmodel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import py_cppmodel
44
import unittest
55

6-
from ctypes.util import find_library
7-
86
LIBCLANG_PATH = os.environ.get("PY_CPPMODEL_LIBCLANG_PATH")
97
if not LIBCLANG_PATH:
108
raise RuntimeError("PY_CPPMODEL_LIBCLANG_PATH is unset")

uv.lock

Lines changed: 2456 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)