Skip to content

Commit 564abbb

Browse files
committed
Initialize the Cython template instance
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
0 parents  commit 564abbb

29 files changed

Lines changed: 1409 additions & 0 deletions

.copier-answers.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changes here will be overwritten by Copier
2+
_commit: 8965e30
3+
_src_path: https://github.com/python-project-templates/base.git
4+
add_docs: true
5+
add_extension: cython
6+
add_wiki: true
7+
email: 3105306+timkpaine@users.noreply.github.com
8+
github: python-project-templates
9+
project_description: A Python project template with compiled Cython extensions
10+
project_name: python template cython
11+
python_version_primary: '3.11'
12+
team: Python Project Template Authors

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
examples/* linguist-documentation
2+
docs/* linguist-documentation
3+
*.ipynb linguist-documentation
4+
Makefile linguist-documentation
5+
6+
*.md text=auto eol=lf
7+
*.py text=auto eol=lf
8+
*.toml text=auto eol=lf
9+
*.yaml text=auto eol=lf

.github/CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at 3105306+timkpaine@users.noreply.github.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug to help us improve
4+
title: '[BUG] '
5+
labels: 'type: bug'
6+
assignees: ''
7+
---
8+
9+
**Description**
10+
A clear and concise description of the bug.
11+
12+
**Steps to Reproduce**
13+
1.
14+
2.
15+
3.
16+
17+
**Expected Behavior**
18+
What you expected to happen.
19+
20+
**Actual Behavior**
21+
What actually happened. Include full error messages or tracebacks if available.
22+
23+
**Environment**
24+
- OS: [e.g. Ubuntu 22.04, macOS 14.0, Windows 11]
25+
- Python version: [e.g. 3.11.5] (`python --version`)
26+
- Package version: (`pip show python-template-cython | grep Version`)
27+
28+
**Additional Context**
29+
Add any other relevant context, logs, or screenshots.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature or improvement
4+
title: '[FEATURE] '
5+
labels: 'type: enhancement'
6+
assignees: ''
7+
---
8+
9+
**Problem Statement**
10+
A clear description of the problem this feature would solve. Ex. "I'm always frustrated when [...]"
11+
12+
**Proposed Solution**
13+
A clear description of the desired behavior or feature.
14+
15+
**Alternatives Considered**
16+
Any alternative solutions or workarounds you've considered.
17+
18+
**Additional Context**
19+
Add any other context, mockups, or examples.

.github/ISSUE_TEMPLATE/question.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Question
3+
about: Ask a question about usage or behavior
4+
title: '[QUESTION] '
5+
labels: 'tag: question'
6+
assignees: ''
7+
---
8+
9+
**Question**
10+
A clear and concise description of your question.
11+
12+
**Context**
13+
What are you trying to accomplish? Include relevant code snippets, configuration, or links to documentation you've already consulted.
14+
15+
**Environment**
16+
If relevant, include your environment details (OS, language versions, package version).

.github/dependabot.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"
11+
labels:
12+
- "part: github_actions"
13+
14+
- package-ecosystem: "pip"
15+
directory: "/"
16+
schedule:
17+
interval: "monthly"
18+
cooldown:
19+
default-days: 7
20+
groups:
21+
python:
22+
patterns:
23+
- "*"
24+
labels:
25+
- "lang: python"
26+
- "part: dependencies"

.github/pull_request_template.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Description
2+
3+
Brief description of the changes in this PR.
4+
5+
## Type of Change
6+
7+
- [ ] Bug fix
8+
- [ ] New feature
9+
- [ ] Documentation update
10+
- [ ] Refactor / code cleanup
11+
- [ ] CI / build configuration
12+
- [ ] Other (describe below)
13+
14+
## Checklist
15+
16+
- [ ] Linting passes (`make lint`)
17+
- [ ] Tests pass (`make test`)
18+
- [ ] New tests added for new functionality
19+
- [ ] Documentation updated (if applicable)
20+
- [ ] Changelog / version bump (if applicable)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""Verify installed native wheels, including wheels rebuilt from each sdist."""
2+
3+
import json
4+
import subprocess
5+
import sys
6+
import venv
7+
from pathlib import Path
8+
from tempfile import TemporaryDirectory
9+
from zipfile import ZipFile
10+
11+
from packaging.tags import sys_tags
12+
from packaging.utils import parse_wheel_filename
13+
14+
15+
def test_wheel(wheel):
16+
with ZipFile(wheel) as archive:
17+
modules = [
18+
name.split(".", 1)[0].replace("/", ".") for name in archive.namelist() if name.endswith((".so", ".pyd")) and ".dist-info/" not in name
19+
]
20+
if not modules:
21+
raise RuntimeError(f"No compiled extensions in {wheel.name}")
22+
with TemporaryDirectory() as directory:
23+
env = Path(directory) / "venv"
24+
venv.EnvBuilder(with_pip=True).create(env)
25+
python = env / ("Scripts/python.exe" if sys.platform == "win32" else "bin/python")
26+
subprocess.run([str(python), "-m", "pip", "install", str(wheel)], check=True, cwd=directory)
27+
subprocess.run(
28+
[
29+
str(python),
30+
"-I",
31+
"-c",
32+
(
33+
"import importlib, importlib.machinery, json, sys; "
34+
"modules = [importlib.import_module(name) for name in json.loads(sys.argv[1])]; "
35+
"assert all(any(m.__file__.endswith(s) for s in importlib.machinery.EXTENSION_SUFFIXES) for m in modules)"
36+
),
37+
json.dumps(modules),
38+
],
39+
check=True,
40+
cwd=directory,
41+
)
42+
print(f"Verified compiled imports from {wheel.name}", flush=True)
43+
44+
45+
def main():
46+
compatible_tags = set(sys_tags())
47+
wheels = [wheel for wheel in Path("dist").glob("*.whl") if parse_wheel_filename(wheel.name)[3] & compatible_tags]
48+
if not wheels:
49+
raise RuntimeError("No compatible wheels in dist/")
50+
for wheel in wheels:
51+
test_wheel(wheel.resolve())
52+
for sdist in Path("dist").glob("*.tar.gz"):
53+
with TemporaryDirectory() as directory:
54+
subprocess.run(
55+
[sys.executable, "-m", "uv", "build", "--wheel", "--out-dir", directory, str(sdist.resolve())],
56+
check=True,
57+
cwd=directory,
58+
)
59+
for wheel in Path(directory).glob("*.whl"):
60+
test_wheel(wheel)
61+
62+
63+
if __name__ == "__main__":
64+
main()

.github/workflows/build.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Build Status
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
paths-ignore:
10+
- LICENSE
11+
- README.md
12+
pull_request:
13+
branches:
14+
- main
15+
workflow_dispatch:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
permissions:
22+
contents: read
23+
checks: write
24+
pull-requests: write
25+
26+
jobs:
27+
build:
28+
name: build (${{ matrix.platform }}-${{ matrix.python.version }})
29+
runs-on: ${{ matrix.platform }}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
platform:
34+
- ubuntu-latest
35+
- ubuntu-24.04-arm
36+
- macos-latest
37+
- windows-latest
38+
python:
39+
- version: "3.11"
40+
cibuildwheel: "cp311"
41+
primary: true
42+
- version: "3.12"
43+
cibuildwheel: "cp312"
44+
primary: false
45+
- version: "3.13"
46+
cibuildwheel: "cp313"
47+
primary: false
48+
- version: "3.14"
49+
cibuildwheel: "cp314"
50+
primary: false
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
55+
with:
56+
persist-credentials: false
57+
58+
- name: Setup Python
59+
uses: actions-ext/python/setup@ec67f82b3bd863948308a41ecb9e70547cbb19c7
60+
with:
61+
version: ${{ matrix.python.version }}
62+
63+
- name: Setup compiler
64+
uses: actions-ext/cpp/setup@22ebafc6f57971978e964f9977333ac98a7c49d9
65+
with:
66+
clang_format: 'false'
67+
68+
- name: Install dependencies
69+
run: make develop
70+
71+
- name: Lint
72+
run: make lint
73+
if: matrix.platform == 'ubuntu-latest' && matrix.python.primary
74+
75+
- name: Checks
76+
run: make checks
77+
if: matrix.platform == 'ubuntu-latest' && matrix.python.primary
78+
79+
- name: Test
80+
run: make coverage
81+
82+
- name: Upload test results (Python)
83+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
84+
with:
85+
name: test-results-${{ matrix.platform }}-${{ matrix.python.version }}
86+
path: junit.xml
87+
if: always()
88+
89+
- name: Publish test results
90+
uses: EnricoMi/publish-unit-test-result-action@d0a4676d0e0b938bc201470d88276b7c74c712b3 # v2.24.0
91+
with:
92+
files: '**/junit.xml'
93+
if: matrix.platform == 'ubuntu-latest' && matrix.python.primary && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
94+
95+
- name: Upload coverage
96+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
97+
with:
98+
token: ${{ secrets.CODECOV_TOKEN }}
99+
100+
- name: Build distributions
101+
run: |
102+
make clean
103+
make dist-py-wheel
104+
make dist-check
105+
env:
106+
CIBW_BUILD: "${{ matrix.python.cibuildwheel }}-*"
107+
108+
- name: Test distributions
109+
run: make test-dist
110+
111+
- name: Upload distributions
112+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
113+
with:
114+
name: dist-${{ matrix.platform }}-${{ matrix.python.version }}
115+
path: dist

0 commit comments

Comments
 (0)