Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
matrix:
template:
- python
- cython
- cpp
- js
- jupyter
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ gen-python: ## regenerate the python template from scratch
copier copy -w . ../python-template --data-file examples/python.yaml
cd ../python-template && $(SED) 's#_src_path: .#_src_path: https://github.com/python-project-templates/base.git#g' ./.copier-answers.yaml

.PHONY: gen-cython test-cython
gen-cython: ## regenerate the Cython template
copier copy --defaults --overwrite --vcs-ref=$$(git rev-parse HEAD) . ../python-template-cython --data-file examples/cython.yaml
cd ../python-template-cython && $(SED) 's#_src_path: .#_src_path: https://github.com/python-project-templates/base.git#g' ./.copier-answers.yaml

test-cython: ## test the generated Cython project
git -C ../python-template-cython init
git -C ../python-template-cython add .
$(MAKE) -C ../python-template-cython develop lint checks coverage dist test-dist

gen-cpp: ## regenerate the c++ template from scratch
mkdir -p ../python-template-cpp && cd ../python-template-cpp && rm -rf ./* && rm -rf .copier-answers.yaml .gitignore .github .gitattributes
copier copy -w . ../python-template-cpp --data-file examples/cpp.yaml
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ copier copy https://github.com/python-project-templates/base.git path/to/new/pro

One selector chooses a template:

- `Python / …` options generate pure Python, C++, JavaScript, Jupyter, Rust, and WebAssembly-backed Python packages from `python/`.
- `Python / …` options generate pure Python, Cython, C++, JavaScript, Jupyter, Rust, and WebAssembly-backed Python packages from `python/`.
- `JavaScript / UI Toolkit / Svelte` generates a Svelte package and showcase from `javascript/uitk-svelte/`.
- `JavaScript / UI Toolkit / Lit + Web Awesome` generates custom elements and a showcase from `javascript/uitk-webawesome/`.
- `JavaScript / Site / React` generates a React site with Vite, Vitest, and Playwright from `javascript/site-react/`.
Expand Down
2 changes: 2 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ add_extension:
choices:
Python / Pure:
value: python
Python / Cython:
value: cython
Python / C++:
value: cpp
Python / JavaScript:
Expand Down
10 changes: 10 additions & 0 deletions examples/cython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
add_docs: true
add_wiki: false
add_extension: cython
email: 3105306+timkpaine@users.noreply.github.com
github: python-project-templates
project_description: A Python project template with compiled Cython extensions
project_name: python template cython
python_version_primary: '3.11'
team: Python Project Template Authors
9 changes: 9 additions & 0 deletions python/cython/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
examples/* linguist-documentation
docs/* linguist-documentation
*.ipynb linguist-documentation
Makefile linguist-documentation

*.md text=auto eol=lf
*.py text=auto eol=lf
*.toml text=auto eol=lf
*.yaml text=auto eol=lf
76 changes: 76 additions & 0 deletions python/cython/.github/CODE_OF_CONDUCT.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at {{ email }}. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
29 changes: 29 additions & 0 deletions python/cython/.github/ISSUE_TEMPLATE/bug_report.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug Report
about: Report a bug to help us improve
title: '[BUG] '
labels: 'type: bug'
assignees: ''
---

**Description**
A clear and concise description of the bug.

**Steps to Reproduce**
1.
2.
3.

**Expected Behavior**
What you expected to happen.

**Actual Behavior**
What actually happened. Include full error messages or tracebacks if available.

**Environment**
- OS: [e.g. Ubuntu 22.04, macOS 14.0, Windows 11]
- Python version: [e.g. 3.11.5] (`python --version`)
- Package version: (`pip show {{project_name_formatted}} | grep Version`)

**Additional Context**
Add any other relevant context, logs, or screenshots.
19 changes: 19 additions & 0 deletions python/cython/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Feature Request
about: Suggest a new feature or improvement
title: '[FEATURE] '
labels: 'type: enhancement'
assignees: ''
---

**Problem Statement**
A clear description of the problem this feature would solve. Ex. "I'm always frustrated when [...]"

**Proposed Solution**
A clear description of the desired behavior or feature.

**Alternatives Considered**
Any alternative solutions or workarounds you've considered.

**Additional Context**
Add any other context, mockups, or examples.
16 changes: 16 additions & 0 deletions python/cython/.github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Question
about: Ask a question about usage or behavior
title: '[QUESTION] '
labels: 'tag: question'
assignees: ''
---

**Question**
A clear and concise description of your question.

**Context**
What are you trying to accomplish? Include relevant code snippets, configuration, or links to documentation you've already consulted.

**Environment**
If relevant, include your environment details (OS, language versions, package version).
26 changes: 26 additions & 0 deletions python/cython/.github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"
labels:
- "part: github_actions"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
cooldown:
default-days: 7
groups:
python:
patterns:
- "*"
labels:
- "lang: python"
- "part: dependencies"
20 changes: 20 additions & 0 deletions python/cython/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Description

Brief description of the changes in this PR.

## Type of Change

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Refactor / code cleanup
- [ ] CI / build configuration
- [ ] Other (describe below)

## Checklist

- [ ] Linting passes (`make lint`)
- [ ] Tests pass (`make test`)
- [ ] New tests added for new functionality
- [ ] Documentation updated (if applicable)
- [ ] Changelog / version bump (if applicable)
65 changes: 65 additions & 0 deletions python/cython/.github/scripts/test-distributions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""Verify installed native wheels, including wheels rebuilt from each sdist."""

import json
import subprocess
import sys
import venv
from pathlib import Path
from tempfile import TemporaryDirectory
from zipfile import ZipFile

from packaging.tags import sys_tags
from packaging.utils import parse_wheel_filename


def test_wheel(wheel):
with ZipFile(wheel) as archive:
modules = []
for name in archive.namelist():
if name.endswith((".so", ".pyd")) and ".dist-info/" not in name:
modules.append(name.split(".", 1)[0].replace("/", "."))
if not modules:
raise RuntimeError(f"No compiled extensions in {wheel.name}")
with TemporaryDirectory() as directory:
env = Path(directory) / "venv"
venv.EnvBuilder(with_pip=True).create(env)
python = env / ("Scripts/python.exe" if sys.platform == "win32" else "bin/python")
subprocess.run([str(python), "-m", "pip", "install", str(wheel)], check=True, cwd=directory)
subprocess.run(
[
str(python),
"-I",
"-c",
(
"import importlib, importlib.machinery, json, sys; "
"modules = [importlib.import_module(name) for name in json.loads(sys.argv[1])]; "
"assert all(any(m.__file__.endswith(s) for s in importlib.machinery.EXTENSION_SUFFIXES) for m in modules)"
),
json.dumps(modules),
],
check=True,
cwd=directory,
)
print(f"Verified compiled imports from {wheel.name}", flush=True)


def main():
compatible_tags = set(sys_tags())
wheels = [wheel for wheel in Path("dist").glob("*.whl") if parse_wheel_filename(wheel.name)[3] & compatible_tags]
if not wheels:
raise RuntimeError("No compatible wheels in dist/")
for wheel in wheels:
test_wheel(wheel.resolve())
for sdist in Path("dist").glob("*.tar.gz"):
with TemporaryDirectory() as directory:
subprocess.run(
[sys.executable, "-m", "uv", "build", "--wheel", "--out-dir", directory, str(sdist.resolve())],
check=True,
cwd=directory,
)
for wheel in Path(directory).glob("*.whl"):
test_wheel(wheel)


if __name__ == "__main__":
main()
Loading
Loading