Skip to content

Commit

Permalink
0.9.10 - fine grained simd optios, abi3 wheels, workflow rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
K0lb3 committed Nov 14, 2024
1 parent 141cf47 commit e47586a
Show file tree
Hide file tree
Showing 13 changed files with 628 additions and 383 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# clone of: https://github.com/mitmproxy/pdoc/blob/main/.github/workflows/docs.yml
name: astc-encoder-py docs

# build the documentation whenever there are new commits on main
on:
push:
branches:
- main
# Alternative: only build for tags.
# tags:
# - '*'

# security: restrict permissions for CI jobs.
permissions:
contents: read

jobs:
# Build the documentation and upload the static HTML files as an artifact.
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install local package
run: pip install -e .

- name: Install pdoc
run: pip install pdoc pillow

# ADJUST THIS: build your documentation into docs/.
# We use a custom build script for pdoc itself, ideally you just run `pdoc -o docs/ ...` here.
- run: pdoc --docformat numpy -o docs/ ./astc_encoder

- uses: actions/upload-pages-artifact@v3
with:
path: docs/

# Deploy the artifact to GitHub pages.
# This is a separate job so that only actions/deploy-pages has the necessary permissions.
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
81 changes: 0 additions & 81 deletions .github/workflows/python-package.yml

This file was deleted.

135 changes: 135 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Build & Publish wheels
on:
workflow_dispatch


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

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

- name: Build sdist
run: pipx run build --sdist

- name: Install sdist
run: pip install dist/*.tar.gz

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
environment: release
strategy:
fail-fast: true
matrix:
os: [windows-latest, macos-latest]

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

- name: Build wheels
uses: joerick/[email protected]
env:
CIBW_TEST_SKIP: "*"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_wheels_ubuntu_manylinux:
name: Build x86 manylinux wheels on ubuntu-latest
runs-on: ubuntu-latest
environment: release

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

- name: Build wheels
uses: joerick/[email protected]
env:
CIBW_ENVIRONMENT_LINUX: CFLAGS="-D_mm256_cvtsi256_si32(x)=_mm256_extract_epi32((x),0)"
CIBW_SKIP: "*aarch64 *ppc64le *s390x *armv7l *-musllinux*"
CIBW_TEST_SKIP: "*"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_wheels_ubuntu_musllinux:
name: Build x86 musllinux wheels on ubuntu-latest
runs-on: ubuntu-latest
environment: release

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

- name: Build wheels
uses: joerick/[email protected]
env:
CIBW_SKIP: "*aarch64 *ppc64le *s390x *armv7l *-manylinux*"
CIBW_TEST_SKIP: "*"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_wheels_qemu:
name: Build wheels qemu on ubuntu-latest
runs-on: ubuntu-latest
environment: release

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
uses: joerick/[email protected]
env:
CIBW_SKIP: "*x86_64 *i686"
CIBW_TEST_SKIP: "*"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl


upload_pypi:
name: Publish to PyPI
needs: [build_wheels, build_wheels_qemu, build_wheels_ubuntu_manylinux, build_wheels_ubuntu_musllinux, build_sdist]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test
on:
push

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]

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

- name: Set up Python
uses: actions/setup-python@v5
if: matrix.os == 'ubuntu-latest'
with:
python-version: '3.x'

- name: Install
run: pip install .[tests]

- name: Run tests
run: pytest -vs ./tests
71 changes: 66 additions & 5 deletions etcpak/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
from ._cpufeatures import check_cpufeatures
from archspec.cpu import host

if check_cpufeatures():
from ._etcpak_simd import * # noqa: F403
else:
from ._etcpak import *
local_host = host()

__version__ = "0.9.10"

try:
# pypi wheels won't have these for now
if local_host.family.name == "aarch64":
# archspec doesn't detect the relevant features for arm
# so we assume neon is available,
# as it's unlikely for a device using the lib to not have it
from ._etcpak_neon import * # type: ignore
elif local_host.family.name == "x86_64":
if "avx512bw" in local_host.features and "avx512vl" in local_host.features:
from ._etcpak_avx512 import * # type: ignore
elif "avx2" in local_host.features:
from ._etcpak_avx2 import * # type: ignore
elif "sse4_1" in local_host.features:
from ._etcpak_sse41 import * # type: ignore
except ImportError:
pass

if "compress_bc1" not in locals():
from ._etcpak_none import * # type: ignore

# legacy mappings for backwards compatibility
compress_to_dxt1 = compress_bc1 # noqa: F405
Expand Down Expand Up @@ -32,3 +51,45 @@ def set_use_heuristics(use_heuristics: bool) -> None:

def get_use_multithreading() -> bool:
raise NotImplementedError("This function was removed in etcpak 0.9.9")


__all__ = (
"__version__",
"compress_bc1",
"compress_bc1_dither",
"compress_bc3",
"compress_bc5",
"compress_bc7",
"compress_etc1_rgb",
"compress_etc1_rgb_dither",
"compress_etc2_rgb",
"compress_etc2_rgba",
"compress_eac_r",
"compress_eac_rg",
"decompress_etc1_rgb",
"decompress_etc2_rgb",
"decompress_etc2_rgba",
"decompress_etc2_r11",
"decompress_etc2_rg11",
"decompress_bc1",
"decompress_bc3",
"decompress_bc4",
"decompress_bc5",
"decompress_bc7",
"BC7CompressBlockParams",
# legacy mappings for backwards compatibility
"compress_to_dxt1",
"compress_to_dxt1_dither",
"compress_to_dxt5",
"compress_to_etc1",
"compress_to_etc1_dither",
"compress_to_etc2",
"compress_to_etc2_rgba",
"decode_dxt1",
"decode_dxt5",
"decode_etc_rgba",
"compress_to_etc1_alpha",
"compress_to_etc2_alpha",
"set_use_heuristics",
"get_use_multithreading",
)
Loading

0 comments on commit e47586a

Please sign in to comment.