我们的项目具有以下高级目录结构*
We have project with the following high-level directory structure*
./datascience/ ├── core │ └── setup.py ├── notebooks │ └── Pipfile └── web └── Pipfile*为简洁起见,排除了所有不相关的文件和目录.
core程序包是一个库.它是notebooks和web应用程序的依赖项.
The core package is a library. It's a dependency of both the notebooks and web applications.
core程序包,是图书馆,其依赖项在setup.py
The core package, being a library, has its dependencies specified in setup.py
import setuptools setuptools.setup( install_requires=[ 'some-dependency', 'another-dependency' ] )web和notebooks应用程序正在使用 pipenv 进行依赖项管理.它们的依赖关系在Pipfile中指定.
The web and notebooks applications are using pipenv for dependency management. Their dependencies are specified in a Pipfile.
例如,下面是在web/Pipfile中指定web依赖项的方式:
For example, here's how the web dependencies are specified in web/Pipfile:
[packages] datascience-core = {path = "./../core"} flask = "~= 1.0"请注意core依赖项是本地依赖项,因此是相对路径.
Notice how the core dependency is a local dependency, hence the relative path.
从web或notebooks目录内部执行pipenv install并不会像我期望的那样安装core库的依赖项!
Doing a pipenv install from inside the the web or notebooks directory, does not install the dependencies of the core library as I expected!
我还尝试对core使用Pipfile,希望pipenv可以在其图形中找到它并下载所有嵌套的依赖项.但事实并非如此.
I also tried using a Pipfile for core, hoping that pipenv would pick it up in its graph and download all the nested dependencies. But it doesn't.
pipenv正在为web或notebooks应用程序安装依赖项时,如何自动安装core应用程序的依赖项?
How can dependencies of the core app be installed automatically when pipenv is installing dependencies for the web or notebooks app?
推荐答案由于在pipenv问题线程中的此注释,找到了一个解决方案: github/pypa/pipenv/issues/209#issuecomment-337409290
Found a solution thanks to this comment in a pipenv issue thread: github/pypa/pipenv/issues/209#issuecomment-337409290
我继续在setup.py中列出core的依赖项.
I've continued listing the core's dependencies in setup.py.
我将web和notebook应用程序更改为使用core软件包的可编辑安装. 这是通过在web和notebooks目录中运行以下命令来完成的:
I've changed the web and notebook apps to use an editable installation of the core package. This was done by running the following in both the web and notebooks directory:
pipenv install --editable ../core它产生了差异
[packages] - datascience-core = {path = "./../core"} + datascience-core = {editable = true,path = "./../core"}现在从web和notebooks目录运行pipenv install会导致core软件包及其依赖项的安装!
Now running pipenv install from the web and notebooks directory results in the installation of the core package and its dependencies!
它还解决了另一个非常烦人的问题,每次core发生变化时,都必须pipenv install.现在,它无需重新安装本地软件包就可以进行开发更改!
It also solved another very annoying problem, which was having to pipenv install every time there was a change in core. Now it picks up development changes without having to re-install the local package!
更多推荐
使用Pipenv安装本地依赖项的依赖项
发布评论