Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f07f0b3
updating submodule asmjit to latest version
Oct 12, 2024
39e2a32
updating blend2d submodule to latest
Oct 12, 2024
e955352
update to latest blend2d asmjit and cython compatibility
Oct 12, 2024
b0e9a6f
correction of rgba order in _get_rgba32_value
Oct 12, 2024
97e1fe3
Update the examples
Oct 12, 2024
4d2c516
remove dist folder
Oct 12, 2024
dbf9ff4
add dist/ to .gitignore
Oct 12, 2024
08adf26
compile blend2d in release mode in order to speed up graphics
Oct 12, 2024
2c71a32
take review into account
Oct 20, 2024
e36111e
pass ruff formatter
Oct 20, 2024
6d6aaee
Update submodules: asmjit to commit 4111cae and blend2d to commit c79…
perara Mar 23, 2025
1a2c21f
Enhance project structure and dependencies: Added nanobind submodule,…
perara Mar 24, 2025
76a52d4
Update project configuration for cross-compilation: Enhanced pyprojec…
perara Mar 24, 2025
36ea478
Refine GitHub Actions workflow for wheel building and publishing: Imp…
perara Mar 24, 2025
32b1746
Refactor GitHub Actions workflow: Removed unnecessary conditional log…
perara Mar 24, 2025
7852452
Enhance GitHub Actions workflow for building wheels: Introduced separ…
perara Mar 24, 2025
7a9d37f
Enhance setup.py for ARM64 support: Added specific compiler flags for…
perara Mar 24, 2025
d3d8e75
Refactor firing effect in ReticleRenderer: Updated pulse effect param…
perara Mar 24, 2025
195896a
Update pyproject.toml for improved build configuration: Changed manyl…
perara Mar 24, 2025
4a00cff
Add LICENSE and MANIFEST.in files; update pyproject.toml and setup.cf…
perara Nov 11, 2025
310a6e1
Enhance CMake configuration for Python integration: Added support for…
perara Nov 11, 2025
95ffea5
Enhance setup.py for macOS architecture detection: Added logic to det…
perara Nov 11, 2025
2b24f1d
Refactor CMakeLists.txt to allow nanobind and setup.py to manage outp…
perara Nov 11, 2025
119c362
Add FIXES_APPLIED.md to document critical issues resolved during mult…
perara Nov 11, 2025
43013ba
Update CMakeLists.txt to set output name for Python extension and imp…
perara Nov 11, 2025
fdef266
Revert src/CMakeLists.txt to fix Linux/macOS import errors
perara Nov 11, 2025
6e81fad
Disable macOS builds until import issue is resolved
perara Nov 11, 2025
5b1d83a
Update package name to blend2d-python in README and setup configuration
perara Nov 11, 2025
77d6b55
Merge pull request #1 from perara/main
Zybulon Jul 26, 2026
970cbb2
Remove support de python 3.8 and 3.9 to ensure the wheels compatibility
Zybulon Jul 26, 2026
7139827
update license classifier according to PEP 639
Zybulon Jul 26, 2026
3a2bee4
removing non recommended compilation options
Zybulon Jul 26, 2026
9c6cca5
Remove the "BL" prefix on the classes and enums
Zybulon Jul 26, 2026
01243d3
Add some useful interfaces for Python
Zybulon Jul 26, 2026
d344661
Make sure the example is working
Zybulon Jul 26, 2026
4360d02
update minimum python requirement
Zybulon Jul 26, 2026
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
51 changes: 51 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM ubuntu:24.04

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC

