ali5h / rules_pip

pip package rules for bazel that are fast (incremental fetch), support different python versions and work with all kinds of packages (i.e. packages with namespaces)
MIT License
60 stars 23 forks source link

defer requirement() failure until build time #51

Closed dae closed 3 years ago

dae commented 3 years ago

I'd like to use select() to conditionally include dependencies depending on platform, eg a py_binary with

deps = select({ "@bazel_tools//src/conditions:host_windows": [ requirement("psutil"), requirement("pywin32"), ], "//conditions:default": [], })

Currently this doesn't work, as requirement() is executed on all platforms. This patch changes requirement() to return an invalid key instead of using fail(), which will allow such usages of select(). If the user specifies a requirement that was not listed in the requirements file, they should still get an error at build time which identifies the missing package.