带有conda安装的依赖的setup.py(不是pip) [英] setup.py with dependecies installed by conda (not pip)

查看:704
本文介绍了带有conda安装的依赖的setup.py(不是pip)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用现有的Python 3代码库,该代码库提供了 setup.py ,因此该代码已安装为Python库.我正在尝试安装具有内部依赖关系的内部库(常用的数据科学类,例如 pandas pyodbc sqlalchemy 等).

I am working on an existing Python 3 code-base that provides a setup.py so the code is installed as a Python library. I am trying to get this internal library installed with its own dependencies (the usual data science ones e.g. pandas, pyodbc, sqlalchemy etc).

我想拥有这个内部库来处理这些依赖关系,并假设如果已安装该库,则假定所有传递依赖都已安装.我还想使用该软件包的Anaconda( conda )版本,而不是 pip 版本.

I would like to have this internal library to deal with these dependencies and assume that if that library is installed, then all the transitive dependencies are assumed to be installed. I also would like to have the Anaconda (conda) version of the package rather than the pip version.

我从 requirements.txt 开始,但是很快移到 setup.py 的该字段:

I started with a requirements.txt, but moved quickly to this field in setup.py:

  install_requires=[
      "pyodbc>=4.0.27",
      "sqlalchemy>=1.3.8",
      "pandas>=0.25.1",
      "requests>=2.22.0",
      "assertpy>=0.14",
      "cycler>=0.10.0",
  ]

但是,当我运行安装过程时:

However when I run the installation process:

  • 使用 python setup.py install --record --installed_files.txt
  • 或使用 pip install.

我看到正在进行一些 gcc /C ++编译,显示了有关Python车轮的日志(我不完全了解Python鸡蛋和Python车轮的含义,但是如果conda 可用,那么我应该使用 conda 版本而不是鸡蛋/车轮,因为那样的话,我就不必照顾Python代码下面的C ++代码了.

I see that there is some gcc / C++ compilation going on that shows logs about Python wheels (I don't completely understand the implications of Python eggs and Python wheels, but AFAIK if conda is available then I should go with the conda version rather than eggs/wheels because then I don't have to take care of the C++ code underneath the Python code).

我真的更希望使用 conda 将这些以Python代码包装的C ++ blob安装为库,例如 pandas .

I really would prefer having conda to install these C++ blobs wrapped in some Python code as a libraries e.g. pandas.

  • 是否有可能让 conda 驱动 setup.py 中描述的安装过程,所以我不处理 gcc ?/li>
  • 我如何确保依赖于此内部库(通过 setup.py 安装)的其他Python代码使用的是在 setup.py 中定义的相同(传递)依赖项.代码>?
  • is it possible at all to have conda driving the installation process described in setup.py so I am not dealing with gcc?
  • how can I make sure that other Python code depending on this internal library (installed via setup.py) is using the same (transitive) dependencies defined in that setup.py?

无论安装方法如何,我如何确保例如还安装了 pandas 吗?有时我看到运行 setup.py 时未安装 numpy 作为 pandas 的依赖项,但我想避免手动执行此操作(例如带有一些 requirements.txt 文件).

Regardless the installation method, how can I make sure that the dependencies for e.g. pandas are installed as well? Sometimes I see that numpy as a dependency of pandas is not installed when running setup.py, but I would like to avoid doing this manually (e.g. with some requirements.txt file).

推荐答案

pip 不了解 conda ,因此您无法构建可通过pip安装的软件包来自conda渠道的依赖.

pip doesn't know about conda, so you cannot build a pip-installable package that pulls in its dependencies from conda channels.

conda 不在乎 setup.py ,它使用其他格式来记录依赖项.

conda doesn't care about setup.py, it uses a different format for recording dependencies.

要使用 conda 安装代码,应创建一个conda程序包,并在 meta.yaml 文件中指定依赖项.有关详细信息,请参阅"conda构建"文档.

To install your code with conda, you should create a conda package, and specify your dependencies in a meta.yaml file. Refer to the documentation of "conda build" for details.

https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html

这篇关于带有conda安装的依赖的setup.py(不是pip)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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