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
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, To quote alure's README,
> It uses OpenAL for audio rendering, and provides common higher-level features > 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. > and source management for virtually unlimited sound source handles.
## Features ## 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): is to OpenGL (except that all the heavy-lifting are taken are by alure):
* 3D sound rendering * 3D sound rendering
@ -19,30 +19,39 @@ is to OpenGL (except that all the heavy-lifting are taken are by alure):
type annotation type annotation
## Installation ## Installation
### Prerequisites
Palace runtime only depends on [alure] and Python 3.6+.
`pip` is required for installation.
### Via PyPI ### Via PyPI
Palace requires Python 3.6+ and [alure][0]. Wheel distribution is not yet ready at the time of writing. If you want to
Given these dependencies satisfied, palace could be installed using `pip` via help out, please head to our GitHub issues [#1][GH-1] and [#3][GH-3].
pip install palace
Currently only GNU/Linux is supported. If you want to help package for
other operating systems, please head to issue #1.
### From source ### From source
To build from source, one will also need to have Python headers, [Cython][2], Aside from the build dependencies listed in `pyproject.toml`, one will
and a C++11 compiler (and probably `git` for fetching the source) installed. additionally need compatible Python headers and a C++11 compiler (and probably
Palace can then be compiled and installed by running `git` for fetching the source). Palace can then be compiled and installed
by running
```sh ```sh
git clone https://github.com/McSinyx/palace git clone https://github.com/McSinyx/palace
cd palace pip install palace/
python setup.py install --user
``` ```
## Usage ## Usage
One may start with the `examples` for sample usage of palace. One may start with the `examples` for sample usage of palace.
For further information, Python's `help` is your friend. For further information, Python's `help` is your friend.
[0]: https://github.com/kcat/alure ## License and Credits
[1]: https://github.com/moderngl/moderngl Palace is released under the [GNU LGPL version 3 or later][LGPLv3+].
[2]: https://cython.org/
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] [build-system]
# Minimum requirements for the build system to execute. requires = ['setuptools>=43', 'wheel>=0.31', 'Cython']
requires = ['setuptools', 'wheel', '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 #!/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 Cython.Build import cythonize
from setuptools import setup, Extension from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
with open('README.md') as f:
long_description = f.read()
setup( class BuildAlure2Ext(build_ext):
name='palace', """Builder of extensions linked to alure2."""
version='0.0.3', def finalize_options(self) -> None:
description='Pythonic Audio Library and Codecs Environment', """Add alure2's and its dependencies' include directories
long_description=long_description, and objects to Extension attributes.
long_description_content_type='text/markdown', """
url='https://github.com/McSinyx/palace', super().finalize_options()
author='Nguyễn Gia Phong', mkpath(self.build_temp)
author_email='vn.mcsinyx@gmail.com', copy_file(join(dirname(__file__), 'CMakeLists.txt'),
license='LGPLv3+', self.build_temp)
classifiers=[ cmake = run(['cmake', '.'], check=True, stdout=DEVNULL, stderr=PIPE,
'Development Status :: 2 - Pre-Alpha', cwd=self.build_temp, universal_newlines=True)
'Intended Audience :: Developers', for key, value in map(methodcaller('groups'),
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)', re.finditer(r'^alure2_(\w*)=(.*)$',
'Operating System :: POSIX :: Linux', cmake.stderr, re.MULTILINE)):
'Programming Language :: C++', for ext in self.extensions:
'Programming Language :: Cython', getattr(ext, key).extend(value.split(';'))
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8', setup(cmdclass={'build_ext': BuildAlure2Ext},
'Programming Language :: Python :: 3 :: Only', ext_modules=cythonize(
'Topic :: Multimedia :: Sound/Audio', Extension(name='palace', sources=['palace.pyx'], language='c++'),
'Topic :: Software Development :: Libraries', compiler_directives=dict(
'Typing :: Typed'], binding=False, embedsignature=True, language_level='3str',
keywords='openal alure hrtf', c_string_type='str', c_string_encoding='utf8')))
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)

15
tox.ini
View File

@ -1,4 +1,11 @@
[flake8] [tox]
ignore = E225, E226, E227, E701 minversion = 3.3
filename = *.py, *.pyx isolated_build = true
exclude = setup.py
[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