Browse Source

upgrade release system (#107)

* upgrade release system

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .
master
Ofek Lev 2 years ago
committed by GitHub
parent
commit
454b80eca0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      .github/scripts/build-linux-wheels.sh
  2. 11
      .github/scripts/build-windows-wheels.sh
  3. 47
      .github/scripts/build.sh
  4. 8
      .github/scripts/install-linux-build-deps.sh
  5. 14
      .github/scripts/install-macos-build-deps.sh
  6. 21
      .github/scripts/install-system-deps.sh
  7. 9
      .github/scripts/install-test-deps.sh
  8. 9
      .github/scripts/prepare-windows-build.sh
  9. 149
      .github/workflows/build.yml
  10. 1
      coincurve/utils.py
  11. 17
      docs/install.md
  12. 2
      setup.py
  13. 3
      tox.ini

37
.github/scripts/build-linux-wheels.sh

@ -1,37 +0,0 @@
#!/bin/bash
set -e
set -x
# Install system packages required by our library
yum install -y pkgconfig libffi libffi-devel
# Use updated GMP
curl -O https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.bz2 && tar -xjpf gmp-*.tar.bz2 && cd gmp* && ./configure --build=${BUILD_GMP_CPU}-pc-linux-gnu > /dev/null && make > /dev/null && make check > /dev/null && make install > /dev/null && cd ..
mkdir out
python_version="$PYTHON_VERSION"
if [[ "$python_version" =~ "pypy" ]]; then
python_version="pp36-pypy36_pp73|pp37-pypy37_pp73"
else
python_version=${python_version/./}
python_version="cp$python_version"
fi
echo "Looking for Python version pattern: $python_version"
# Compile wheels
for PYBIN in /opt/python/*/bin; do
if [[ ${PYBIN} =~ $python_version ]]; then
${PYBIN}/pip wheel /io/ -w wheelhouse/
fi
done
# Adjust wheel tags
for whl in wheelhouse/coincurve*.whl; do
auditwheel repair "$whl" --plat $PLAT -w out
done
cp out/*.whl /io/dist

11
.github/scripts/build-windows-wheels.sh

@ -1,6 +1,5 @@
#!/bin/bash
set -e -x
set -ex
build_dll() {
./autogen.sh
@ -9,6 +8,14 @@ build_dll() {
make
}
sudo apt-get install -y mingw-w64
sudo apt-get -f install
mkdir .hidden
cp * .hidden -R
mv .hidden/coincurve/_windows_libsecp256k1.py .hidden/coincurve/_libsecp256k1.py
mv .hidden ../clean
cd ..
curl -sLO "https://github.com/bitcoin-core/secp256k1/archive/$COINCURVE_UPSTREAM_REF.tar.gz"

47
.github/scripts/build.sh

@ -1,47 +0,0 @@
#!/bin/bash
set -e
set -x
mkdir dist
if [[ "$OS_NAME" =~ "ubuntu-" ]]; then
if [[ "$PYTHON_VERSION" =~ "pypy" ]]; then
docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux2010_x86_64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io pypywheels/manylinux2010-pypy_x86_64 /io/.github/scripts/build-linux-wheels.sh
else
docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux2014_x86_64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 /io/.github/scripts/build-linux-wheels.sh
linux32 docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux2014_i686" -e BUILD_GMP_CPU="i686" -v $(pwd):/io quay.io/pypa/manylinux2014_i686 /io/.github/scripts/build-linux-wheels.sh
if [[ "$PYTHON_VERSION" == "$PYTHON_VERSION_BUILD_EXTRA" ]]; then
# Build the source distribution
python setup.py sdist
# Build the wheels for Windows
.github/scripts/build-windows-wheels.sh
fi
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux2014_aarch64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io quay.io/pypa/manylinux2014_aarch64 /io/.github/scripts/build-linux-wheels.sh
fi
else
# Make sure we can build and "fix" the wheel.
python -m pip install delocate wheel
# Create directories for the built and fixed wheels.
mkdir dist_wheels/ fixed_wheels/
# Build the wheel for the local OS.
python -m pip wheel . --wheel-dir dist_wheels/
# Make the wheel relocatable to another OS.
delocate-wheel \
--check-archs \
--wheel-dir fixed_wheels/ \
--verbose \
dist_wheels/coincurve*.whl
# Move the fixed wheel into dist/.
mv fixed_wheels/coincurve*.whl dist/
# Clean up build directories.
rm -fr dist_wheels/ fixed_wheels/
fi
ls -l dist
set +x +e

8
.github/scripts/install-linux-build-deps.sh

@ -0,0 +1,8 @@
#!/bin/sh
set -ex
# Find out what we're emulating
ARCH="$(python -c 'import platform;print(platform.machine())')"
# Use updated GMP
curl -O https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.bz2 && tar -xjpf gmp-*.tar.bz2 && cd gmp* && ./configure --build=${ARCH}-pc-linux-gnu > /dev/null && make > /dev/null && make check > /dev/null && make install > /dev/null && cd ..

14
.github/scripts/install-macos-build-deps.sh

@ -0,0 +1,14 @@
#!/bin/bash
set -ex
# update brew
brew update
# Update openssl if necessary
brew outdated openssl || brew upgrade openssl
# Install packages needed to build lib-secp256k1
for pkg in automake libtool pkg-config; do
brew list $pkg > /dev/null || brew install $pkg
brew outdated --quiet $pkg || brew upgrade $pkg
done

21
.github/scripts/install-system-deps.sh

@ -1,21 +0,0 @@
#!/bin/bash
set -e
set -x
if [[ "$OS_NAME" =~ "macos-" ]]; then
# update brew
brew update
# Update openssl if necessary
brew outdated openssl || brew upgrade openssl
# Install packages needed to build lib-secp256k1
for pkg in automake libtool pkg-config; do
brew list $pkg > /dev/null || brew install $pkg
brew outdated --quiet $pkg || brew upgrade $pkg
done
fi
set +x +e

9
.github/scripts/install-test-deps.sh

@ -0,0 +1,9 @@
#!/bin/bash
set -ex
if [ "$RUNNER_OS" == "macOS" ]; then
./.github/scripts/install-macos-build-deps.sh
fi
python -m pip install --upgrade cffi
python -m pip install --upgrade tox codecov

9
.github/scripts/prepare-windows-build.sh

@ -1,9 +0,0 @@
#!/bin/bash
mkdir .hidden
cp * .hidden -R
mkdir .hidden/dist
mv .hidden/coincurve/_windows_libsecp256k1.py .hidden/coincurve/_libsecp256k1.py
mv .hidden ../clean
sudo apt-get install -y mingw-w64
sudo apt-get -f install

149
.github/workflows/build.yml

@ -11,37 +11,40 @@ on:
branches:
- master
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
env:
PYTHON_VERSION_BUILD_EXTRA: '3.9'
COINCURVE_UPSTREAM_REF: f2d9aeae6d5a7c7fbbba8bbb38b1849b784beef7
LD_LIBRARY_PATH: ./libsecp256k1_ext/.libs
DYLD_FALLBACK_LIBRARY_PATH: ./libsecp256k1_ext/.libs
LIB_DIR: ./libsecp256k1_ext/.libs
INCLUDE_DIR: ./libsecp256k1_ext/include
CIBW_ENVIRONMENT_PASS_LINUX: >
COINCURVE_UPSTREAM_REF
CIBW_TEST_COMMAND: >
python -c
"from coincurve import PrivateKey;
a=PrivateKey();
b=PrivateKey();
assert a.ecdh(b.public_key.format())==b.ecdh(a.public_key.format())
"
CIBW_BEFORE_ALL_LINUX: ./.github/scripts/install-linux-build-deps.sh
CIBW_SKIP: >
pp*
jobs:
test:
name: "Test ${{ !startsWith(matrix.python-version, 'pypy') && 'Python ' || '' }}${{ startsWith(matrix.python-version, 'pypy') && 'PyPy' || matrix.python-version }} on ${{ startsWith(matrix.os, 'ubuntu-') && 'Ubuntu' || 'macOS' }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15]
python-version: ['3.6', '3.7', '3.8', '3.9']
include:
- os: ubuntu-18.04
python-version: pypy3
name: Test latest
runs-on: ubuntu-latest
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
PYTHON_VERSION: '3.10'
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}
- name: Upgrade Python packaging tools
run: pip install --upgrade pip setuptools wheel
@ -51,17 +54,10 @@ jobs:
python --version
pip --version
- name: Install system dependencies
run: ./.github/scripts/install-system-deps.sh
- name: Install build dependencies
run: python -m pip install --upgrade cffi
- name: Install test dependencies
run: python -m pip install --upgrade tox codecov
- name: Install dependencies
run: ./.github/scripts/install-test-deps.sh
- name: Check style and typing
if: startsWith(matrix.os, 'ubuntu-') && matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: tox -e lint,typing
- name: Run tests
@ -73,69 +69,88 @@ jobs:
- name: Upload coverage
run: codecov -X gcov
build:
name: "Build ${{ !startsWith(matrix.python-version, 'pypy') && 'Python ' || '' }}${{ startsWith(matrix.python-version, 'pypy') && 'PyPy' || matrix.python-version }} ${{ startsWith(matrix.os, 'ubuntu-') && 'manylinux' || 'on' }} ${{ startsWith(matrix.os, 'ubuntu-') && 'wheels' || 'macOS' }}"
runs-on: ${{ matrix.os }}
unix-wheels-standard:
name: Build ${{ startsWith(matrix.os, 'macos-') && 'macOS' || 'Linux' }} wheels
needs:
- test
- test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15]
python-version: ['3.6', '3.7', '3.8', '3.9']
include:
- os: ubuntu-18.04
python-version: pypy3
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
os: [ubuntu-20.04, macos-10.15]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build wheels
uses: pypa/cibuildwheel@v2.3.0
env:
CIBW_BEFORE_ALL_MACOS: ./.github/scripts/install-macos-build-deps.sh
CIBW_ARCHS_MACOS: x86_64 arm64
- name: Upgrade Python packaging tools
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: pip install --upgrade pip setuptools wheel
- uses: actions/upload-artifact@v2
with:
name: artifacts
path: wheelhouse/*.whl
if-no-files-found: error
- name: Show runner information
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: |
python --version
pip --version
windows-wheels-and-sdist:
name: Build Windows wheels and source distribution
needs:
- test
runs-on: ubuntu-latest
- name: Install system dependencies
run: ./.github/scripts/install-system-deps.sh
steps:
- uses: actions/checkout@v2
- name: Install build dependencies
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: python -m pip install --upgrade cffi
- name: Prepare for cross-platform Windows build
if: startsWith(matrix.os, 'ubuntu-') && matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: ./.github/scripts/prepare-windows-build.sh
- name: Build source distribution
run: python setup.py sdist
- name: Build package
run: ./.github/scripts/build.sh
- name: Build Windows wheels
run: ./.github/scripts/build-windows-wheels.sh
- uses: actions/upload-artifact@v2
if: always()
with:
name: artifacts
path: dist/*
if-no-files-found: error
unix-wheels-arm:
name: Build Linux wheels for ARM
needs:
- test
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/master'
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.0
env:
CIBW_ARCHS_LINUX: aarch64
- uses: actions/upload-artifact@v2
with:
name: artifacts
path: wheelhouse/*.whl
if-no-files-found: error
publish:
name: Publish release
runs-on: ubuntu-latest
needs:
- build
# Only publish tags
- unix-wheels-standard
- windows-wheels-and-sdist
- unix-wheels-arm
runs-on: ubuntu-latest
if: github.event_name == 'create' && github.event.ref_type == 'tag'
steps:
@ -145,7 +160,7 @@ jobs:
path: dist
- name: Push build artifacts to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.1
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
skip_existing: true
user: __token__

1
coincurve/utils.py

@ -25,7 +25,6 @@ if environ.get('COINCURVE_BUILDING_DOCS') != 'true':
def sha256(bytestr: bytes) -> bytes:
return _sha256(bytestr).digest()
else: # no cov
class __Nonce(tuple):

17
docs/install.md

@ -12,15 +12,14 @@ pip install coincurve
Binary wheels are available for most platforms and require at least version `19.3` of pip to install.
| | | | | | | |
| --- | --- | --- | --- | --- | --- | --- |
| | 3.6 | 3.7 | 3.8 | 3.9 | PyPy3.6 7.3.3 | PyPy3.7 7.3.3 |
| Linux (x86_64) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Linux (AArch64) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Linux (x86) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Windows (x86_64) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | |
| Windows (x86) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | |
| macOS (x86_64) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | |
| | | | | |
| --- | --- | --- | --- | --- |
| | macOS | Windows | Linux (glibc) | Linux (musl) |
| CPython 3.6 | <ul><li>x86_64</li></ul> | <ul><li>x86_64</li><li>x86</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> |
| CPython 3.7 | <ul><li>x86_64</li></ul> | <ul><li>x86_64</li><li>x86</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> |
| CPython 3.8 | <ul><li>x86_64</li><li>Apple Silicon</li></ul> | <ul><li>x86_64</li><li>x86</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> |
| CPython 3.9 | <ul><li>x86_64</li><li>Apple Silicon</li></ul> | <ul><li>x86_64</li><li>x86</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> |
| CPython 3.10 | <ul><li>x86_64</li><li>Apple Silicon</li></ul> | <ul><li>x86_64</li><li>x86</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> | <ul><li>x86_64</li><li>i686</li><li>AArch64</li></ul> |
## Source

2
setup.py

@ -32,6 +32,8 @@ BUILDING_FOR_WINDOWS = detect_dll()
MAKE = 'gmake' if platform.system() in ['FreeBSD', 'OpenBSD'] else 'make'
# IMPORTANT: keep in sync with .github/workflows/build.yml
#
# Version of libsecp256k1 to download if none exists in the `libsecp256k1` directory
UPSTREAM_REF = os.getenv('COINCURVE_UPSTREAM_REF') or 'f2d9aeae6d5a7c7fbbba8bbb38b1849b784beef7'

3
tox.ini

@ -5,6 +5,7 @@ envlist =
3.7
3.8
3.9
3.10
pypy3
bench
lint
@ -38,7 +39,7 @@ deps =
flake8>=3.8.2
flake8-bugbear>=20.1.4
flake8-quotes>=3.2.0
black>=19.10b0
black>=21.12b0
isort[pyproject]>=5
commands =
flake8 .

Loading…
Cancel
Save