pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Failed to auto resolve `pixi add --pypi av` after specifying python==3.7.6

Open guoh064 opened this issue 8 months ago • 6 comments

Checks

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

Commands I ran and their output:

pixi add --pypi av

Error:   × failed to solve the pypi requirements of environment 'default' for platform 'linux-64'
  ├─▶ failed to resolve pypi dependencies
  ├─▶ Failed to download and build `av==10.0.0`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
      
      [stdout]
      pkg-config is required for building PyAV
      
      hint: This usually indicates a problem with the package or the build environment.

pixi.toml/pyproject.toml file that reproduces my issue:

[workspace]
channels = ["conda-forge"]
name = "test"
platforms = ["linux-64"]
version = "0.1.0"

[tasks]

[dependencies]
python = "==3.7.6"

pixi info output:

System
------------
       Pixi version: 0.66.0
        TLS backend: rustls
           Platform: linux-64
   Virtual packages: __unix=0=0
                   : __linux=6.6.87.2=0
                   : __glibc=2.39=0
                   : __cuda=12.8=0
                   : __archspec=1=icelake
          Cache dir: /home/guoh064/.cache/rattler/cache
       Auth storage: /home/guoh064/.rattler/credentials.json
   Config locations: No config files found

Global
------------
            Bin dir: /home/guoh064/.pixi/bin
    Environment dir: /home/guoh064/.pixi/envs
       Manifest dir: /home/guoh064/.pixi/manifests/pixi-global.toml

Workspace
------------
               Name: test
            Version: 0.1.0
      Manifest file: /home/guoh064/test/pixi.toml
       Last updated: 01-04-2026 17:56:13

Environments
------------
        Environment: default
           Features: default
           Channels: conda-forge
   Dependency count: 1
       Dependencies: python
   Target platforms: linux-64
    Prefix location: /home/guoh064/test/.pixi/envs/default

Other files (e.g. script files, source files, etc.):

Issue description

For some reason I need to import av in my python script under python==3.7.6. Since I do not want to disrupt my working machine (which is WSL2 Ubuntu 24.04.1), I tried to handle everything in pixi. However I was warned that pkg-config is required for building PyAV since the solved version av==10.0.0 has no usable wheels at hand.

According to PyAV documentation (which sadly does not have one for av=10.0.0, what I can find is either >=11 or <10), to build it one needs:

PyAV depends upon several libraries from FFmpeg:
- libavcodec
- libavdevice
- libavfilter
- libavformat
- libavutil
- libswresample
- libswscale
and a few other tools in general:
- pkg-config
- Python’s development headers

Since I was hoping pixi to do all the work for me, I have to try to make it work for myself.

What I have tried (in following consequent steps):

  1. barely pixi add --pypi av, which results in the error above.
  2. pixi add pkg-config which adds pkg-config >= 0.29.2,<0.30, and then pixi add --pypi av, which results in pyav packages not found.
  3. pixi add ffmpeg which adds ffmpeg >=5.1.0,<6, and then pixi add --pypi av, which results in stdout saying "Compiling av/logging.pyx because it changed" and stderr saying
av/logging.pyx:216:22: Cannot assign type 'const char *(void *) except? NULL nogil' to 'const char *(*)(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to the type of 'log_context_name'.
  1. pixi add --pypi "av<9", which does no more trigger compiling av's pyx files, but now errors "No such file or directory: 'gcc'"
  2. pixi add gcc and then pixi add --pypi "av<9", which errors that
