Make build more portable and compatible with manylinux2014

Additionally:
* Specify some build requirement version
* Move metadata outta setup script
* Add linting tests to tox
This commit is contained in:
Nguyễn Gia Phong 2020-01-24 17:00:21 +07:00
parent 659196ed7b
commit 37e471354b
7 changed files with 115 additions and 60 deletions

10
CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.6.0)
project(palace)
find_package(Alure2 REQUIRED CONFIG)
get_target_property(include_dirs Alure2::alure2 INTERFACE_INCLUDE_DIRECTORIES)
message("alure2_include_dirs=${include_dirs}")
get_target_property(link_libraries Alure2::alure2 INTERFACE_LINK_LIBRARIES)
get_target_property(libalure2 Alure2::alure2 IMPORTED_LOCATION_NOCONFIG)
message("alure2_extra_objects=${link_libraries};${libalure2}")

View File

@ -1 +1,2 @@
include LICENSE pyproject.toml alure.pxd palace.pyx
include alure.pxd palace.pyx CMakeLists.txt
graft examples

View File

@ -1,5 +1,5 @@
# palace
Palace is a Python 3D audio API wrapping around [alure][0].
Palace is a Python 3D audio API wrapping around [alure].
To quote alure's README,
> It uses OpenAL for audio rendering, and provides common higher-level features
@ -7,7 +7,7 @@ To quote alure's README,
> and source management for virtually unlimited sound source handles.
## Features
In some sense, what palace aimes to be to OpenAL is what [ModernGL][1]
In some sense, what palace aimes to be to OpenAL is what [ModernGL]
is to OpenGL (except that all the heavy-lifting are taken are by alure):
* 3D sound rendering
@ -19,30 +19,39 @@ is to OpenGL (except that all the heavy-lifting are taken are by alure):
type annotation
## Installation
### Prerequisites
Palace runtime only depends on [alure] and Python 3.6+.
`pip` is required for installation.
### Via PyPI
Palace requires Python 3.6+ and [alure][0].
Given these dependencies satisfied, palace could be installed using `pip` via
pip install palace
Currently only GNU/Linux is supported. If you want to help package for
other operating systems, please head to issue #1.
Wheel distribution is not yet ready at the time of writing. If you want to
help out, please head to our GitHub issues [#1][GH-1] and [#3][GH-3].
### From source
To build from source, one will also need to have Python headers, [Cython][2],
and a C++11 compiler (and probably `git` for fetching the source) installed.
Palace can then be compiled and installed by running
Aside from the build dependencies listed in `pyproject.toml`, one will
additionally need compatible Python headers and a C++11 compiler (and probably
`git` for fetching the source). Palace can then be compiled and installed
by running
```sh
git clone https://github.com/McSinyx/palace
cd palace
python setup.py install --user
pip install palace/
```
## Usage
One may start with the `examples` for sample usage of palace.
For further information, Python's `help` is your friend.
[0]: https://github.com/kcat/alure
[1]: https://github.com/moderngl/moderngl
[2]: https://cython.org/
## License and Credits
Palace is released under the [GNU LGPL version 3 or later][LGPLv3+].
The [`cmake` modules are provided by scikit-build][sk-cmake], which is
originally released under the [MIT and 2-clause BSD][sk-license] licence.
[alure]: https://github.com/kcat/alure
[ModernGL]: https://github.com/moderngl/moderngl
[Cython]: https://cython.org/
[GH-1]: https://github.com/McSinyx/palace/issues/1
[GH-3]: https://github.com/McSinyx/palace/issues/3
[LGPLv3+]: https://www.gnu.org/licenses/lgpl-3.0.en.html
[sk-cmake]: https://scikit-build.readthedocs.io/en/latest/cmake-modules.html
[sk-license]: https://github.com/scikit-build/scikit-build/blob/master/LICENSE

View File

@ -1,3 +1,3 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ['setuptools', 'wheel', 'cython']
requires = ['setuptools>=43', 'wheel>=0.31', 'Cython']
build-backend = "setuptools.build_meta"

30
setup.cfg Normal file
View File

@ -0,0 +1,30 @@
[metadata]
name = palace
version = 0.0.3
url = https://github.com/McSinyx/palace
author = Nguyễn Gia Phong
author_email = vn.mcsinyx@gmail.com
classifiers =
Development Status :: 2 - Pre-Alpha
Intended Audience :: Developers
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Operating System :: POSIX :: Linux
Programming Language :: C++
Programming Language :: Cython
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3 :: Only
Topic :: Multimedia :: Sound/Audio
Topic :: Software Development :: Libraries
Typing :: Typed
license = LGPLv3+
license_file = LICENSE
description = Pythonic Audio Library and Codecs Environment
long_description = file: README.md
long_description_content_type = text/markdown
keywords = openal, alure, hrtf
[options]
zip_safe = False
python_requires = >=3.6

View File

@ -1,40 +1,38 @@
#!/usr/bin/env python3
import re
from distutils.dir_util import mkpath
from distutils.file_util import copy_file
from operator import methodcaller
from os.path import dirname, join
from subprocess import DEVNULL, PIPE, run
from Cython.Build import cythonize
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
with open('README.md') as f:
long_description = f.read()
setup(
name='palace',
version='0.0.3',
description='Pythonic Audio Library and Codecs Environment',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/McSinyx/palace',
author='Nguyễn Gia Phong',
author_email='vn.mcsinyx@gmail.com',
license='LGPLv3+',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Operating System :: POSIX :: Linux',
'Programming Language :: C++',
'Programming Language :: Cython',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Multimedia :: Sound/Audio',
'Topic :: Software Development :: Libraries',
'Typing :: Typed'],
keywords='openal alure hrtf',
ext_modules=cythonize(
Extension('palace', ['palace.pyx'],
include_dirs=['/usr/include/AL/'],
libraries=['alure2'], language='c++'),
compiler_directives=dict(
binding=False, embedsignature=True, language_level='3str',
c_string_type='str', c_string_encoding='utf8')),
zip_safe=False)
class BuildAlure2Ext(build_ext):
"""Builder of extensions linked to alure2."""
def finalize_options(self) -> None:
"""Add alure2's and its dependencies' include directories
and objects to Extension attributes.
"""
super().finalize_options()
mkpath(self.build_temp)
copy_file(join(dirname(__file__), 'CMakeLists.txt'),
self.build_temp)
cmake = run(['cmake', '.'], check=True, stdout=DEVNULL, stderr=PIPE,
cwd=self.build_temp, universal_newlines=True)
for key, value in map(methodcaller('groups'),
re.finditer(r'^alure2_(\w*)=(.*)$',
cmake.stderr, re.MULTILINE)):
for ext in self.extensions:
getattr(ext, key).extend(value.split(';'))
setup(cmdclass={'build_ext': BuildAlure2Ext},
ext_modules=cythonize(
Extension(name='palace', sources=['palace.pyx'], language='c++'),
compiler_directives=dict(
binding=False, embedsignature=True, language_level='3str',
c_string_type='str', c_string_encoding='utf8')))

15
tox.ini
View File

@ -1,4 +1,11 @@
[flake8]
ignore = E225, E226, E227, E701
filename = *.py, *.pyx
exclude = setup.py
[tox]
minversion = 3.3
isolated_build = true
[testenv]
deps = flake8
commands =
; Lint Python and Cython source files
flake8 --ignore=E225,E226,E227,E701
flake8 --ignore=E225,E226,E227,E701,E999 palace.pyx
flake8 --ignore=E225,E226,E227,E501,E701,E999 alure.pxd