我想围绕这个库创建一个薄包装https://github.com/jupyter-incubator/sparkmagic#installation https://github.com/jupyter-incubator/sparkmagic#installation
正如您在链接中看到的,安装步骤需要
- 使用 pip 安装一些包
- 运行某种类型的命令
jupyter enable ...
or jupyter-kernelspec install
- 我想要生成并放置在正确位置的自定义配置文件
我正在检查必须使用哪些选项才能使安装像调用脚本一样自动进行。到目前为止,我已经用所有这些命令创建了一个 bash 脚本。通过这种方式,它可以通过一个简单的install.sh
但我可能会遇到问题,因为我不知道要使用哪个 python 二进制文件。如果用户想要安装 python2 或 python3 的库,除非他接触脚本,否则他无法进行此选择。
然后我尝试使用setup.py
并覆盖cmdclass
插入自定义代码
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
develop.run(self)
print("do things")
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
print("do things")
setup(
...
install_requires=['sparkmagic'],
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
...
)
但自定义打印仅在运行时有效python setup.py install
但不是为了pip install
我想让最后一个选项起作用,但如果这不是做这类事情的正确模式,你能建议我走哪条路吗?
问题不在于pip install
直接但与wheels。打包为wheel的项目不能有自定义安装步骤。例如参见这个讨论 https://github.com/pypa/packaging-problems/issues/64. Since pip更喜欢使用轮子,必要时在本地构建它们,您的自定义步骤不会在安装时运行。不过,可能有一些方法可以防止车轮失步。
知道这一点后,您可能应该遵循以下建议扬·维尔钦斯基在他对这个问题的回答的评论中:安装轮子后安装后脚本 https://stackoverflow.com/questions/24263774/post-install-script-after-installing-a-wheel/24749871#comment41929643_24749871.
Add a 设置工具 控制台入口点 https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation到你的项目(我们称之为myprojectconfigure
)。也许您更喜欢使用迪斯图尔斯 script feature https://docs.python.org/3/distutils/setupscript.html#installing-scripts反而。
指示您的软件包的用户在安装您的软件包后立即运行它(pip install myproject && myprojectconfigure
).
最终考虑提供myprojectconfigure --uninstall
以及。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)