guoh064@guoh064-SLS:~/test$ pixi add --pypi "av<9"
Error:   × Failed to update PyPI packages for environment 'default'
  ├─▶ Failed to prepare distributions
  ├─▶ Failed to build `av==8.1.0`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
      
      [stdout]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      running config
      PyAV: 8.1.0 (unknown commit)
      Python: 3.7.6 | packaged by conda-forge | (default, Jun  1 2020, 18:57:50) \n[GCC 7.5.0]
      platform: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-debian-trixie-sid
      extension_extra:
        include_dirs: [b'include', b'/home/guoh064/test/.pixi/envs/default/include']
        libraries: [b'avformat', b'avcodec', b'avdevice', b'avutil', b'avfilter', b'swscale', b'swresample']
        library_dirs: [b'/home/guoh064/test/.pixi/envs/default/lib']
        define_macros: []
        runtime_library_dirs: []
      config_macros:
        PYAV_COMMIT_STR="unknown-commit"
        PYAV_VERSION=8.1.0
        PYAV_VERSION_STR="8.1.0"
      writing build/temp.linux-x86_64-cpython-37/include/pyav/config.h
      running cythonize
      building 'av.format' extension
      gcc -pthread -B /home/guoh064/test/.pixi/envs/default/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iinclude -I/home/guoh064/.cache/rattler/cache/uv-cache/builds-v0/.tmpmJpen6/include
      -Ibuild/temp.linux-x86_64-cpython-37/include -I/home/guoh064/test/.pixi/envs/default/include -I/home/guoh064/test/.pixi/envs/default/include/python3.7m -I/home/guoh064/.cache/rattler/cache/uv-cache/builds-v0/.tmpmJpen6/include -I/home/guoh064/
      test/.pixi/envs/default/include/python3.7m -Ibuild/temp.linux-x86_64-cpython-37/include -c src/av/format.c -o build/temp.linux-x86_64-cpython-37/src/av/format.o
      
      [stderr]
      In file included from src/av/format.c:63:
      /home/guoh064/test/.pixi/envs/default/include/python3.7m/Python.h:44:10: fatal error: crypt.h: No such file or directory
         44 | #include <crypt.h>
            |          ^~~~~~~~~
      compilation terminated.
      error: command '/home/guoh064/test/.pixi/envs/default/bin/gcc' failed with exit code 1
      
      hint: This error likely indicates that you need to install a library that provides "crypt.h" for `[email protected]`
  1. pixi add libxcrypt and then pixi add --pypi "av<9", which errors
guoh064@guoh064-SLS:~/test$ pixi add --pypi "av<9"
Error:   × Failed to update PyPI packages for environment 'default'
  ├─▶ Failed to prepare distributions
  ├─▶ Failed to build `av==8.1.0`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
      
      [stdout]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      running config
      PyAV: 8.1.0 (unknown commit)
      Python: 3.7.6 | packaged by conda-forge | (default, Jun  1 2020, 18:57:50) \n[GCC 7.5.0]
      platform: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-debian-trixie-sid
      extension_extra:
        include_dirs: [b'include', b'/home/guoh064/test/.pixi/envs/default/include']
        libraries: [b'avformat', b'avcodec', b'avdevice', b'avutil', b'avfilter', b'swscale', b'swresample']
        library_dirs: [b'/home/guoh064/test/.pixi/envs/default/lib']
        define_macros: []
        runtime_library_dirs: []
      config_macros:
        PYAV_COMMIT_STR="unknown-commit"
        PYAV_VERSION=8.1.0
        PYAV_VERSION_STR="8.1.0"
      writing build/temp.linux-x86_64-cpython-37/include/pyav/config.h
      running cythonize
      building 'av.format' extension
      gcc -pthread -B /home/guoh064/test/.pixi/envs/default/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibuild/temp.linux-x86_64-cpython-37/include -I/home/guoh064/test/.pixi/envs/default/
      include/python3.7m -I/home/guoh064/.cache/rattler/cache/uv-cache/builds-v0/.tmpdMmXSM/include -Iinclude -I/home/guoh064/test/.pixi/envs/default/include -I/home/guoh064/.cache/rattler/cache/uv-cache/builds-v0/.tmpdMmXSM/include -I/home/guoh064/
      test/.pixi/envs/default/include/python3.7m -Ibuild/temp.linux-x86_64-cpython-37/include -c src/av/format.c -o build/temp.linux-x86_64-cpython-37/src/av/format.o
      gcc -pthread -shared -B /home/guoh064/test/.pixi/envs/default/compiler_compat -L/home/guoh064/test/.pixi/envs/default/lib -Wl,-rpath=/home/guoh064/test/.pixi/envs/default/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-cpython-37/
      src/av/format.o -L/home/guoh064/test/.pixi/envs/default/lib -lswresample -lavdevice -lavutil -lswscale -lavformat -lavcodec -lavfilter -o build/lib.linux-x86_64-cpython-37/av/format.cpython-37m-x86_64-linux-gnu.so
      
      [stderr]
      src/av/format.c: In function '__pyx_pf_2av_6format_15ContainerFormat___cinit__':
      src/av/format.c:1927:24: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       1927 |     __pyx_v_self->iptr = av_find_input_format(__pyx_t_5);
            |                        ^
      src/av/format.c:1965:24: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       1965 |     __pyx_v_self->optr = av_guess_format(__pyx_t_6, NULL, NULL);
            |                        ^
      /home/guoh064/test/.pixi/envs/default/compiler_compat/ld: cannot find /lib64/libc.so.6: No such file or directory
      /home/guoh064/test/.pixi/envs/default/compiler_compat/ld: cannot find /usr/lib64/libc_nonshared.a: No such file or directory
      collect2: error: ld returned 1 exit status
      error: command '/home/guoh064/test/.pixi/envs/default/bin/gcc' failed with exit code 1
      
      hint: This usually indicates a problem with the package or the build environment.

