Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile code with Mypyc #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ tag = True
tag_name = {new_version}
current_version = 1.0.0

[bumpversion:file:pyproject.toml]
search = version = "{current_version}" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
replace = version = "{new_version}" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT

[bumpversion:file:src/tomli_w/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"
107 changes: 91 additions & 16 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
pull_request:
branches: [ master ]

env:
CIBW_BEFORE_TEST: pip install -r tests/requirements.txt
CIBW_TEST_COMMAND: pytest
CIBW_SKIP: pp*
# Pass through to container
CIBW_ENVIRONMENT_PASS_LINUX: HATCH_BUILD_HOOKS_ENABLE

jobs:

linters:
Expand Down Expand Up @@ -56,11 +63,85 @@ jobs:
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
uses: codecov/codecov-action@v2

binary-wheels-standard:
name: Binary wheels for ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2

- name: Build wheels
uses: pypa/cibuildwheel@v2.3.1
env:
CIBW_ARCHS_MACOS: x86_64
HATCH_BUILD_HOOKS_ENABLE: 'true'

- uses: actions/upload-artifact@v2
with:
name: artifacts
path: wheelhouse/*.whl
if-no-files-found: error

pure-python-wheel-and-sdist:
name: Build a pure Python wheel and source distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install build dependencies
run: python -m pip install --upgrade build

- name: Build
run: python -m build

- uses: actions/upload-artifact@v2
with:
name: artifacts
path: dist/*
if-no-files-found: error

binary-wheels-arm:
name: Build Linux wheels for ARM
runs-on: ubuntu-latest
# Very slow, no need to run on PRs
if: >
github.event_name == 'push'
&&
(github.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/tags'))

steps:
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: arm64

- name: Build wheels
uses: pypa/cibuildwheel@v2.3.1
env:
CIBW_ARCHS_LINUX: aarch64
HATCH_BUILD_HOOKS_ENABLE: 'true'

- uses: actions/upload-artifact@v2
with:
name: artifacts
path: wheelhouse/*.whl
if-no-files-found: error

allgood:
runs-on: ubuntu-latest
needs:
- tests
- linters
- binary-wheels-standard
- pure-python-wheel-and-sdist
- binary-wheels-arm
steps:
- run: echo "Great success!"

Expand All @@ -70,20 +151,14 @@ jobs:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/download-artifact@v2
with:
python-version: '3.7'
- name: Install build and publish tools
run: |
pip install build twine
- name: Build and check
run: |
rm -rf dist/ && python -m build
twine check --strict dist/*
- name: Publish
run: |
twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
name: artifacts
path: dist

- name: Push build artifacts to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
skip_existing: true
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
25 changes: 21 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[build-system]
requires = ["flit_core>=3.2.0,<4"]
build-backend = "flit_core.buildapi"
requires = ["hatchling~=0.8"]
build-backend = "hatchling.build"

[project]
name = "tomli_w"
version = "1.0.0" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
description = "A lil' TOML writer"
authors = [
{ name = "Taneli Hukkinen", email = "hukkin@users.noreply.github.com" },
]
license = { file = "LICENSE" }
license = "MIT"
requires-python = ">=3.7"
readme = "README.md"
classifiers = [
Expand All @@ -28,12 +27,30 @@ classifiers = [
"Typing :: Typed",
]
keywords = ["toml", "tomli"]
dynamic = ["version"]

[project.urls]
"Homepage" = "https://github.com/hukkin/tomli-w"
"Changelog" = "https://github.com/hukkin/tomli-w/blob/master/CHANGELOG.md"


[tool.hatch.version]
path = "src/tomli_w/__init__.py"

[tool.hatch.build.targets.sdist]
include = ["/src"]

[tool.hatch.build.targets.wheel]
packages = ["/src/tomli_w"]
zip-safe = false

[tool.hatch.build.targets.wheel.hooks.mypyc]
enable-by-default = false
dependencies = ["hatch-mypyc>=0.5"]
# Seems to be slightly faster in benchmark
options = { separate = true }


[tool.isort]
# Force imports to be sorted by module, independent of import type
force_sort_within_sections = true
Expand Down