我正在尝试安装一个程序包,该程序包会在安装过程中构建一个名为reaper的c ++库,setup.py脚本如下所示:
import subprocess
from setuptools import setup
from setuptools.command.install import install as _install
import os
with open("README.md", "r") as fh:
long_description = fh.read()
class InstallLocalPackage(_install):
def run(self):
_install.run(self)
reaper_path = os.path.join(os.path.dirname(__file__), 'REAPER')
subprocess.call("mkdir build", shell=True, cwd=reaper_path)
subprocess.call("cmake ..", shell=True, cwd=os.path.join(reaper_path, 'build'))
subprocess.call("make", shell=True, cwd=os.path.join(reaper_path, 'build'))
setup(
name="reapy",
version="0.0.1",
long_description=long_description,
packages=['reapy'],
setup_requires=["numpy"],
install_requires=["numpy"],
cmdclass={'install': InstallLocalPackage},
classifiers=[
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.7",
"Operating System :: UBUNTU",
],
)
这是python setup.py install
的终端输出:
running install
running build
running build_py
running install_lib
running install_egg_info
running egg_info
writing reapy.egg-info/PKG-INFO
writing dependency_links to reapy.egg-info/dependency_links.txt
writing requirements to reapy.egg-info/requires.txt
writing top-level names to reapy.egg-info/top_level.txt
reading manifest file 'reapy.egg-info/SOURCES.txt'
writing manifest file 'reapy.egg-info/SOURCES.txt'
removing '/Users/username/anaconda3/envs/reapyenv/lib/python3.7/site-packages
reapy-0.0.1-py3.7.egg-info' (and everything under it)
Copying reapy.egg-info to /Users/username/anaconda3/envs/reapyenv/lib/python3.7/site-packages/reapy-0.0.1-py3.7.egg-info
running install_scripts
mkdir: build: File exists
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/username/Documents/reapy/REAPER/build
[ 26%] Built target core
[ 53%] Built target wave
[ 86%] Built target epoch_tracker
[100%] Built target reaper
但是,当我导入reapy时,出现ModuleNotFoundError:没有名为“ numpy”的模块,表明未安装颠簸的。我相信这可能与cmdclass安装调用有关,但不确定如何解决此问题。