Skip to content

Commit

Permalink
Update CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisstaite committed Jan 1, 2025
1 parent 65e41fc commit f050e2a
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ make
make install
cd ..
for PYBIN in /opt/python/*/bin; do
if [[ $PYBIN = *"cp27"* ]]; then
if [[ $PYBIN = *"cp27"* ]] || [[ $PYBIN = *"cp36"* ]] || [[ $PYBIN = *"cp37"* ]]; then
continue
fi
"${PYBIN}/python" setup.py bdist_wheel -b build/build_tmp -d build --libdir=build/lib --incdir=build/include/lame
"${PYBIN}/python" -m build -w -o build -C="--build-option=--libdir=build/lib" -C="--build-option=--incdir=build/include/lame"
done
for whl in build/*.whl; do
auditwheel repair "$whl" -w build/
Expand Down
89 changes: 59 additions & 30 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Execute the build
uses: docker://quay.io/pypa/manylinux_2_24_x86_64
with:
entrypoint: bash
args: /github/workspace/.github/workflows/build.sh
- name: Archive built wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: manylinux2_24_64
path: build/*.whl
Expand All @@ -33,7 +36,7 @@ jobs:
needs: [ build_linux2_24_64 ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
id: download
with:
name: manylinux2_24_64
Expand All @@ -49,14 +52,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Execute the build
uses: docker://quay.io/pypa/manylinux_2_24_i686
with:
entrypoint: linux32
args: bash /github/workspace/.github/workflows/build.sh
- name: Archive built wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: manylinux2_24_32
path: build/*.whl
Expand All @@ -67,7 +73,7 @@ jobs:
needs: [ build_linux2_24_32 ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
id: download
with:
name: manylinux2_24_32
Expand All @@ -83,7 +89,10 @@ jobs:
runs-on: ubuntu-latest

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

- name: Set up emulation
uses: docker/setup-qemu-action@v2
Expand All @@ -96,7 +105,7 @@ jobs:
entrypoint: bash
args: /github/workspace/.github/workflows/build.sh
- name: Archive built wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: manylinux2_24_aarch64
path: build/*.whl
Expand All @@ -107,7 +116,7 @@ jobs:
needs: [ build_linux2_24_aarch64 ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
id: download
with:
name: manylinux2_24_aarch64
Expand All @@ -123,14 +132,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Execute the build
uses: docker://quay.io/pypa/manylinux_2_28_x86_64
with:
entrypoint: bash
args: /github/workspace/.github/workflows/build.sh
- name: Archive built wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: manylinux2_28_64
path: build/*.whl
Expand All @@ -141,7 +153,7 @@ jobs:
needs: [ build_linux2_28_64 ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
id: download
with:
name: manylinux2_28_64
Expand All @@ -157,10 +169,13 @@ jobs:
runs-on: ubuntu-latest

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

- name: Set up emulation
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
platforms: aarch64

Expand All @@ -170,7 +185,7 @@ jobs:
entrypoint: bash
args: /github/workspace/.github/workflows/build.sh
- name: Archive built wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: manylinux2_28_aarch64
path: build/*.whl
Expand All @@ -181,7 +196,7 @@ jobs:
needs: [ build_linux2_28_aarch64 ]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
id: download
with:
name: manylinux2_28_aarch64
Expand All @@ -203,34 +218,41 @@ jobs:

steps:
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: python -m pip install --user setuptools wheel
- uses: actions/checkout@v2
run: python -m pip install --user build
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Build the wheel
run: |
mkdir build
cd build
cmake -DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" -DPYTHON_VERSIONS=${{ matrix.python-version }} ..
make
- name: Archive built wheel
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: mac
name: mac_${{ matrix.arch }}_${{ matrix.python-version }}
path: build/*.whl
if-no-files-found: error

publish_mac:
if: github.event_name == 'release' && github.event.action == 'created'
needs: [ build_mac ]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
arch: ['arm64', 'x86_64']
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
id: download
with:
name: mac
name: mac_${{ matrix.arch }}_${{ matrix.python-version }}

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -255,35 +277,42 @@ jobs:

steps:
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.python-arch }}
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install dependencies
run: python -m pip install --upgrade setuptools wheel
run: python -m pip install --upgrade build
- name: Build the wheel
run: |
mkdir build
cd build
cmake -DPYTHON_VERSIONS=${{ matrix.python-version }} .. -G "Visual Studio 16 2019" ${{ matrix.arch }}
cmake --build . --config Release
- name: Archive built wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: windows
name: windows_${{ matrix.python-arch }}_${{ matrix.python-version }}
path: build/*.whl
if-no-files-found: error

publish_windows:
if: github.event_name == 'release' && github.event.action == 'created'
needs: [ build_windows ]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-arch: ['x86', 'x64']
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
id: download
with:
name: windows
name: windows_${{ matrix.python-arch }}_${{ matrix.python-version }}

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (APPLE)
set(HOST "")
if ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64" OR "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
set(ARCH_FLAGS "-arch x86_64")
set(HOST "--host=x86_64")
endif ()
if ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
set(ARCH_FLAGS "${ARCH_FLAGS} -arch arm64")
Expand Down Expand Up @@ -109,15 +110,14 @@ foreach (Version IN LISTS PYTHON_VERSIONS)
COMMAND ${CMAKE_COMMAND}
ARGS
-E env "ARCHFLAGS=${ARCH_FLAGS}" "${HOST_PLATFORM}"
${PYTHON${Version}_EXECUTABLE}
"${CMAKE_CURRENT_SOURCE_DIR}/setup.py" bdist_wheel
-b "${CMAKE_CURRENT_BINARY_DIR}/build_tmp"
-d "${CMAKE_CURRENT_BINARY_DIR}"
"--libdir=${BINARY_DIR}/lib"
"--incdir=${SOURCE_DIR}/include"
${PYTHON${Version}_EXECUTABLE} -m build -w
-o "${CMAKE_CURRENT_BINARY_DIR}"
"-C=--build-option=--libdir=${BINARY_DIR}/lib"
"-C=--build-option=--incdir=${SOURCE_DIR}/include"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS
lame
"${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml"
"${CMAKE_CURRENT_SOURCE_DIR}/setup.py"
"${CMAKE_CURRENT_SOURCE_DIR}/lameenc.c"
)
Expand Down
5 changes: 5 additions & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Python 3 bindings for the LAME encoding library.
This library makes it simple to encode PCM data into MP3 without having
to compile any binaries.

Provides binaries in PyPi for Python 3.8+ for Windows, macOS and Linux.
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[build-system]
requires = ["setuptools","wheel", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "lameenc"
description = "LAME encoding bindings"
readme = "DESCRIPTION.md"
authors = [
{name = "Chris Staite", email = "[email protected]"},
]
license = {file = "LICENSE"}
classifiers = [
"Topic :: Multimedia :: Sound/Audio :: Conversion",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux"
]
dynamic = ["version"]

[project.urls]
Repository = "https://github.com/chrisstaite/lameenc"

[tool.setuptools_scm]
36 changes: 16 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,41 @@
import os.path


print(sys.argv)
# Grab the library location from the command line
libdir = None
for argument in sys.argv:
if argument.startswith('--libdir='):
libdir = argument
if libdir is None:
print('Need to specify location of liblame')
sys.exit(1)
sys.argv.remove(libdir)
libdir = libdir[len('--libdir='):]
if 'bdist_wheel' in sys.argv:
print('Need to specify location of liblame')
sys.exit(1)
else:
sys.argv.remove(libdir)
libdir = libdir[len('--libdir='):]

# Grab the include location from the command line
incdir = None
for argument in sys.argv:
if argument.startswith('--incdir='):
incdir = argument
if incdir is None:
print('Need to specify location of liblame source')
sys.exit(1)
sys.argv.remove(incdir)
incdir = incdir[len('--incdir='):]
if 'bdist_wheel' in sys.argv:
print('Need to specify location of liblame source')
sys.exit(1)
else:
sys.argv.remove(incdir)
incdir = incdir[len('--incdir='):]

# Create the extension
lameenc = distutils.core.Extension(
'lameenc',
include_dirs=[incdir],
include_dirs=[incdir] if incdir else [],
libraries=['libmp3lame'] if sys.platform == 'win32' else [],
extra_objects=
[] if sys.platform == 'win32' else [os.path.join(libdir, 'libmp3lame.a')],
library_dirs=[libdir] if sys.platform == 'win32' else [],
[] if sys.platform == 'win32' or not libdir else [os.path.join(libdir, 'libmp3lame.a')],
library_dirs=[libdir] if sys.platform == 'win32' and libdir else [],
sources=['lameenc.c']
)

Expand Down Expand Up @@ -62,14 +67,5 @@
]
)

if os.path.exists(os.path.join(os.path.abspath(os.path.dirname(__file__)), '.git')):
configuration['setup_requires'] = ['setuptools-git-versioning']
configuration['setuptools_git_versioning'] = {
'enabled': True,
'starting_version': '1.7.0'
}
else:
configuration['version'] = '1.7.0'

# Create the package
setuptools.setup(**configuration)

0 comments on commit f050e2a

Please sign in to comment.