Skip to content

Commit

Permalink
Publish pre-built wheels to PyPI (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Jan 10, 2023
1 parent beba01f commit 3d02b52
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 64 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: build-wheels

on:
push:
branches:
- wheel
tags:
- '*'

concurrency:
group: build-wheels-${{ github.ref }}
cancel-in-progress: true

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

steps:
- uses: actions/checkout@v2

# see https://cibuildwheel.readthedocs.io/en/stable/changelog/
# for a list of versions
- name: Build wheels
uses: pypa/cibuildwheel@v2.11.4
env:
CIBW_SKIP: "cp27-* cp35-* *-win32 pp* *-musllinux*"
CIBW_BUILD_VERBOSITY: 3

- name: Display wheels
shell: bash
run: |
ls -lh ./wheelhouse/
ls -lh ./wheelhouse/*.whl
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

- name: Publish wheels to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 -m pip install --upgrade pip
python3 -m pip install wheel twine setuptools
twine upload ./wheelhouse/*.whl
3 changes: 2 additions & 1 deletion .github/workflows/build_conda_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-10.15]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
# refer to https://github.com/actions/checkout
Expand All @@ -30,6 +30,7 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
activate-environment: lilcom

- name: Display Python version
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_conda_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-18.04]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
# refer to https://github.com/actions/checkout
Expand All @@ -30,6 +30,7 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
activate-environment: lilcom

- name: Display Python version
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_conda_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-2019]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
# refer to https://github.com/actions/checkout
Expand All @@ -30,6 +30,7 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
activate-environment: lilcom

- name: Display Python version
Expand Down
54 changes: 0 additions & 54 deletions .github/workflows/publish_to_pypi.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/test-pip-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: test-pip-install

on:
push:
branches:
- nightly
schedule:
# minute (0-59)
# hour (0-23)
# day of the month (1-31)
# month (1-12)
# day of the week (0-6)
# nightly test at 22:50 UTC time every day
- cron: "50 22 * * *"

concurrency:
group: test_pip_install-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test_pip_install:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install lilcom
shell: bash
run: |
pip3 install --verbose lilcom
- name: Run test
shell: bash
run: |
rm -rfv lilcom
python3 -c "import lilcom; print(lilcom.__file__)"
python3 -c "import lilcom_extension; print(lilcom_extension.__file__)"
python3 ./test/test_lilcom.py
python3 ./test/test_speed.py
python3 ./test/test_header.py
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(lilcom)

# Remember to also change the line 3 of ./scripts/conda/lilcom/meta.yaml
set(LILCOM_VERSION "1.5.1")
set(LILCOM_VERSION "1.6")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
Expand Down Expand Up @@ -61,12 +61,8 @@ pybind11_add_module(lilcom_extension
)

if(UNIX AND NOT APPLE)
target_link_libraries(lilcom_extension PRIVATE ${PYTHON_LIBRARY})

# Fix https://github.com/lhotse-speech/lhotse/issues/800
target_link_libraries(lilcom_extension PUBLIC "-Wl,-rpath,${LILCOM_RPATH_ORIGIN}/../..")
elseif(WIN32)
target_link_libraries(lilcom_extension PRIVATE ${PYTHON_LIBRARIES})
endif()

if(LILCOM_ENABLE_TESTS)
Expand Down
7 changes: 6 additions & 1 deletion cmake/cmake_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from setuptools.command.build_ext import build_ext


def is_for_pypi():
ans = os.environ.get("LILCOM_IS_FOR_PYPI", None)
return ans is not None


def is_macos():
return platform.system() == "Darwin"

Expand All @@ -27,7 +32,7 @@ def finalize_options(self):
_bdist_wheel.finalize_options(self)
# In this case, the generated wheel has a name in the form
# sherpa-xxx-pyxx-none-any.whl
if not is_macos():
if is_for_pypi() and not is_macos():
self.root_is_pure = True
else:
# The generated wheel has a name ending with
Expand Down
2 changes: 1 addition & 1 deletion scripts/conda/lilcom/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: lilcom
version: "1.5.1"
version: "1.6"

source:
path: "{{ environ.get('LILCOM_ROOT_DIR') }}"
Expand Down

0 comments on commit 3d02b52

Please sign in to comment.