Skip to content

Commit

Permalink
WIP: Add wheel builds (#16)
Browse files Browse the repository at this point in the history
* ENH: Add Azure build

* FIX: Set standard explicitly

* FIX: Install PortAudio

* ENH: Add Makefile to doc, bump version

* FIX: build_sphinx and Makefile

* FIX: requirements.txt

* STY: Stick with python3 -m pip

* MAINT: Remove v and merge

* FIX: Missed one
  • Loading branch information
larsoner authored Sep 5, 2019
1 parent 5d861c6 commit 50d4ea2
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 30 deletions.
46 changes: 46 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Adapted from MNE-Python (BSD 3-clause)
version: 2
jobs:
build_docs:
docker:
- image: circleci/python:3.7-stretch
steps:
- checkout
- run:
name: Set BASH_ENV
command: |
echo "set -e" >> $BASH_ENV
echo "BASH_ENV:"
cat $BASH_ENV
- restore_cache:
keys:
- pip-cache

- run:
name: Get Python running
command: |
pip install --user --upgrade --progress-bar off -r doc/requirements.txt
- save_cache:
key: pip-cache
paths:
- ~/.cache/pip

# Build docs
- run:
name: make html
command: |
python setup.py build_sphinx
# Save the outputs
- store_artifacts:
path: build/sphinx/html/
destination: html

workflows:
version: 2

default:
jobs:
- build_docs
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build
doc/_build
src/*.so
src/*.egg-info
__pycache__
.eggs
29 changes: 20 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Realtime Audio Mixer for Python
===============================

**WARNING:** This is work in progress!
.. warning:: This is work in progress!

Goal: Reliable low-latency audio playback and recording with Python, using
PortAudio_ via the sounddevice_ module.
Expand Down Expand Up @@ -75,22 +75,33 @@ Somewhat similar projects:
* https://github.com/nvahalik/PyAudioMixer
* http://www.pygame.org/docs/ref/mixer.html

.. _PortAudio: http://portaudio.com/
.. _sounddevice: http://python-sounddevice.readthedocs.io/
.. _CFFI: http://cffi.readthedocs.io/
.. _soundfile: http://pysoundfile.readthedocs.io/

Installation
------------

::
On Windows, macOS, and Linux you can install a precompiled wheel with::

python3 -m pip install rtmixer

This will install ``rtmixer`` and its dependencies, including ``sounddevice``.

.. note:: On Linux, to use ``sounddevice`` and ``rtmixer`` you will need to
have PortAudio installed, e.g. via ``sudo apt install libportaudio2``.
On other platforms, PortAudio comes bundled with ``sounddevice``.

Developers can install in editable mode with some variant of::

git clone https://github.com/spatialaudio/python-rtmixer
cd python-rtmixer
git submodule update --init
python3 -m pip install -e . --user
python3 -m pip install -e .

Usage
-----

See the examples in the `examples/` directory.
See the list of `examples on GitHub`_.

.. _PortAudio: http://portaudio.com/
.. _sounddevice: http://python-sounddevice.readthedocs.io/
.. _CFFI: http://cffi.readthedocs.io/
.. _soundfile: http://pysoundfile.readthedocs.io/
.. _examples on GitHub: https://github.com/spatialaudio/python-rtmixer/tree/master/examples
100 changes: 82 additions & 18 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,83 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

# Originally adapted from github.com/vispy/vispy (BSD 3-clause)
trigger:
- master

pool:
vmImage: 'ubuntu-latest'

steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'

- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
branches:
include:
- '*'
tags:
include:
- '*'
variables:
CIBW_BUILDING: "true"
CIBW_SKIP: "cp27-* cp34-*"
CIBW_TEST_COMMAND: "python -c \"import rtmixer; print(rtmixer.__version__)\""
CIBW_BUILD_VERBOSITY: "2"
CIBW_BEFORE_BUILD: "pip install -U pip setuptools"
CIBW_BEFORE_BUILD_LINUX: "yum install -y portaudio"
jobs:
- job: linux
pool: {vmImage: 'Ubuntu-16.04'}
steps:
- task: UsePythonVersion@0
- bash: |
git submodule update --init --recursive
python -m pip install --upgrade pip
pip install cibuildwheel twine numpy Cython jupyter ipywidgets
python setup.py sdist -d wheelhouse
cibuildwheel --output-dir wheelhouse .
- task: PublishPipelineArtifact@1
inputs:
path: $(System.DefaultWorkingDirectory)/wheelhouse
artifact: deployLinux
- job: macos
pool: {vmImage: 'macOS-10.13'}
steps:
- task: UsePythonVersion@0
- bash: |
git submodule update --init --recursive
python -m pip install --upgrade pip
pip install cibuildwheel
cibuildwheel --output-dir wheelhouse .
- task: PublishPipelineArtifact@1
inputs:
path: $(System.DefaultWorkingDirectory)/wheelhouse
artifact: deployMacOS
- job: windows
pool: {vmImage: 'vs2017-win2016'}
steps:
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.5', architecture: x86}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.5', architecture: x64}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x86}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.7', architecture: x86}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.7', architecture: x64}}
- bash: |
git submodule update --init --recursive
python -m pip install --upgrade pip
pip install cibuildwheel
cibuildwheel --output-dir wheelhouse .
- task: PublishPipelineArtifact@1
inputs:
path: $(System.DefaultWorkingDirectory)/wheelhouse
artifact: deployWindows
- job: deployPyPI
pool: {vmImage: 'Ubuntu-16.04'}
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
dependsOn:
- linux
- macos
- windows
steps:
- task: UsePythonVersion@0
- task: DownloadPipelineArtifact@2
inputs:
patterns: |
deployLinux/*
deployMacOS/*.whl
deployWindows/*.whl
- bash: |
cd $(Pipeline.Workspace)
python -m pip install --upgrade pip
pip install twine
twine upload -u "__token__" --skip-existing deployLinux/* deployMacOS/* deployWindows/*
env:
TWINE_PASSWORD: $(pypiToken)
2 changes: 2 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pa-ringbuffer
sphinx_rtd_theme
sphinx
9 changes: 7 additions & 2 deletions rtmixer_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@
RINGBUFFER_CDEF + open('src/rtmixer.c').read(),
include_dirs=['src', 'portaudio/include'],
sources=['portaudio/src/common/pa_ringbuffer.c'],
#extra_compile_args=['-Wconversion'],
extra_compile_args=[
'--std=c99',
# '-Wconversion',
],
# TODO: release mode by default, option for using debug mode
undef_macros=['NDEBUG'],
undef_macros=[
# 'NDEBUG'
],
)

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/rtmixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
http://python-rtmixer.readthedocs.io/
"""
__version__ = '0.0.0'
__version__ = '0.1.0'

import sounddevice as _sd
from pa_ringbuffer import init as _init_ringbuffer
Expand Down

0 comments on commit 50d4ea2

Please sign in to comment.