# Install basic dependencies
RUN apt-get update && apt-get install -y \
software-properties-common \
build-essential \
cmake \
git \
curl \
wget \
pkg-config \
python3 \
python3-pip \
python3-dev \
python3-setuptools \
python3-wheel \
python3-venv \
&& rm -rf /var/lib/apt/lists/*

# Create the vscode user
RUN apt-get update \
&& apt-get install -y sudo \
&& echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \
&& chmod 0440 /etc/sudoers.d/ubuntu \
&& rm -rf /var/lib/apt/lists/*

# Set up Blend2D dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
&& rm -rf /var/lib/apt/lists/*

# Create symbolic links for python -> python3
RUN ln -sf /usr/bin/python3 /usr/bin/python \
&& ln -sf /usr/bin/pip3 /usr/bin/pip

# Create venv
RUN python3 -m venv /opt/venv

# Activate venv
ENV PATH="/opt/venv/bin:$PATH"

# Make permissions for venv
RUN chown -R ubuntu:ubuntu /opt/venv




77 changes: 77 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Development Container for Blend2D Python

This directory contains configuration files for a development container that provides an isolated, consistent development environment for the Blend2D Python bindings project.

## Features

- Ubuntu 22.04 base image
- Multiple Python versions pre-installed:
- Python 3.10
- Python 3.11
- Python 3.12
- Common development tools:
- CMake
- Git
- Build essentials (compilers, etc.)
- VS Code extensions for Python and C++ development

## Using Different Python Versions

The container has all three Python versions available on the system. You can use them with the following commands:

```bash
# Default Python (3.12)
python --version

# Specific Python versions
python3.10 --version
python3.11 --version
python3.12 --version
```

## Installing Dependencies

The basic requirements for building the project (NumPy, Cython, and pytest) are automatically installed in the default Python environment during container creation.

To install them for a specific Python version:

```bash
python3.10 -m pip install numpy cython pytest
python3.11 -m pip install numpy cython pytest
python3.12 -m pip install numpy cython pytest
```

## Building with Different Python Versions

To build the project with a specific Python version:

```bash
# For Python 3.10
python3.10 setup.py build_ext --inplace

# For Python 3.11
python3.11 setup.py build_ext --inplace

# For Python 3.12
python3.12 setup.py build_ext --inplace
```

## Testing with Different Python Versions

```bash
# For Python 3.10
python3.10 -m pytest

# For Python 3.11
python3.11 -m pytest

# For Python 3.12
python3.12 -m pytest
```

## Starting the Container

If using VS Code:
1. Install the "Remote - Containers" extension
2. Open the command palette (F1 or Ctrl+Shift+P)
3. Select "Remote-Containers: Reopen in Container"
39 changes: 39 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Blend2D Python Development",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools-extension-pack"
],
"settings": {
"python.defaultInterpreterPath": "/usr/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Enabled": true,
"python.formatting.blackEnabled": true,
"python.formatting.yapfEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"editor.formatOnSave": true
}
}
},
"remoteUser": "ubuntu",
"features": {
"ghcr.io/devcontainers/features/git:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"moby": true,
"dockerDashComposeVersion": "v2"
}
}
}
142 changes: 142 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Build Wheels

on:
push:
branches: [ main ]
tags:
- 'v*' # Run on version tags for PyPI releases
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
publish_to:
description: 'Publish wheels to'
required: true
default: 'none'
type: choice
options:
- none
- test-pypi
- pypi

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Temporarily disabled macOS until import issue is resolved
# os: [ubuntu-latest, windows-latest, macos-13, macos-14]
os: [ubuntu-latest, windows-latest]
fail-fast: false

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

# Set up QEMU for ARM64 Linux builds
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel

# Build the wheels (using pyproject.toml configuration)
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
# macOS-specific: build for the native architecture only
CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || matrix.os == 'macos-14' && 'arm64' || 'auto' }}

# Upload artifacts
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

# Build source distribution
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

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

- name: Build sdist
run: python -m build --sdist

- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz

# Job to publish to PyPI
publish:
name: Publish to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# Add environment for Trusted Publishing
environment:
name: pypi
url: https://pypi.org/p/blend2d-python
# Required permissions for Trusted Publishing
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# Run based on conditions
if: >-
startsWith(github.ref, 'refs/tags/') ||
(github.event_name == 'workflow_dispatch' &&
(github.event.inputs.publish_to == 'test-pypi' || github.event.inputs.publish_to == 'pypi'))

steps:
# Download all wheel artifacts
- uses: actions/download-artifact@v4
with:
path: ./dist
merge-multiple: true

- name: List all files to be uploaded
run: |
ls -lah ./dist/

# Upload to TestPyPI
- name: Upload to TestPyPI
if: >-
github.event.inputs.publish_to == 'test-pypi' ||
(startsWith(github.ref, 'refs/tags/') && contains(github.ref, '-rc'))
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true

# Upload to PyPI using Trusted Publishing (no token needed!)
- name: Upload to PyPI
if: >-
github.event.inputs.publish_to == 'pypi' ||
(startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-rc'))
uses: pypa/gh-action-pypi-publish@release/v1
# No credentials needed - uses Trusted Publishing via OIDC
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ blend2d/*.so
src/*.c
*.py[cd]
*.png

dist
build/
cmake-build/
.history/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "3rdparty/asmjit"]
path = 3rdparty/asmjit
url = https://github.com/asmjit/asmjit.git
[submodule "nanobind"]
path = nanobind
url = https://github.com/wjakob/nanobind.git
[submodule "3rdparty/nanobind"]
path = 3rdparty/nanobind
url = https://github.com/wjakob/nanobind.git
2 changes: 1 addition & 1 deletion 3rdparty/asmjit
Submodule asmjit updated 221 files
2 changes: 1 addition & 1 deletion 3rdparty/blend2d
Submodule blend2d updated 520 files
1 change: 1 addition & 0 deletions 3rdparty/nanobind
Submodule nanobind added at a57010
40 changes: 28 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cmake_minimum_required( VERSION 3.1 )
cmake_minimum_required(VERSION 3.15)

project( blend2d_python C CXX )

# Blend2D
# -------
project(blend2d_python C CXX)

# C++17 is required for nanobind
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Blend2D setup
set(BLEND2D_DIR "${CMAKE_CURRENT_LIST_DIR}/3rdparty/blend2d"
CACHE PATH "Location of 'blend2d'")

Expand All @@ -17,13 +17,29 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(GNU|Clang|AppleClang)$")
list(APPEND BLEND2D_CFLAGS "-fvisibility=hidden")
endif()

# Blend2D Cython Extension
# ------------------------
# Nanobind setup
# Use nanobind from 3rdparty directory
set(NANOBIND_DIR "${CMAKE_CURRENT_LIST_DIR}/3rdparty/nanobind" CACHE PATH "Location of 'nanobind'")
add_subdirectory(${NANOBIND_DIR})

# Find Python and NumPy (needed for array support)
# Use the Python executable specified by setup.py (important for cross-compilation and cibuildwheel)
if(DEFINED PYTHON_EXECUTABLE)
# Set hints for FindPython to use the correct Python version
set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}" CACHE FILEPATH "Path to Python executable")
get_filename_component(Python_ROOT_DIR "${PYTHON_EXECUTABLE}" DIRECTORY)
get_filename_component(Python_ROOT_DIR "${Python_ROOT_DIR}" DIRECTORY)
set(Python_FIND_STRATEGY LOCATION)
set(Python_FIND_REGISTRY NEVER)
set(Python_FIND_FRAMEWORK NEVER)
endif()
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module NumPy)

set( BLEND2DPY_TARGET_NAME "_capi" CACHE STRING "Name of the extension file")
# Blend2D nanobind module
set(BLEND2DPY_TARGET_NAME "_capi" CACHE STRING "Name of the extension file")

set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake )
include( UseCython )
# Process the src subdirectory which contains our nanobind source files
add_subdirectory(src)

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/src )
add_subdirectory( src )
# Install the module
install(TARGETS ${BLEND2DPY_TARGET_NAME} DESTINATION blend2d)
Loading