Skip to content

Commit

Permalink
Merge pull request #90 from djhoese/bugfix-py312-compat
Browse files Browse the repository at this point in the history
Fix Python 3.12 compatibility
  • Loading branch information
djhoese committed Oct 11, 2023
2 parents 21742be + 0e28927 commit 0c5124c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 32 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
66 changes: 40 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,17 @@ name: CI
on: [push, pull_request]

jobs:
build:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
BUILDMODE: [CIBUILDWHEEL, UNITTEST]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2

- name: Set up QEMU
if: ${{ matrix.os == 'ubuntu-latest' && matrix.BUILDMODE == 'CIBUILDWHEEL' }}
id: qemu
uses: docker/setup-qemu-action@v1
- uses: actions/checkout@v4

- name: Setup Conda Environment
if: ${{ matrix.BUILDMODE == 'UNITTEST' }}
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
Expand All @@ -32,54 +24,76 @@ jobs:
activate-environment: test-environment

- name: Run tests
if: ${{ matrix.BUILDMODE == 'UNITTEST' }}
shell: bash -l {0}
run: |
pip install -e .
python selftest.py
- name: Build wheel
if: ${{ matrix.BUILDMODE == 'CIBUILDWHEEL' }}
build:
name: "Build wheels on ${{ matrix.os }} ${{ matrix.cibw_archs }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
cibw_archs: "AMD64 ARM64"
- os: macos-11
cibw_archs: "x86_64 arm64"
- os: "ubuntu-20.04"
cibw_archs: "aarch64"
- os: "ubuntu-20.04"
cibw_archs: "x86_64"

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_TEST_COMMAND: python {project}/selftest.py
CIBW_BEFORE_BUILD_LINUX: yum install -y freetype-devel
CIBW_SKIP: "cp36-* pp* *-win32 *-manylinux_i686 *-musllinux*"
CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *-win32 *-manylinux_i686 *-musllinux*"
CIBW_TEST_REQUIRES: numpy pillow pytest
CIBW_ARCHS_LINUX: auto aarch64
CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64"
CIBW_ARCHS: "${{ matrix.cibw_archs }}"
# disable finding unintended freetype installations
CIBW_ENVIRONMENT_WINDOWS: "AGGDRAW_FREETYPE_ROOT=''"
run: |
python -m pip install cibuildwheel
cibuildwheel --output-dir wheelhouse
- name: upload
if: ${{ matrix.BUILDMODE == 'CIBUILDWHEEL' }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: wheelhouse
path: "wheelhouse/*.whl"
path: "./wheelhouse/*.whl"

publish:
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4

- name: sdist
run: |
python -m pip install -U build pip
python -m build -s
- name: download
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: wheelhouse
path: dist

- name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@v1.4.1
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.pypi_password }}
8 changes: 4 additions & 4 deletions aggdraw.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ text_getchar(PyObject* string, int index, unsigned long* char_out)
{
#if defined(HAVE_UNICODE)
if (PyUnicode_Check(string)) {
Py_UNICODE* p = PyUnicode_AS_UNICODE(string);
int size = PyUnicode_GET_SIZE(string);
if (index >= size)
Py_ssize_t str_len = PyUnicode_GetLength(string);
if (index >= str_len)
return 0;
*char_out = p[index];
Py_UCS4 this_char = PyUnicode_READ_CHAR(string, index);
*char_out = this_char;
return 1;
}
#endif
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def _get_freetype_with_pkgconfig():
download_url="http://www.effbot.org/downloads#aggdraw",
license="Python (MIT style)",
long_description=DESCRIPTION.strip(),
platforms="Python 2.7 and later.",
url="https://github.com/pytroll/aggdraw",
ext_modules=[
Extension("aggdraw", ["aggdraw.cxx"] + sources,
Expand All @@ -169,6 +168,6 @@ def _get_freetype_with_pkgconfig():
library_dirs=library_dirs, libraries=libraries
)
],
python_requires='>=3.7',
python_requires='>=3.9',
tests_require=['pillow', 'pytest'],
)

0 comments on commit 0c5124c

Please sign in to comment.