purple-umbrella-89891
05/31/2023, 2:29 PMtorch
version to be installed in the user's venv, in order to link against it. Besides radical solutions like patching the sdist, is there a way to tell pants to inject a dependency in the build environment of a package? In runtime, anything missing can be specified using python_requirement(..., dependencies=[...])
(which is a huge help due to other problematic packages!), however there is no build_dependencies
or similar argument where I could specify ":requirements#torch"
. Does any solution/workaround come to mind?lively-gpu-26436
05/31/2023, 2:33 PMpurple-umbrella-89891
05/31/2023, 2:40 PMmanylinux
wheel for it. However it's a bit cumbersome and in the general case requires automation of such wheel builds.
Our current workaround is a small patch to the sdist, which adds the build dependency (PEP-517). Even though the sdist works for all, since it's not yet linked to any libraries, it's still an additional step.lively-gpu-26436
05/31/2023, 2:42 PMpurple-umbrella-89891
05/31/2023, 2:51 PMenough-analyst-54434
05/31/2023, 2:55 PM[build-system] requires = [...]
? You'd then just switch to a VCS requirement.enough-analyst-54434
05/31/2023, 2:55 PMenough-analyst-54434
05/31/2023, 2:56 PMenough-analyst-54434
05/31/2023, 2:58 PMpurple-umbrella-89891
05/31/2023, 3:01 PMpyproject.toml
would also work. My sdist patch is the same and the two solutions are more or less equivalent functionally. I opted to use sdists with a local version identifier, e.g. 0.6+2c6c380f94
, as detectron2 has not updated the version for years and it is useful to have the git hash of the public repo, instead of the changed hash after applying the patch in the fork.enough-analyst-54434
05/31/2023, 3:01 PMenough-analyst-54434
05/31/2023, 3:02 PMenough-analyst-54434
05/31/2023, 3:02 PMenough-analyst-54434
05/31/2023, 3:03 PMpurple-umbrella-89891
05/31/2023, 3:03 PMenough-analyst-54434
05/31/2023, 3:04 PMpurple-umbrella-89891
05/31/2023, 3:05 PMpurple-umbrella-89891
05/31/2023, 3:08 PM--config-settings
? Currently my requirements.txt
needs to look like this:
detectron2 >= 0.6 --config-settings torch_version=1.12.1+cu113
torch == 1.12.1+cu113
If I set a range for torch
and regenerate the lockfile, the versions will mismatch. Could I somehow supply a pants target there (:requirements#torch
)?purple-umbrella-89891
05/31/2023, 3:08 PM--config-settings
and relock to have the versions matchenough-analyst-54434
05/31/2023, 3:08 PMpyproject.toml
with:
[build-system]
requires = ["torch", "setuptools"]
build-backend = "setuptools.build_meta"
2. Now use a requirements like detectron2 @ git+<https://github.com/my-fork/detectron2@abcd1234>
enough-analyst-54434
05/31/2023, 3:09 PMenough-analyst-54434
05/31/2023, 3:11 PMenough-analyst-54434
05/31/2023, 3:12 PMgit+
purple-umbrella-89891
05/31/2023, 3:12 PMenough-analyst-54434
05/31/2023, 3:13 PMpurple-umbrella-89891
05/31/2023, 3:13 PMfrom setuptools.build_meta import __legacy__ as l
from functools import partial
def _get_requires(config_settings=None, legacy_func=None):
if config_settings:
return ["setuptools>=40.8.0", "wheel", f"torch=={config_settings['torch_version']}"]
return legacy_func()
# PEP 517
build_wheel = l.build_wheel
build_sdist = l.build_sdist
prepare_metadata_for_build_wheel = l.prepare_metadata_for_build_wheel
get_requires_for_build_sdist = partial(_get_requires, legacy_func=l.get_requires_for_build_sdist)
get_requires_for_build_wheel = partial(_get_requires, legacy_func=l.get_requires_for_build_wheel)
# PEP 660
build_editable = l.build_editable
prepare_metadata_for_build_editable = l.prepare_metadata_for_build_editable
get_requires_for_build_editable = partial(_get_requires, legacy_func=l.get_requires_for_build_editable)
(in case anyone wants to experiment until I submit a PR and it is merged)purple-umbrella-89891
05/31/2023, 3:16 PMenough-analyst-54434
05/31/2023, 3:17 PM--config-settings torch_version=1.12.1+cu113
bit often? If not you could just kill it, kill all the shenanigans you have to go through above in a custom build backend wrapper and just say requires = ["torch=1.12.1+cu113", "setuptools"]
and be done with it.purple-umbrella-89891
05/31/2023, 3:19 PMenough-analyst-54434
05/31/2023, 3:19 PMenough-analyst-54434
05/31/2023, 3:20 PMenough-analyst-54434
05/31/2023, 3:20 PMpurple-umbrella-89891
05/31/2023, 3:20 PMpurple-umbrella-89891
05/31/2023, 3:21 PMancient-breakfast-45303
05/31/2023, 3:21 PMenough-analyst-54434
05/31/2023, 3:24 PMenough-analyst-54434
05/31/2023, 3:25 PM--par
by EOD will you do it?enough-analyst-54434
05/31/2023, 3:26 PMpurple-umbrella-89891
05/31/2023, 3:28 PMancient-breakfast-45303
05/31/2023, 3:31 PMancient-breakfast-45303
05/31/2023, 3:32 PMancient-breakfast-45303
05/31/2023, 3:32 PMpurple-umbrella-89891
05/31/2023, 3:35 PM