python - 在 setup.py 中包含 git repo(使用 pip 编译和安装)
问题描述
仅当尚未安装软件包时,如何在从源代码编译的 setup.py 设置函数中包含 git 存储库?
我有这个安装手册中的 shell 命令)。我可以用 运行这些OS module
,但如何使 pip3 install 命令健壮?如果用户重命名 pip3 --> pip 怎么办?然后我的实施将不再有效。
FENICS_VERSION=$(python3 -c"import ffc; print(ffc.__version__)")
git clone --branch=$FENICS_VERSION https://bitbucket.org/fenics-project/dolfin
git clone --branch=$FENICS_VERSION https://bitbucket.org/fenics-project/mshr
mkdir dolfin/build && cd dolfin/build && cmake .. && make install && cd ../..
mkdir mshr/build && cd mshr/build && cmake .. && make install && cd ../..
cd dolfin/python && pip3 install . && cd ../..
cd mshr/python && pip3 install . && cd ../..
背景
这个和这个问题/答案提出了一种通过具有运行方法的类向 setup.py 中的设置函数引入自定义安装命令的方法。我假设在下面的代码中,自定义安装脚本是在检查install_requires
.
from setuptools import setup
from setuptools.command.install import install as _install
import subprocess
class install(_install):
def run(self):
install.run(self)
## do the magic for the installation of mshr and dolfin
setup(name='myProject',
.......
install_requires=['fenics-ffc >= 2018.1.0'],
setup(cmdclass={'install': install}))
解决方案
推荐阅读
- android - 使用 android studio 离线 React-native 应用程序
- go - 禁用选择语句的默认部分
- java - 如何获取地图中特定字段的值
- kubernetes - 如何将微服务与 Kubernetes 集群内的 NATS docker 映像连接起来
- android - 找不到符号导入 com.example.androiddata.databinding.FragmentDetailBindingImpl;
- c# - 如何在同一解决方案 Asp .NET Core 3 中的另一个项目中调用会话变量
- html - 如何在引导程序 4 中将 div 与适当的空间对齐
- flutter - 如何在颤动的文本字段中修剪空白?
- google-sheets - iferror 不返回值/错误消息
- ios - 无法创建自定义视图