我正在尝试自动安装和启用Jupyter扩展,这样用户就不需要键入命令:
jupyter nbextension install --user <my_fancy_module>
jupyter nbextension enable <the entry point> --user
如Jupyter Notebook documentation中所述,可以在setup.py
中指定:
import setuptools
setuptools.setup(
name="MyFancyModule",
...
include_package_data=True,
data_files=[
# like `jupyter nbextension install --sys-prefix`
("share/jupyter/nbextensions/my_fancy_module", [
"my_fancy_module/static/index.js",
]),
# like `jupyter nbextension enable --sys-prefix`
("etc/jupyter/nbconfig/notebook.d", [
"jupyter-config/nbconfig/notebook.d/my_fancy_module.json"
])
],
...
zip_safe=False
)
但是,当我尝试在包目录中运行pip install .
时,安装完成,但my_fancy_module
没有安装。跑步:
jupyter nbextension install --user <my_fancy_module>
工作正常,因为它正确地复制了<my_fancy_module>
中我的包目录中的整个~/Library/Jupyter/nbextensions/
。你知道吗
根据Python documentation on Installing Additional Files:
data_files
specifies a sequence of (directory, files) (...) Each (directory, files) pair in the sequence specifies the installation directory and the files to install there. (...) The directory should be a relative path. It is interpreted relative to the installation prefix (Python’ssys.prefix
for system installations;site.USER_BASE
for user installations).
我的site.USER_BASE
指向~/.local
。你知道吗
我的问题是:
如何从setup.py
内部安装并启用my_fancy_package
,从而得到与执行开头提到的两个命令相同的结果?如果这是关于指定data_files
-为了成功安装和启用my_fancy_module
,我应该指定什么directory
?你知道吗
我试过:
"/Library/Jupyter/nbextensions/my_fancy_module"
,"../Library/Jupyter/nbextensions/my_fancy_module"
,"share/jupyter/nbextensions/my_fancy_module"
但都没用。你知道吗
似乎
data_files
很难接受绝对路径作为目的地,但是如果您使用no-binary
标志运行setup.py
,即pip install <my_package> no-binary :all":
,它可以正常工作。你知道吗相关问题 更多 >
编程相关推荐