Skip to content

Commit

Permalink
Publish pre-built wheels to PyPI (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Jan 10, 2023
1 parent 4091cd0 commit 474674e
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, "macos-10.15", windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/build-wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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/[email protected]
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 }}
shell: bash
run: |
python3 -m pip install --upgrade pip
python3 -m pip install wheel twine setuptools
twine upload ./wheelhouse/*.whl
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: |
python3 -m pip install --upgrade numpy
- name: Configure Cmake
- name: Configure CMake
shell: bash
run: |
mkdir build
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_conda_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
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 @@ -41,6 +41,7 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
activate-environment: kaldi_native_io

- 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 @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
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 @@ -41,6 +41,7 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
activate-environment: kaldi_native_io

- 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 @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
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 @@ -41,6 +41,7 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
activate-environment: kaldi_native_io

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

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/test-pip-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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.7", "3.8", "3.9", "3.10", "3.11"]

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 kaldi_native_io
shell: bash
run: |
pip3 install --verbose kaldi_native_io
- name: Run test
shell: bash
run: |
cd kaldi_native_io/python/tests
python3 -c "import kaldi_native_io; print(kaldi_native_io.__file__)"
python3 -c "import kaldi_native_io; print(kaldi_native_io.__version__)"
python3 -m pip install --upgrade pip pytest
pytest
37 changes: 18 additions & 19 deletions cmake/pybind11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,32 @@ function(download_pybind11)

include(FetchContent)

set(pybind11_URL "https://github.com/pybind/pybind11/archive/v2.6.0.tar.gz")
set(pybind11_HASH "SHA256=90b705137b69ee3b5fc655eaca66d0dc9862ea1759226f7ccd3098425ae69571")

set(double_quotes "\"")
set(dollar "\$")
set(semicolon "\;")
if(NOT WIN32)
FetchContent_Declare(pybind11
URL ${pybind11_URL}
URL_HASH ${pybind11_HASH}
PATCH_COMMAND
sed -i.bak "s/VERSION 3.4/VERSION 3.3/g" CMakeLists.txt
)
else()
FetchContent_Declare(pybind11
URL ${pybind11_URL}
URL_HASH ${pybind11_HASH}
)
set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v2.10.2.tar.gz")
set(pybind11_HASH "SHA256=93bd1e625e43e03028a3ea7389bba5d3f9f2596abc074b068e70f4ef9b1314ae")

# If you don't have access to the Internet, please download it to your
# local drive and modify the following line according to your needs.
if(EXISTS "/star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz")
set(pybind11_URL "file:///star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz")
elseif(EXISTS "/Users/fangjun/Downloads/pybind11-2.10.2.tar.gz")
set(pybind11_URL "file:///Users/fangjun/Downloads/pybind11-2.10.2.tar.gz")
elseif(EXISTS "/tmp/pybind11-2.10.2.tar.gz")
set(pybind11_URL "file:///tmp/pybind11-2.10.2.tar.gz")
endif()

FetchContent_Declare(pybind11
URL ${pybind11_URL}
URL_HASH ${pybind11_HASH}
)

FetchContent_GetProperties(pybind11)
if(NOT pybind11_POPULATED)
message(STATUS "Downloading pybind11")
message(STATUS "Downloading pybind11 from ${pybind11_URL}")
FetchContent_Populate(pybind11)
endif()
message(STATUS "pybind11 is downloaded to ${pybind11_SOURCE_DIR}")
add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR} EXCLUDE_FROM_ALL)

endfunction()

download_pybind11()
9 changes: 0 additions & 9 deletions kaldi_native_io/python/csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ pybind11_add_module(_kaldi_native_io
wave-reader.cc
)

if(UNIX AND NOT APPLE)
target_link_libraries(_kaldi_native_io PUBLIC ${PYTHON_LIBRARY})
endif()

if(APPLE)
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
Expand All @@ -29,11 +25,6 @@ if(NOT WIN32)
endif()

target_link_libraries(_kaldi_native_io PRIVATE kaldi_native_io_core)
if(UNIX AND NOT APPLE)
target_link_libraries(_kaldi_native_io PUBLIC ${PYTHON_LIBRARY})
elseif(WIN32)
target_link_libraries(_kaldi_native_io PUBLIC ${PYTHON_LIBRARIES})
endif()

install(TARGETS _kaldi_native_io
DESTINATION ../
Expand Down
2 changes: 1 addition & 1 deletion kaldi_native_io/python/csrc/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class BlobHolder {

if (is.good()) {
// s is copied to value_
value_ = py::bytes(s.data(), len);
value_ = py::bytes(s.data(), static_cast<int32_t>(len));
}

return is.good();
Expand Down

0 comments on commit 474674e

Please sign in to comment.