Skip to content

Commit

Permalink
Merge pull request PyO3#1 from mbway/main
Browse files Browse the repository at this point in the history
Initial Version
  • Loading branch information
messense authored Mar 4, 2024
2 parents c268973 + 8a6b707 commit b6435ba
Show file tree
Hide file tree
Showing 88 changed files with 11,803 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[codespell]
ignore-words-list = crate
45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 🐛 Bug Report
description: Create a bug report
labels: [bug]
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to fill out this bug report!
Please fill out the form below...
- type: textarea
id: description
attributes:
label: Bug Description
placeholder: The bug is...
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to Reproduce
description: Please list the exact steps required to reproduce your error. Try to narrow down to the smallest example that still triggers the issue. Enable debug logging (see [README](https://github.com/PyO3/maturin-import-hook/blob/main/README.md)) and share the output, either in a codeblock or as a [gist](https://gist.github.com/)
placeholder: |
1.
2.
3.
validations:
required: true
- type: textarea
id: versions
attributes:
label: Please provide the output of `python -m maturin_import_hook version` (or provide manually)
placeholder: |
OS: Linux-6.6.18-1-lts-x86_64-with-glibc2.39
Python: CPython 3.11.7
maturin-import-hook: 0.1.0
maturin: maturin 1.4.0
rustc: rustc 1.76.0 (07dca489a 2024-02-04)
pip: 23.3.2
- type: checkboxes
id: buildable
attributes:
label: Does `maturin develop` work when run manually for your project?
options:
- label: Yes/No (leave blank if not applicable)
required: false
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: ❓ Question
url: https://github.com/PyO3/maturin-import-hook/discussions
about: Ask and answer questions about maturin-import-hook on Discussions
- name: 🔧 Troubleshooting
url: https://github.com/PyO3/maturin-import-hook/discussions
about: For troubleshooting help, see the Discussions
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: 💡 Feature request
about: Suggest an idea for this project
labels: [enhancement]
---

<!--
Thank you for sharing your idea!
Please describe your idea in depth. If you're not sure what to write, imagine the following:
- How is this important to you? How would you use it?
- Can you think of any alternatives?
- Do you have any ideas about how it can be implemented? Are you willing/able to implement it? Do you need mentoring?
-->
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint

on:
workflow_dispatch:
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: pre-commit/action@v3.0.1
185 changes: 185 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Test

on:
workflow_dispatch:
inputs:
os:
type: choice
description: OS to test with
default: 'ubuntu-latest'
options:
- all
- ubuntu-latest
- macos-13 # TODO(matt): switch to 14 once this is fixed: https://github.com/actions/setup-python/issues/825
- windows-latest
python_version:
type: choice
description: Python version to test with
default: '3.11'
options:
- 'all'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- 'pypy3.9'
- 'pypy3.10'
test_specification:
type: string
description: Specification for the tests to run
default: 'tests/test_import_hook/'
fail_fast:
type: boolean
default: true
description: Fail fast
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
generate-matrix:
name: Generate Matrix
runs-on: ubuntu-latest
outputs:
os: ${{ steps.generate-matrix.outputs.os }}
python-version: ${{ steps.generate-matrix.outputs.python-version }}
fail-fast: ${{ steps.generate-matrix.outputs.fail-fast }}
steps:
- uses: actions/setup-node@v4
with:
node-version: 16
- run: npm install js-yaml
- name: Generate matrix
id: generate-matrix
uses: actions/github-script@v7
with:
script: |
const yaml = require('js-yaml')
const OS = yaml.load(process.env.OS_MATRIX)
const PYTHON_VERSIONS = yaml.load(process.env.PYTHON_VERSION)
if (context.eventName == 'workflow_dispatch') {
const input_os = "${{ github.event.inputs.os }}";
const input_python_version = "${{ github.event.inputs.python_version }}";
core.setOutput('os', input_os == "all" ? OS : [input_os]);
core.setOutput('python-version', input_python_version == "all" ? PYTHON_VERSIONS : [input_python_version]);
core.setOutput('fail-fast', "${{ github.event.inputs.fail_fast }}");
} else if (context.eventName == 'merge_group') {
core.setOutput('os', OS)
core.setOutput('python-version', PYTHON_VERSIONS)
core.setOutput('fail-fast', 'false')
} else if (context.eventName == 'pull_request') {
const { data: { labels: labels } } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
})
const labelNames = labels.map(label => label.name)
if (labelNames.includes('CI-no-fail-fast')) {
core.setOutput('fail-fast', 'false')
}
// Only run latest CPython and PyPy tests on pull requests
const firstPyPy = PYTHON_VERSIONS.findIndex(version => version.startsWith('pypy'))
const pythonVersions = [PYTHON_VERSIONS[firstPyPy - 1], PYTHON_VERSIONS[PYTHON_VERSIONS.length - 1]]
core.setOutput('python-version', pythonVersions)
}
env:
OS_MATRIX: |
- ubuntu-latest
- macos-13
- windows-latest
PYTHON_VERSION: |
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- 'pypy3.9'
- 'pypy3.10'
test:
name: Test
needs: [generate-matrix]
strategy:
fail-fast: ${{ needs.generate-matrix.outputs.fail-fast != 'false' }}
matrix:
os: ${{ fromJson(needs.generate-matrix.outputs.os) }}
python-version: ${{ fromJson(needs.generate-matrix.outputs.python-version) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
cache: "pip"
- uses: dtolnay/rust-toolchain@stable
id: rustup
- name: Install aarch64-apple-darwin Rust target
if: startsWith(matrix.os, 'macos')
run: rustup target add aarch64-apple-darwin
- name: Setup Xcode env
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
set -ex
sudo xcode-select -s /Applications/Xcode.app
bindir="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin"
echo "CC=${bindir}/clang" >> "${GITHUB_ENV}"
echo "CXX=${bindir}/clang++" >> "${GITHUB_ENV}"
echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> "${GITHUB_ENV}"
# To save disk space
- name: Disable debuginfo on Windows
if: startsWith(matrix.os, 'windows')
run: echo "RUSTFLAGS="-C debuginfo=0"" >> $GITHUB_ENV
- name: Install test requirements
run: cd tests && pip install --disable-pip-version-check -r requirements.txt
- name: Run tests
shell: bash
run: |
EXTRA_ARGS=""
if [ "${{ needs.generate-matrix.outputs.fail-fast }}" != "false" ]; then
EXTRA_ARGS="$EXTRA_ARGS --max-failures 4"
fi
python tests/runner.py \
--workspace ./test_workspace \
--name "${{ matrix.os }}_${{ matrix.python-version }}" \
${EXTRA_ARGS} \
"${{ github.event.inputs.test_specification || 'tests/test_import_hook' }}"
- name: Upload HTML test report
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.os }}-${{ matrix.python-version }}-test-report.html
path: './test_workspace/report.html'
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: './test_workspace/reports/*.xml'
test_files_prefix: "${{ matrix.os }}_${{ matrix.python-version }}"


conclusion:
needs:
- test
if: always()
runs-on: ubuntu-latest
steps:
- name: Result
run: |
jq -C <<< "${needs}"
# Check if all needs were successful or skipped.
"$(jq -r 'all(.result as $result | (["success", "skipped"] | contains([$result])))' <<< "${needs}")"
env:
needs: ${{ toJson(needs) }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*.whl

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/maturin"]
path = tests/maturin
url = https://github.com/PyO3/maturin.git
19 changes: 19 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
default: true

MD003:
style: atx
MD004:
style: dash
MD007:
indent: 4
MD013:
line_length: 120
code_block_line_length: 120
MD046:
style: fenced
MD048:
style: backtick
MD049:
style: asterisk
MD050:
style: asterisk
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff-format
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
# note: mypy runs in an isolated environment and so has no access to third party packages
- id: mypy
entry: mypy src/maturin_import_hook/ tests/test_import_hook tests/runner.py
pass_filenames: false
additional_dependencies: ["pytest"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint-fix
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [Unreleased]
Loading

0 comments on commit b6435ba

Please sign in to comment.