如何破解 Anaconda3 Python 的 conda 以忽略包依赖项?修改了 conda-meta 包 JSON dependent flag,但是还不够

发布于 2025-01-10 20:14:40 字数 1338 浏览 0 评论 0原文

好吧,我有一个包 Pythran,它是一个 Python 到 C++(PYD 模块)编译器。 conda-forge 上的软件包本身表示它需要 clangclangxx。但我已经安装了 MS Build Tools clang-12,因此根本不使用这些包。

现在,每次我去 conda install [package_name] 时,它都会告诉我我的环境不一致,因为我通过 a 强制删除了我不需要(或想要)的 clang 库:

conda remove clang clangxx clang-13 --force

所以我环顾四周有点在安装东西。我发现有一个 \Anaconda3\conda-meta\pythran-0.11.0-py39h832f523_0.json (注意版本更改后的名称)...

所以我向上打开该文件,向下滚动到:

 "depends": [
    "beniget 0.4.*",
    "decorator",
    "gast 0.5.*",
    "numpy >=1.19.5,<2.0a0",
    "ply >=3.4",
    "python >=3.9,<3.10.0a0",
    "python_abi 3.9.* *_cp39",
    "xsimd >=8.0.5,<8.1"
  ],

其中包含这些条目,我手动删除了它:

"clang",
"clangxx",

所以现在当我运行 conda 时,它不再说我的环境不一致了。但是,当我尝试添加包时,它坚持安装clangclang-13clangxx

有人有办法完全消除这些依赖吗?我想也许它指的是在线文件而不是本地文件,因为我删除了那些必需的库。我运行了命令提示符: findstr /S /C:'clang' * 这就像从 Linux 中调用 grep 一样。它显示了在某处引用 clang 的所有文件。除了我已经删除的内容之外,它没有在任何地方被引用,因此我很困惑。

是的,我知道像 conda 这样的包管理器应该确保您的环境正常运行。但我可以将 Python 编译为 C++ 到 PYD(模块),在缺少这些 clang 库的情况下完全没有问题。因为我的路径中已经有 clang-12 。这比其他任何事情都更令人烦恼,因为每个软件包安装/升级都一直想要安装不需要的 clang-13 库......

Alright I have a package Pythran which is a Python to C++ (PYD module) complier. The package itself on conda-forge says it requires clang and clangxx. BUT I have MS Build Tools clang-12 already installed, so these packages are not used at all.

Now every time I go to conda install [package_name] it tells me my environment is inconsistent, because I force removed the clang libraries I don't need (or want) via a:

conda remove clang clangxx clang-13 --force

So I looked around a bit at the installation of things. And I found that there is a \Anaconda3\conda-meta\pythran-0.11.0-py39h832f523_0.json (note the name after the version changes)...

So I opened that file up, scrolled down to:

 "depends": [
    "beniget 0.4.*",
    "decorator",
    "gast 0.5.*",
    "numpy >=1.19.5,<2.0a0",
    "ply >=3.4",
    "python >=3.9,<3.10.0a0",
    "python_abi 3.9.* *_cp39",
    "xsimd >=8.0.5,<8.1"
  ],

Which had these entries, which I manually removed:

"clang",
"clangxx",

So now when I go to run conda it doesn't say my environment is inconsistent anymore. However, when I try to add a package, it insists on installing clang, clang-13, clangxx.

Anyone have a way to completely remove these dependencies? I think maybe it's referring to files online rather than local, since I deleted those required libraries. I ran a command prompt: findstr /S /C:'clang' * which is like calling grep from Linux. It shows all the files that reference clang somewhere. It isn't referenced anywhere other than what I deleted already, hence my confusion.

Yes I understand these package managers like conda are supposed to ensure your environment works. But I can compile Python to C++ to PYD (modules) no problem at all with these clang libraries missing. Since I already have clang-12 in the path. This is more of an annoyance than anything else, as every package install / upgrade keeps wanting to install clang-13 libraries that aren't needed...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

优雅的叶子 2025-01-17 20:14:40

虚拟软件包

更简洁的解决方案是创建一个虚拟软件包,可以将其安装作为系统上已存在相应软件的指示器。这就是 Conda Forge 提供的功能对于 mpich。具体来说,他们提供了外部构建(请参阅recipe),该版本随

conda install 'mpich=*=external_*'

创建 clang 虚拟包

一起安装对于您想要的自定义配置,请创建您自己的 clang 虚拟版本并clangxx 包将满足要求并将其安装到环境中。类似于

meta.yaml

{% set version = "12.0.1" %}
{% set build = 0 %}

package:
  name: clang-dummies
  version: {{ version }}

build:
  number: {{ build }}

outputs:
  - name: clang
    string: external_{{ build }}
  - name: clangxx
    string: external_{{ build }}

about:
  license: GPL-3.0-only
  summary: Dummy package for external clang(xx) compiler.

构建此 (conda build .) 后,您可以使用 Anaconda Cloud 用户通道安装这些本地版本

conda install --use-local 'clang=12=external*' 'clangxx=12=external*'

或将它们上传到用户 Anaconda Cloud 通道。

Dummy Packages

The cleaner solution is to create a dummy package that one can install as an indicator that the corresponding software is already available on the system. This is what Conda Forge provides for the mpich package. Specifically, they provide an external build (see recipe), that one installs with

conda install 'mpich=*=external_*'

Creating clang Dummy Packages

For custom configurations like what you want, create your own dummy version of the clang and clangxx packages that would satisfy the requirements and install them to the environment. Something like

meta.yaml

{% set version = "12.0.1" %}
{% set build = 0 %}

package:
  name: clang-dummies
  version: {{ version }}

build:
  number: {{ build }}

outputs:
  - name: clang
    string: external_{{ build }}
  - name: clangxx
    string: external_{{ build }}

about:
  license: GPL-3.0-only
  summary: Dummy package for external clang(xx) compiler.

After building this (conda build .), you can install these local versions with

conda install --use-local 'clang=12=external*' 'clangxx=12=external*'

or upload them to a user Anaconda Cloud channel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文