Skip to content

Commit

Permalink
Fix __libsoxr_version__ (#22)
Browse files Browse the repository at this point in the history
* Bump Python to 3.12.0 release
  • Loading branch information
dofuuz authored Oct 4, 2023
1 parent ab74a5a commit 7b3f5d6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Build wheels
uses: pypa/cibuildwheel@v2.14.1
uses: pypa/cibuildwheel@v2.16.2
env:
# Skip builds(save time / avoid build error)
CIBW_SKIP: "cp36-* pp* *-musllinux_* *_i686 *-win32"
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_BUILD_FRONTEND: "build"

- uses: actions/upload-artifact@v3
with:
Expand All @@ -46,6 +48,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Set up QEMU
Expand All @@ -54,11 +57,12 @@ jobs:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.14.1
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_LINUX: aarch64
CIBW_BUILD: cp*-manylinux_aarch64
CIBW_SKIP: "cp36-*"
CIBW_BUILD_FRONTEND: "build"

- uses: actions/upload-artifact@v3
with:
Expand All @@ -75,10 +79,13 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Build sdist
run: pipx run build --sdist
run: |
python -m pip install build
python -m build --sdist
- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy3.9"]
python-version: ["3.9", "3.10", "3.11", "3.12", "pypy3.9"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

Expand Down
26 changes: 19 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
from distutils.ccompiler import get_default_compiler
from setuptools import setup, Extension
from setuptools.command.sdist import sdist
from wheel.bdist_wheel import bdist_wheel


SYS_LIBSOXR = False

# python -m build -C=--build-option=--use-system-libsoxr
# python -m build -C--build-option=--use-system-libsoxr
if '--use-system-libsoxr' in sys.argv:
sys.argv.remove('--use-system-libsoxr')
SYS_LIBSOXR = True
Expand All @@ -38,6 +39,7 @@ def include_dirs(self, dirs):
self._include = dirs


# Submodule versioning
def get_git_version(cwd=''):
try:
result = subprocess.run(
Expand All @@ -47,8 +49,8 @@ def get_git_version(cwd=''):
ver = result.stdout.strip()
return ver
except Exception as e:
logging.warning(f'Error retrieving submodule version: {e}')
return 'unknown'
logging.warning(f'Can not get {cwd} version: {e}')
return None


CSOXR_VERSION_C = '''
Expand All @@ -57,13 +59,23 @@ def get_git_version(cwd=''):
'''


class SDistBundledCommand(sdist):
def run(self):
ver = get_git_version('libsoxr')
def write_csoxr_version():
ver = get_git_version('libsoxr')
if ver:
with open(f'src/soxr/_csoxr_version.c', 'wt') as f:
f.write(CSOXR_VERSION_C % (ver))
logging.info(f'libsoxr version: {ver}')


class CustomSDistCmd(sdist):
def run(self):
write_csoxr_version()
super().run()


class CustomWheelCmd(bdist_wheel):
def run(self):
write_csoxr_version()
super().run()


Expand Down Expand Up @@ -142,6 +154,6 @@ def run(self):
else:
logging.info('Building Python-SoXR using bundled libsoxr...')
setup(
cmdclass={'sdist': SDistBundledCommand},
cmdclass={'sdist': CustomSDistCmd, 'bdist_wheel': CustomWheelCmd},
ext_modules=cythonize(extensions, language_level='3'),
)

0 comments on commit 7b3f5d6

Please sign in to comment.