At this stage I feel tired, so I do not try more.

Expected behavior

If somehow building the binary is necessary, automatically do the resolving steps for me including adding depencencies and pypi dependencies.

guoh064 avatar Apr 01 '26 10:04 guoh064

For some reason I need to import av in my python script under python==3.7.6

Can you explain why this is the case? Python 3.7 reached its EOL (it's no longer supported) Python Releases.

bpythonistic avatar Apr 01 '26 19:04 bpythonistic

Can you explain why this is the case? Python 3.7 reached its EOL (it's no longer supported) Python Releases.

We were trying to recreate the building environment for the repository LmeSzinc/AzurLaneAutoScript, which was created about 7 years ago and continues to update. However the repo author cannot update dependencies due to heavy usage of old OCR model in requirements-in.txt, namely (in my opinion) cnocr==1.2.2 and mxnet==1.6.0.

I think using pixi add av==10.0.0 numpy==1.16.6 will somehow work for the moment, but I am not sure if a better solution exists.

guoh064 avatar Apr 01 '26 21:04 guoh064

Maybe we could have some predefined set of packages for building binaries on a platform and suggest to add that on build failures? At least that could help with the "what do I need to add" problem.

hunger avatar Apr 10 '26 09:04 hunger

It was not trivial but I got av to build on linux-64 using:

[dependencies]
python = "==3.7.6"
setuptools = ">=69.0.3,<70"
cython = ">=0.29.32,<0.30"
pkg-config = ">=0.29.2,<0.30"
ffmpeg = ">=5.1.0,<6"
wheel = ">=0.42.0,<0.43"

[pypi-dependencies]
av = "*"

[pypi-options]
no-build-isolation = ["av"]

The key was to add no-build-isolation and then adding all required build dependencies.

@guoh064 Does that help?

baszalmstra avatar May 01 '26 11:05 baszalmstra

@guoh064 gentle ping!

baszalmstra avatar Jun 12 '26 09:06 baszalmstra

Thanks for the ping!

For the solution you provided: no, I think not so easy, because it happens that my isolated environment has no gcc installed at first (which I think should also be part of the environment requirements, if not for global requirement)

Currently it says:

guoh064@guoh064-SLS:~/test$ pixi install
Error:   × Failed to update PyPI packages for environment 'default'
  ├─▶ Failed to prepare distributions
  ├─▶ Failed to build `av==8.1.0`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
      
      [stdout]
      running bdist_wheel
      running build
      running build_py
      copying av/deprecation.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/datasets.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/__init__.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/__main__.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/filter/__init__.py -> build/lib.linux-x86_64-cpython-37/av/filter
      copying av/sidedata/__init__.py -> build/lib.linux-x86_64-cpython-37/av/sidedata
      copying av/codec/__init__.py -> build/lib.linux-x86_64-cpython-37/av/codec
      copying av/container/__init__.py -> build/lib.linux-x86_64-cpython-37/av/container
      copying av/data/__init__.py -> build/lib.linux-x86_64-cpython-37/av/data
      copying av/subtitles/__init__.py -> build/lib.linux-x86_64-cpython-37/av/subtitles
      copying av/audio/__init__.py -> build/lib.linux-x86_64-cpython-37/av/audio
      copying av/video/__init__.py -> build/lib.linux-x86_64-cpython-37/av/video
      running build_ext
      running config
      PyAV: 8.1.0 (unknown commit)
      Python: 3.7.6 | packaged by conda-forge | (default, Jun  1 2020, 18:57:50) \n[GCC 7.5.0]
      platform: Linux-6.18.33.1-microsoft-standard-WSL2-x86_64-with-debian-trixie-sid
      extension_extra:
        include_dirs: [b'include', b'/home/guoh064/test/.pixi/envs/default/include']
        libraries: [b'avformat', b'avcodec', b'avdevice', b'avutil', b'avfilter', b'swscale', b'swresample']
        library_dirs: [b'/home/guoh064/test/.pixi/envs/default/lib']
        define_macros: []
        runtime_library_dirs: []
      config_macros:
        PYAV_COMMIT_STR="unknown-commit"
        PYAV_VERSION=8.1.0
        PYAV_VERSION_STR="8.1.0"
      writing build/temp.linux-x86_64-cpython-37/include/pyav/config.h
      running cythonize
      building 'av.format' extension
      gcc -pthread -B /home/guoh064/test/.pixi/envs/default/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iinclude -Ibuild/temp.linux-x86_64-cpython-37/include -I/home/guoh064/test/.pixi/envs/
      default/include/python3.7m -I/home/guoh064/test/.pixi/envs/default/include -I/home/guoh064/test/.pixi/envs/default/include/python3.7m -Ibuild/temp.linux-x86_64-cpython-37/include -c src/av/format.c -o build/temp.linux-x86_64-cpython-37/src/av/
      format.o
      
      [stderr]
      error: command 'gcc' failed: No such file or directory: 'gcc'
      
      hint: This usually indicates a problem with the package or the build environment.

Then adding gcc = "*" to dependencies will cause a hint that requires crypt.h, which I thought was similar to previous try:

guoh064@guoh064-SLS:~/test$ pixi install
Error:   × Failed to update PyPI packages for environment 'default'
  ├─▶ Failed to prepare distributions
  ├─▶ Failed to build `av==8.1.0`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
      
      [stdout]
      running bdist_wheel
      running build
      running build_py
      copying av/deprecation.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/datasets.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/__init__.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/__main__.py -> build/lib.linux-x86_64-cpython-37/av
      copying av/filter/__init__.py -> build/lib.linux-x86_64-cpython-37/av/filter
      copying av/sidedata/__init__.py -> build/lib.linux-x86_64-cpython-37/av/sidedata
      copying av/codec/__init__.py -> build/lib.linux-x86_64-cpython-37/av/codec
      copying av/container/__init__.py -> build/lib.linux-x86_64-cpython-37/av/container
      copying av/data/__init__.py -> build/lib.linux-x86_64-cpython-37/av/data
      copying av/subtitles/__init__.py -> build/lib.linux-x86_64-cpython-37/av/subtitles
      copying av/audio/__init__.py -> build/lib.linux-x86_64-cpython-37/av/audio
      copying av/video/__init__.py -> build/lib.linux-x86_64-cpython-37/av/video
      running build_ext
      running config
      PyAV: 8.1.0 (unknown commit)
      Python: 3.7.6 | packaged by conda-forge | (default, Jun  1 2020, 18:57:50) \n[GCC 7.5.0]
      platform: Linux-6.18.33.1-microsoft-standard-WSL2-x86_64-with-debian-trixie-sid
      extension_extra:
        include_dirs: [b'include', b'/home/guoh064/test/.pixi/envs/default/include']
        libraries: [b'avformat', b'avcodec', b'avdevice', b'avutil', b'avfilter', b'swscale', b'swresample']
        library_dirs: [b'/home/guoh064/test/.pixi/envs/default/lib']
        define_macros: []
        runtime_library_dirs: []
      config_macros:
        PYAV_COMMIT_STR="unknown-commit"
        PYAV_VERSION=8.1.0
        PYAV_VERSION_STR="8.1.0"
      writing build/temp.linux-x86_64-cpython-37/include/pyav/config.h
      running cythonize
      building 'av.format' extension
      gcc -pthread -B /home/guoh064/test/.pixi/envs/default/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/guoh064/test/.pixi/envs/default/include -I/home/guoh064/test/.pixi/envs/default/
      include/python3.7m -Iinclude -Ibuild/temp.linux-x86_64-cpython-37/include -I/home/guoh064/test/.pixi/envs/default/include/python3.7m -Ibuild/temp.linux-x86_64-cpython-37/include -c src/av/format.c -o build/temp.linux-x86_64-cpython-37/src/av/
      format.o
      
      [stderr]
      In file included from src/av/format.c:63:
      /home/guoh064/test/.pixi/envs/default/include/python3.7m/Python.h:44:10: fatal error: crypt.h: No such file or directory
         44 | #include <crypt.h>
            |          ^~~~~~~~~
      compilation terminated.
      error: command '/home/guoh064/test/.pixi/envs/default/bin/gcc' failed with exit code 1
      
      hint: This error likely indicates that you need to install a library that provides "crypt.h" for `[email protected]`

I really hate it when I have to use sudo apt-get install <something> to make sure the environment works.

guoh064 avatar Jun 12 '26 09:06 guoh064