[Python] tox is not installing build requirements

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use tox with a project where some of the requirements need torch to be installed before their installation. To solve this, I tried adding torch as a build requirement.

    A simplified version of my setup looks something like this:

    tox.ini:

    [tox]
    minversion = 4.23.2
    envlist = lint
    isolated_build = true

    [gh-actions]
    python =
    3.12: lint

    [testenv:{lint}]
    commands =
    lint: flake8 src tests


    pyproject.toml:

    [build-system]
    requires = ["setuptools>=42.0,<78.0", "wheel", "torch==2.5.0"]
    build-backend = "setuptools.build_meta"


    setup.cfg:

    [options]
    packages =
    gnnconcepts
    install_requires =
    numpy==2.2.3
    jaxtyping==0.2.36
    wandb>=0.19.3
    tqdm>=4.67.1
    rdkit==2024.9.5
    pandas>=2.2.3
    plotly==5.24.1
    graphium==2.4.7
    scipy==1.13.1
    python_requires = >=3.12
    package_dir =
    =src
    zip_safe = no


    Whenn running tox --recreate --verbose, the console output does imply that the build requirements are being installed

    .pkg: install_requires> python -I -m pip install setuptools<78.0,>=42.0 torch==2.5.0 wheel
    .pkg: exit 0 (31.11 seconds) [PATH TO MY PROJECT]> python -I -m pip install setuptools<78.0,>=42.0 torch==2.5.0 wheel pid=8968


    Nonetheless, installing the requirements fails with

    lint: install_package_deps> python -I -m pip install graphium==2.4.7 jaxtyping==0.2.36 numpy==2.2.3 pandas>=2.2.3 plotly==5.24.1 rdkit==2024.9.5 scipy==1.13.1 tqdm>=4.67.1 wandb>=0.19.3

    [...]

    Collecting torch-sparse>=0.6 (from graphium==2.4.7)
    Using cached torch_sparse-0.6.18.tar.gz (209 kB)
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'error'
    error: subprocess-exited-with-error

    Getting requirements to build wheel did not run successfully.
    exit code: 1

    [20 lines of output]
    Traceback (most recent call last):
    File "C:\Users\jonas\Programmieren\gnn-concepts\.tox\lint\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module>
    main()
    File "C:\Users\jonas\Programmieren\gnn-concepts\.tox\lint\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main
    json_out["return_val"] = hook(**hook_input["kwargs"])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\jonas\Programmieren\gnn-concepts\.tox\lint\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 143, in get_requires_for_build_wheel
    return hook(config_settings)
    ^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\jonas\AppData\Local\Temp\pip-build-env-a4iygx15\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\jonas\AppData\Local\Temp\pip-build-env-a4iygx15\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
    self.run_setup()
    File "C:\Users\jonas\AppData\Local\Temp\pip-build-env-a4iygx15\overlay\Lib\site-packages\setuptools\build_meta.py", line 522, in run_setup
    super().run_setup(setup_script=setup_script)
    File "C:\Users\jonas\AppData\Local\Temp\pip-build-env-a4iygx15\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
    exec(code, locals())
    File "<string>", line 8, in <module>
    ModuleNotFoundError: No module named 'torch'
    [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error

    Getting requirements to build wheel did not run successfully.
    exit code: 1


    Note that 30 seconds to install torch seems suspiciously fast to me (although there might be some caching going on that I am unaware of).

    The most similar issue I could find was this but that didn't really help.

    Continue reading...

Compartilhe esta Página