Home > Blockchain >  How to hack conda for Anaconda3 Python to ignore package dependencies? Modified conda-meta package J
How to hack conda for Anaconda3 Python to ignore package dependencies? Modified conda-meta package J

Time:03-02

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...

CodePudding user response:

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.

  • Related