From 50d4ea27f8347c2b97b64389e3d165ffebc8c40a Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 5 Sep 2019 13:33:50 -0400 Subject: [PATCH] WIP: Add wheel builds (#16) * 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 --- .circleci/config.yml | 46 ++++++++++++++++++++ .gitignore | 6 +++ README.rst | 29 +++++++++---- azure-pipelines.yml | 100 +++++++++++++++++++++++++++++++++++-------- doc/requirements.txt | 2 + rtmixer_build.py | 9 +++- src/rtmixer.py | 2 +- 7 files changed, 164 insertions(+), 30 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .gitignore diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b59e663 --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6923373 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +build +doc/_build +src/*.so +src/*.egg-info +__pycache__ +.eggs diff --git a/README.rst b/README.rst index a51110e..98c0c6e 100644 --- a/README.rst +++ b/README.rst @@ -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. @@ -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 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index aa91291..40561a8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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) diff --git a/doc/requirements.txt b/doc/requirements.txt index ea90398..9e1431c 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1 +1,3 @@ pa-ringbuffer +sphinx_rtd_theme +sphinx diff --git a/rtmixer_build.py b/rtmixer_build.py index 8ab6fb8..3728138 100644 --- a/rtmixer_build.py +++ b/rtmixer_build.py @@ -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__': diff --git a/src/rtmixer.py b/src/rtmixer.py index 2971d17..ab3c996 100644 --- a/src/rtmixer.py +++ b/src/rtmixer.py @@ -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