Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,28 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.11"]
python: ["3.10", "3.11", "3.12", "3.13"]
clang: ["18"]

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python }}
- name: "Set up Python"
run: uv python install ${{ matrix.python }}
- name: Setup Clang
uses: egor-tensin/setup-clang@v1
with:
version: ${{ matrix.clang }}
platform: x64
- name: Install virtual env and dependencies
run: |
python -m venv .venv
source ./.venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install the project
run: uv sync
- name: Type checks
run: |
source ./.venv/bin/activate
python -m mypy *.py --check-untyped-defs
run: uv run mypy *.py --check-untyped-defs
- name: Tests
run: |
source ./.venv/bin/activate
PY_CPPMODEL_LIBCLANG_PATH=/usr/lib/llvm-18/lib/libclang-18.so.1 \
python -m unittest discover --verbose .
uv run python -m unittest discover --verbose .
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: forbid-submodules
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2
Expand Down
6 changes: 2 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ install a virtual environment with pre-commmit set up, and then use precommit to
install git hooks it to your local repository:

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

pre-commit is configured with .pre-commit-config.yaml which contains some
Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ simple Python model of a C++ translation unit.
Currently the environment variable `PY_CPPMODEL_LIBCLANG_PATH` must be defined
to specify where libclang can be found. This may be fixed in the future.

## Testing
## Development

To set up the development environment, execute the following commands:

```sh
uv sync
```

To run the tests, run:

```sh
python3 -m venv .venv # Create a Python virtual env.
source ./.venv/bin/activate # Activate the virtual env for bash by source.
./test.macos.sh
```

To run type checking:

mypy *.py --check-untyped-defs # Run mypy to check type hints.
unittest discover . # Run tests.
```sh
uv run mypy *.py --check-untyped-defs
```

## Attribution
Expand Down
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[project]
name = "py-cppmodel"
version = "0.0.1"
description = "A Python wrapper around clang's python bindings to generate a simple Python model of a C++ translation unit."
readme = "README.md"
requires-python = ">=3.10"
license = { file = "LICENSE" }
authors = [{ name = "J.B. Coe", email = "jonathanbcoe@gmail.com" }]
dependencies = [
"clang>=14.0",
]

[project.urls]
Repository = "https://github.com/jbcoe/py_cppmodel"

[project.optional-dependencies]
dev = [
"mypy",
"parameterized",
"pre-commit",
"pytype",
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pytype package is included in [project.optional-dependencies] but is not used anywhere in the project (no references in scripts, CI/CD workflows, or documentation). Consider removing it if it's not needed, or document its intended use if it will be used in the future.

Suggested change
"pytype",

Copilot uses AI. Check for mistakes.
]
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependencies are defined in two places: [project.optional-dependencies] and [dependency-groups]. This creates duplication and potential for inconsistency. According to PEP 735, [dependency-groups] is the modern standard for defining development dependencies when using uv. Consider removing [project.optional-dependencies] and keeping only [dependency-groups], or ensure they serve different purposes and document why both are needed.

Copilot uses AI. Check for mistakes.

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist]
include = [
"py_cppmodel.py",
"LICENSE",
"README.md",
]

[tool.hatch.build.targets.wheel]
packages = ["."]
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'packages = ["."]' for wheel builds will attempt to include the entire root directory as a package, which is unusual. Since py_cppmodel.py is a single-file module (not a package directory), you should either remove the 'packages' directive and rely on 'exclude' patterns, or use hatchling's default file discovery. The current configuration may lead to packaging issues.

Suggested change
packages = ["."]

Copilot uses AI. Check for mistakes.
exclude = [
"*.sh",
"*.ipynb",
"test_*.py",
"requirements.txt",
"mypy.ini",
"Sandbox.ipynb",
".github",
]

[dependency-groups]
dev = [
"ipython>=8.12.3",
"jupyter>=1.1.1",
"mypy>=1.19.1",
"parameterized>=0.9.0",
"pre-commit>=4.5.1",
"pytest>=8.3.5",
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [dependency-groups] section includes pytest as a development dependency, but the test files (test_py_cppmodel.py and test_parse_standard_library_includes.py) use unittest, and the CI workflow runs tests with 'python -m unittest discover'. Either pytest is not needed and should be removed, or the tests should be migrated to use pytest. If pytest is intended for future use, this should be documented.

Suggested change
"pytest>=8.3.5",

Copilot uses AI. Check for mistakes.
]
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [dependency-groups] section specifies version constraints (e.g., mypy>=1.19.1, pre-commit>=4.5.1) while [project.optional-dependencies] does not specify any version constraints for the same packages. This creates inconsistency in dependency management. If both sections are kept, they should have aligned version requirements, or one should be removed to maintain a single source of truth.

Copilot uses AI. Check for mistakes.
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

10 changes: 4 additions & 6 deletions test.macos.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env bash

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

# Type checks
python3 -m mypy *.py --check-untyped-defs # Run mypy to check type hints
uv run mypy *.py --check-untyped-defs # Run mypy to check type hints

# Unit tests
PY_CPPMODEL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib \
python3 -m unittest discover --verbose . # Run tests
uv run python3 -m unittest discover --verbose . # Run tests
2 changes: 0 additions & 2 deletions test_py_cppmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import py_cppmodel
import unittest

from ctypes.util import find_library

LIBCLANG_PATH = os.environ.get("PY_CPPMODEL_LIBCLANG_PATH")
if not LIBCLANG_PATH:
raise RuntimeError("PY_CPPMODEL_LIBCLANG_PATH is unset")
Expand Down
Loading
Loading