Skip to content

Commit

Permalink
Merge pull request #75 from AT0myks/cibuildwheel
Browse files Browse the repository at this point in the history
Integrate cibuildwheel
  • Loading branch information
jd-boyd authored Jun 6, 2023
2 parents dc6a0f3 + 936b260 commit 0eafa0a
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 164 deletions.
192 changes: 192 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: Build and test wheels

on:
workflow_dispatch:
push:
tags:
- v*

jobs:
wheels:
name: Build wheels on ${{ matrix.os }} for ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
arch: ["x86_64", "arm64"]
include:
- os: windows-2019
arch: win_amd64
- os: windows-2019
arch: win32
- os: ubuntu-20.04
arch: i686
- os: ubuntu-20.04
arch: aarch64
- os: ubuntu-20.04
arch: ppc64le
- os: ubuntu-20.04
arch: s390x
exclude:
- os: windows-2019
arch: "x86_64"
- os: ubuntu-20.04
arch: "arm64"
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build and test wheels
uses: pypa/cibuildwheel@v2.12.3
env:
CIBW_BUILD: "*${{ matrix.arch }}"
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-${{ matrix.arch }}
path: wheelhouse/*.whl
if-no-files-found: error

wheels-old:
name: Build old wheels on ${{ matrix.os }} for ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
arch: ["x86_64"]
include:
- os: windows-2019
arch: win_amd64
- os: windows-2019
arch: win32
- os: ubuntu-20.04
arch: i686
- os: ubuntu-20.04
arch: aarch64
- os: ubuntu-20.04
arch: ppc64le
- os: ubuntu-20.04
arch: s390x
exclude:
- os: windows-2019
arch: "x86_64"
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build and test wheels
uses: pypa/cibuildwheel@v1.12.0
env:
CIBW_ARCHS: all
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: "*${{ matrix.arch }}"
CIBW_SKIP: cp36-* cp37-* cp38-* cp39-* pp37-* pp*-macosx* cp35-macosx_x86_64
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {package}/tests
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-${{ matrix.arch }}
path: wheelhouse/*.whl
if-no-files-found: error

wheels-win27:
name: Build Python 2.7 wheels on Windows ${{ matrix.arch }}
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
arch: ["amd64", "win32"]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Prepare compiler environment for Windows
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Set Windows environment variables
if: runner.os == 'Windows'
shell: bash
run: |
echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV
echo "MSSdk=1" >> $GITHUB_ENV
- name: Build and test wheels
uses: pypa/cibuildwheel@v1.12.0
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: "*27*${{ matrix.arch }}"
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {package}/tests
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-${{ matrix.arch }}
path: wheelhouse/*.whl
if-no-files-found: error

sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
# Build sdist on lowest supported Python.
# 3.8 is used because 3.6 has issues with pyproject.toml
# and 3.7 has bpo-41316.
python-version: '3.8'
- name: Build sdist
run: |
python -m pip install -U pip
python -m pip install -U build
python -m build -s
- name: Test sdist
run : python -m pip install dist/*.gz
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/*
if-no-files-found: error

publish:
name: Publish builds on PyPI
runs-on: ubuntu-latest
needs: [sdist, wheels, wheels-old, wheels-win27]
if: ${{ always() && (needs.sdist.result == 'success' || needs.wheels.result == 'success' || needs.wheels-old.result == 'success' || needs.wheels-win27.result == 'success') }}
environment:
name: release
url: https://test.pypi.org/p/python-lzo
permissions:
id-token: write
steps:
- name: Download builds
uses: actions/download-artifact@v3
with:
path: dist
- name: Organise
working-directory: dist
run: |
mv **/*.whl .
mv **/*.gz .
find . -type d -delete
- name: Display structure of downloaded files
run: ls -R
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
repository-url: https://test.pypi.org/legacy/
6 changes: 1 addition & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
# written by Markus F. X. J. Oberhumer <markus@oberhumer.com>
#
include COPYING
include README
include INSTALL
include MANIFEST.in
include Makefile
include NEWS
include lzomodule.c
include setup.py
include tests/*.py
graft lzo-2.10
19 changes: 0 additions & 19 deletions PKG-INFO

This file was deleted.

85 changes: 35 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
![example workflow](https://github.com/jd-boyd/python-lzo/actions/workflows/tests.yaml/badge.svg)

[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/jd-boyd/python-lzo?svg=true)](https://ci.appveyor.com/project/jd-boyd/python-lzo/branch/master)
[![Build and tests](https://github.com/jd-boyd/python-lzo/actions/workflows/wheels.yml/badge.svg)](https://github.com/jd-boyd/python-lzo/actions/workflows/wheels.yml)

```
Python-LZO -- Python bindings for LZO
Expand Down Expand Up @@ -34,70 +32,57 @@ Python strings.

# Installation

## Ubuntu/Debian Linux

You need the following dependencies installed:
* `zlib1g-dev`
* `liblzo2-dev`
* `python-pip` or `python3-pip`

Then, just `pip install python-lzo`.

## CentOS/Red Hat Enterprise Linux

You need the following dependencies installed:

* `yum install epel-release`
* `yum install python-pip`
* `yum install lzo-devel`
* `yum install lzo-minilzo`

Then, just `pip install python-lzo`.

## macOS

You need XCode installed, or something else that provides suitable C
compiler. Then just:

`pip install python-lzo`
```
pip install python-lzo
```
Or explicitly from source,
either from a specific release or from the repo (requires build tools):
```
pip install python-lzo-x.y.tar.gz
pip install https://[...]/python-lzo-x.y.tar.gz
pip install git+https://github.com/jd-boyd/python-lzo
```

## Windows
# Building from source

There is an issue filed to provide a pre-compiled wheel to greatly
simplify this.
Building from source requires build tools. On most Linux distributions
they are probably already installed. On Windows you need
[Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
(which should already be installed if you have Visual Studio).
On macOS you need XCode installed, or something else that provides a suitable C
compiler. Then either `git clone`, or download a source distribution and untar it.
Once you are in the root of the project directory where `pyproject.toml` is located,
run `python -m build -w`. This should build a wheel in the `dist` directory.
You might need to install `build` with `pip install build`.

Until then, here we go:
* Download http://www.oberhumer.com/opensource/lzo/download/lzo-2.09.tar.gz
* extract that file to `c:\src\` (should produce `c:\src\lzo-2.09` )
* Install a visual studio compatible with your python build. If you are using
python 2.7, MS has a package just for you at: https://www.microsoft.com/en-us/download/details.aspx?id=44266
Current automated tests are done with Visual Studio 2013, but newer should work as well.
* `python.exe setup.py install`
If you really want to build a wheel for Python 2.7 on Windows you'll need the
[Microsoft Visual C++ Compiler for Python 2.7](https://web.archive.org/web/20210116063838/https://www.microsoft.com/en-us/download/details.aspx?id=44266).

# Where's the documentation ?

Python-LZO comes with built-in documentation which is accessible
using `lzo.__doc__` and `lzo.func__doc__`. See ["Chapter 3: Data Model"
in the Python Reference Manual](https://docs.python.org/3.6/reference/datamodel.html) for more information.

Python-LZO comes with built-in documentation which is accessible using
```py
>>> import lzo
>>> help(lzo)
```
Additionally you should read the docs and study the example
programs that ship with the LZO library.

# Python 2 support statement

As of 1.15, Python 2.x is unsupported. To continue using Python 2.6 or
Python 2.7, please stick with version 1.14.
Python 2.7 is still supported but without being a priority.
Support will be dropped soon.

# Notes

The Windows version is tested.

It is not currently continuously tested on OSX, but that is coming.
Wheels are built with [cibuildwheel](https://cibuildwheel.readthedocs.io/)
on GitHub Actions. Tests are run for all combinations of platform and
Python version that it can run tests for.

# Releasing

1. Update version in `setup.py` and the `MODULE_VERSION` define in
`lzomodule.c`.
1. Update version in `pyproject.toml`, `setup.py` and the `MODULE_VERSION`
define in `lzomodule.c`.
1. Update NEWS.
1. Tag with new release.
1. wheels (download from github actions)
Expand Down
8 changes: 8 additions & 0 deletions lzomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ compress(PyObject *dummy, PyObject *args, PyObject *kwds)

/* init */
UNUSED(dummy);
#if PY_VERSION_HEX >= 0x03030000
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii$s", argnames, &in, &len, &level, &header, &algorithm))
#else
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|iis", argnames, &in, &len, &level, &header, &algorithm))
#endif
return NULL;
if (len < 0)
return NULL;
Expand Down Expand Up @@ -309,7 +313,11 @@ decompress(PyObject *dummy, PyObject *args, PyObject *kwds)

/* init */
UNUSED(dummy);
#if PY_VERSION_HEX >= 0x03030000
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii$s", argnames, &in, &len, &header, &buflen, &algorithm))
#else
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|iis", argnames, &in, &len, &header, &buflen, &algorithm))
#endif
return NULL;
if (header) {
if (len < 5 + 3 || in[0] < 0xf0 || in[0] > 0xf1)
Expand Down
Loading

0 comments on commit 0eafa0a

Please sign in to comment.