将git repo(编译并使用pip安装)包含到setup.py

时间:2020-03-31 12:20:17

标签: python setuptools setup.py pypi

仅在尚未安装软件包的情况下,如何才能在从源代码编译的setup.py安装函数中包括git repo?

我有来自此instalation manual的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 ../..

背景

This this问题/答案提出了一种通过带有run方法的类将自定义安装命令引入setup.py中的setup函数的方法。我假设在自定义安装脚本下面的代码中,它在检查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}))

0 个答案:

没有答案
相关问题