-
Notifications
You must be signed in to change notification settings - Fork 541
/
Copy pathsetup.py
146 lines (122 loc) · 5.56 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import shutil
import os
import glob
import subprocess
import sys
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.install_lib import install_lib
library = None
PYTHON = sys.executable
# Default project name
project_name = 'essentia'
var_project_name = 'ESSENTIA_PROJECT_NAME'
if var_project_name in os.environ:
project_name = os.environ[var_project_name]
class EssentiaInstall(install_lib):
def install(self):
global library
install_dir = os.path.join(self.install_dir, library.split(os.sep)[-1])
res = shutil.move(library, install_dir)
os.system("ls -l %s" % self.install_dir)
return [install_dir]
class EssentiaBuildExtension(build_ext):
def run(self):
global library
os.system('rm -rf tmp; mkdir tmp')
# Ugly hack using an enviroment variable... There's no way to pass a
# custom flag to python setup.py bdist_wheel
var_skip_3rdparty = 'ESSENTIA_WHEEL_SKIP_3RDPARTY'
var_only_python = 'ESSENTIA_WHEEL_ONLY_PYTHON'
var_macos_arm64 = os.getenv('ESSENTIA_MACOSX_ARM64')
macos_arm64_flags = []
if var_macos_arm64 == '1':
macos_arm64_flags = ['--arch=arm64', '--no-msse']
if var_skip_3rdparty in os.environ and os.environ[var_skip_3rdparty]=='1':
print('Skipping building static 3rdparty dependencies (%s=1)' % var_skip_3rdparty)
else:
subprocess.run('./packaging/build_3rdparty_static_debian.sh', check=True)
if var_only_python in os.environ and os.environ[var_only_python]=='1':
print('Skipping building the core libessentia library (%s=1)' % var_only_python)
subprocess.run([PYTHON, 'waf', 'configure', '--only-python', '--static-dependencies',
'--prefix=tmp'] + macos_arm64_flags, check=True)
else:
subprocess.run([PYTHON, 'waf', 'configure', '--build-static', '--static-dependencies'
'--with-python --prefix=tmp'] + macos_arm64_flags, check=True)
subprocess.run([PYTHON, 'waf'], check=True)
subprocess.run([PYTHON, 'waf', 'install'], check=True)
library = glob.glob('tmp/lib/python*/*-packages/essentia')[0]
def get_git_version():
""" try grab the current version number from git"""
version = None
if os.path.exists(".git"):
try:
version = os.popen("git describe --always --tags").read().strip()
except Exception as e:
print(e)
return version
def get_version():
version = open('VERSION', 'r').read().strip('\n')
if version.count('-dev'):
# Development version. Get the number of commits after the last release
git_version = get_git_version()
print('git describe:', git_version)
dev_commits = git_version.split('-')[-2] if git_version else ''
if not dev_commits.isdigit():
print('Error parsing the number of dev commits: %s', dev_commits)
dev_commits = '0'
version += dev_commits
return version
classifiers = [
'License :: OSI Approved :: GNU Affero General Public License v3',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Software Development :: Libraries',
'Topic :: Multimedia :: Sound/Audio :: Analysis',
'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis',
'Operating System :: POSIX',
'Operating System :: MacOS :: MacOS X',
#'Operating System :: Microsoft :: Windows',
'Programming Language :: C++',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
]
description = 'Library for audio and music analysis, description and synthesis'
long_description = '''
Essentia is an open-source C++ library with Python bindings for audio analysis and audio-based music information retrieval. It contains an extensive collection of algorithms, including audio input/output functionality, standard digital signal processing blocks, statistical characterization of data, a large variety of spectral, temporal, tonal, and high-level music descriptors, and tools for inference with deep learning models. Designed with a focus on optimization in terms of robustness, computational speed, low memory usage, as well as flexibility, it is efficient for many industrial applications and allows fast prototyping and setting up research experiments very rapidly.
Website: https://essentia.upf.edu
'''
setup_requires = ['numpy>=1.8.2', 'six']
install_requires = setup_requires + ['pyyaml']
# Require tensorflow for the package essentia-tensorflow
# We are using version 2.5.0 as it is the newest version supported by the C API
# https://www.tensorflow.org/guide/versions
if project_name == 'essentia-tensorflow':
description += ', with TensorFlow support'
module = Extension('name', sources=[])
setup(
name=project_name,
version=get_version(),
description=description,
long_description=long_description,
author='Dmitry Bogdanov',
author_email='[email protected]',
url='http://essentia.upf.edu',
project_urls={
"Documentation": "http://essentia.upf.edu",
"Source Code": "https://github.com/MTG/essentia"
},
keywords='audio music sound dsp MIR',
license='AGPLv3',
platforms='any',
classifiers=classifiers,
setup_requires=setup_requires,
install_requires=install_requires,
ext_modules=[module],
cmdclass={
'build_ext': EssentiaBuildExtension,
'install_lib': EssentiaInstall
}
)