使用Pipenv安装本地依赖项的依赖项 [英] Installing dependencies of a local dependency with pipenv

查看:945
本文介绍了使用Pipenv安装本地依赖项的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目具有以下高级目录结构*

We have project with the following high-level directory structure*

./datascience/
├── core
│   └── setup.py
├── notebooks
│   └── Pipfile
└── web
    └── Pipfile

*为简洁起见,排除了所有不相关的文件和目录.

core程序包是一个库.它是notebooksweb应用程序的依赖项.

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'
    ]
)

webnotebooks应用程序正在使用 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.

webnotebooks目录内部执行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正在为webnotebooks应用程序安装依赖项时,如何自动安装core应用程序的依赖项?

How can dependencies of the core app be installed automatically when pipenv is installing dependencies for the web or notebooks app?

推荐答案

由于在pipenv问题线程中的此注释,找到了一个解决方案:

Found a solution thanks to this comment in a pipenv issue thread: https://github.com/pypa/pipenv/issues/209#issuecomment-337409290

我继续在setup.py中列出core的依赖项.

I've continued listing the core's dependencies in setup.py.

我将webnotebook应用程序更改为使用core软件包的可编辑安装.
这是通过在webnotebooks目录中运行以下命令来完成的:

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"}

现在从webnotebooks目录运行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安装本地依赖项的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