Closed wsoesanto-arbo closed 3 hours ago
This is failing because it is trying to build a wheel as there are no wheels available on PyPI. The workaround for this would be to build a wheel for hnswlib
separately upload it to an internal PyPI mirror, recompile the requirements.txt
so that the built wheel is available and then add download_only = True
to pip_parse
to ensure that only wheels are being used.
May I know why it works when I don't set such attribute then?
This is because when you don't set the attribute, it uses the system-wide python installation and it could be working because you may have all of the dependencies for building the wheel already installed on your system.
Repository rules are non-hermetic and in general produce different results on different machines.
On 6 October 2023 12:54:31 GMT+09:00, Willy Soesanto @.***> wrote:
May I know why it works when I don't set such attribute then?
-- Reply to this email directly or view it on GitHub: https://github.com/bazelbuild/rules_python/issues/1463#issuecomment-1749947921 You are receiving this because you commented.
Message ID: @.***>
After further investigation, I notice that it is using clang
to build the wheel instead of cc
or g++
. I wonder if it is something that we can configure in the hermetic python toolchain.
The command above works after I install clang
, llvm
and create a symlink of binaries in the expected location of the compilation.
Basically the following command.
sudo apt install clang llvm
We also encountered this issue when adding the yubikey-manager
package to the list of requirements in our requirements file.
requirements.txt
yubikey-manager>=5,<6
sw/requirements_lock.txt
pyscard==2.0.7 \
--hash=sha256:06666a597e1293421fa90e0d4fc2418add447b10b7dc85f49b3cafc23480f046 \
--hash=sha256:278054525fa75fbe8b10460d87edcd03a70ad94d688b11345e4739987f85c1bf \
--hash=sha256:2d4bdc1f4e0e6c46e417ac1bc9d5990f7cfb24a080e890d453781405f7bd29dc \
--hash=sha256:39e030c47878b37ae08038a917959357be6468da52e8b144e84ffc659f50e6e2 \
--hash=sha256:59a466ab7ae20188dd197664b9ca1ea9524d115a5aa5b16b575a6b772cdcb73c \
--hash=sha256:5a5865675be294c8d91f22dc91e7d897c4138881e5295fb6b2cd821f7c0389d9 \
--hash=sha256:8e37b697327e8dc4848c481428d1cbd10b7ae2ce037bc799e5b8bbd2fc3ab5ed \
--hash=sha256:a0c5edbedafba62c68160884f878d9f53996d7219a3fc11b1cea6bab59c7f34a \
--hash=sha256:a2266345bd387854298153264bff8b74f494581880a76e3e8679460c1b090fab \
--hash=sha256:beacdcdc3d1516e195f7a38ec3966c5d4df7390c8f036cb41f6fef72bc5cc646 \
--hash=sha256:da70aa5b7be5868b88cdb6d4a419d2791b6165beeb90cd01d2748033302a0f43 \
--hash=sha256:f704ad40dc40306e1c0981941789518ab16aa1f84443b1d52ec0264884092b3b
# via yubikey-manager
yubikey-manager==5.3.0 \
--hash=sha256:5492c36a10ce6a5995b8ea1d32cf5bd60db7587201b2aa3e63e0c1da2334b8b6 \
--hash=sha256:9a809620f5c910c1047323570095e10b885002f6b0a2e4d8ced7f62d7c2ce628
# via -r bazel_requirements.txt
WORKSPACE
pip_parse(
name = "astranis_deps",
python_interpreter_target = interpreter,
requirements_lock = "//sw:requirements_lock.txt",
)
load("@astranis_deps//:requirements.bzl", "install_deps")
install_deps()
produces the below error:
Error in fail: whl_library astranis_deps_pyscard failed: Collecting pyscard==2.0.7 (from -r /tmp/tmpw4ottrd5 (line 1))
Downloading pyscard-2.0.7.tar.gz (152 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 152.3/152.3 kB 5.7 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: pyscard
Building wheel for pyscard (setup.py): started
Building wheel for pyscard (setup.py): finished with status 'error'
Running setup.py clean for pyscard
Failed to build pyscard
( error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [13 lines of output]
running bdist_wheel
running build
running build_py
running build_ext
building 'smartcard.scard._scard' extension
swigging smartcard/scard/scard.i to smartcard/scard/scard_wrap.c
swig -python -outdir smartcard/scard -DPCSCLITE -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
creating build
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/smartcard
creating build/temp.linux-x86_64-cpython-38/smartcard/scard
clang -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -I/tools/deps/libedit/include -g0 -fPIC -DVER_PRODUCTVERSION=2,0,7,0000 -DVER_PRODUCTVERSION_STR=2.0.7 -DPCSCLITE=1 -Ismartcard/scard/ -I/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/include/python3.8 -c smartcard/scard/helpers.c -o build/temp.linux-x86_64-cpython-38/smartcard/scard/helpers.o -pthread -I/usr/include/PCSC
error: command 'clang' failed: No such file or directory
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyscard
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/rules_python/python/pip_install/tools/wheel_installer/wheel_installer.py", line 205, in <module>
main()
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/rules_python/python/pip_install/tools/wheel_installer/wheel_installer.py", line 190, in main
subprocess.run(pip_args, check=True, env=env)
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/bin/python3', '-m', 'pip', '--isolated', 'wheel', '--no-deps', '-r', '/tmp/tmpw4ottrd5']' returned non-zero exit status 1.
) error code: '1'
ERROR: /github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/astranis_deps/pyscard/BUILD.bazel:13:6: @astranis_deps//pyscard:whl depends on @astranis_deps_pyscard//:whl in repository @astranis_deps_pyscard which failed to fetch. no such package '@astranis_deps_pyscard//': whl_library astranis_deps_pyscard failed: Collecting pyscard==2.0.7 (from -r /tmp/tmpw4ottrd5 (line 1))
Downloading pyscard-2.0.7.tar.gz (152 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 152.3/152.3 kB 5.7 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: pyscard
Building wheel for pyscard (setup.py): started
Building wheel for pyscard (setup.py): finished with status 'error'
Running setup.py clean for pyscard
Failed to build pyscard
( error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [13 lines of output]
running bdist_wheel
running build
running build_py
running build_ext
building 'smartcard.scard._scard' extension
swigging smartcard/scard/scard.i to smartcard/scard/scard_wrap.c
swig -python -outdir smartcard/scard -DPCSCLITE -o smartcard/scard/scard_wrap.c smartcard/scard/scard.i
creating build
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/smartcard
creating build/temp.linux-x86_64-cpython-38/smartcard/scard
clang -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -I/tools/deps/libedit/include -g0 -fPIC -DVER_PRODUCTVERSION=2,0,7,0000 -DVER_PRODUCTVERSION_STR=2.0.7 -DPCSCLITE=1 -Ismartcard/scard/ -I/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/include/python3.8 -c smartcard/scard/helpers.c -o build/temp.linux-x86_64-cpython-38/smartcard/scard/helpers.o -pthread -I/usr/include/PCSC
error: command 'clang' failed: No such file or directory
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyscard
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/rules_python/python/pip_install/tools/wheel_installer/wheel_installer.py", line 205, in <module>
main()
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/rules_python/python/pip_install/tools/wheel_installer/wheel_installer.py", line 190, in main
subprocess.run(pip_args, check=True, env=env)
File "/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/github/home/.cache/bazel/_bazel_root/818c72ad5a3a83f42a3d6f48674a13b0/external/python3_8_x86_64-unknown-linux-gnu/bin/python3', '-m', 'pip', '--isolated', 'wheel', '--no-deps', '-r', '/tmp/tmpw4ottrd5']' returned non-zero exit status 1.
) error code: '1'
ERROR: Analysis of target '//:modules_map' failed; build aborted:
INFO: Elapsed time: 8.807s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (857 packages loaded, 35050 targets configured)
Unfortunately, pyscard
doesn't distribute a wheel that is compatible with Linux.
We ended up adding extra arguments to the call to pip_parse
in order to avoid this problem. Namely, we added extra arguments to:
CC=gcc
as an environment variable. We couldn't avoid doing this because pyscard
doesn't distribute an appropriate wheel.--only-binary
argument for yubikey-manager
directly to Pip so that Pip uses wheels for yubikey-manager
.WORKSPACE
pip_parse(
name = "astranis_deps",
environment = {"CC": "gcc"},
extra_pip_args = [
"--only-binary",
"yubikey-manager",
],
python_interpreter_target = interpreter,
requirements_lock = "//sw:requirements_lock.txt",
)
load("@astranis_deps//:requirements.bzl", "install_deps")
install_deps()
Clearly, this isn't ideal.
--prefer-binary
argument in order to tell Pip to prefer binary packages over source packages more holistically, but the resulting CI run was unacceptably slow. Is there another approach to preferring binary packages over source packages without CI grinding to a halt?
- Is there a better way of managing the installation of packages that must be built using source packages?
You can consider pre-building wheels for your target platform(s) and hosting them on your own artifact repository such as Artifactory, AWS CodeArtifact, GCP Artifact Registry, GCP Assured OSS Software, S3 bucket etc. Then "pin" or "lock" your dependencies against wheels in pip using --index https://foo --only-binary=:all:
2. Is there another approach to preferring binary packages over source packages without CI grinding to a halt?
Likely similar to above. Any resolution algorithm will try to backtrack to find wheels if none exist. This is likely slow unless you can short-circuit and give it some wheels to find using techniques as above.
An entirely different approach could be for you to consider using alternative rules such as rules_pycross, which aims to support building from sdist
inside bazel actions using native toolchains.
None of this is an easy problem, because Python package management is essentially eval setup.py
so there isn't a general solution. Only solutions that sometimes appear to work more than others.
It looks like #824 is tracking adding support for building C/C++ extensions. Perhaps another possible approach would be to build the missing wheels directly in Bazel? I haven't looked into how feasible that approach is at this time or how much of a lift it would be, though.
I spent some time yesterday attempting to get pyscard
to build under pycross, but:
It's probably solvable, but I stopped there. Welcome to sdist building, I guess.
Just echoing that I'm also unable to configure pcsclite on my Ubuntu host. Bootstrap errors out:
$ ./bootstrap
+ test -f Makefile
+ rm -rf autom4te.cache aclocal.m4 config.guess config.log config.status config.sub depcomp ltmain.sh
+ autoreconf --verbose --install
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
autoreconf: configure.ac: not using Intltool
autoreconf: configure.ac: not using Gtkdoc
autoreconf: running: aclocal -I m4
autoreconf: running: /usr/bin/autoconf
configure.ac:52: error: possibly undefined macro: AC_MSG_ERROR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:59: error: possibly undefined macro: AC_DEFINE
autoreconf: error: /usr/bin/autoconf failed with exit status: 1
Sigh...
Edit: I had to do
sudo apt install autoconf-archive
to run ./bootstrap
successfully and
sudo apt install flex libsystemd-dev
for ./configure
. Now the error in ./configure
is:
configure: error:
***
*** polkit >= 0.111 was not found. Access control will be disabled.
*** You may get it from http://www.freedesktop.org/software/polkit/
***
and sudo apt install policykit-1 policykit-1-gnome
doesn't resolve it. Maybe polkit
is its own rabbit hole...
I think in these scenarios, the best option is generally to work with and support the upstream package (eg pcslite) to fix packaging errors or make their packages easier to build. It may also be possible to get them to publish wheels using projects like https://github.com/pypa/cibuildwheel
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"
🐞 bug report
Affected Rule
The issue is caused by the rule:
pip_parse
Is this a regression?
Not certain.
Description
I am getting compilation error when it's trying to build wheel dependency.
It doesn't throw an error when I left out
python_interpreter_target
attribute ofpip_parse
.🔬 Minimal Reproduction
Repository link can be seen here: https://github.com/wsoesanto-arbo/rules_python-pipcompile
WORKSPACE
BUILD
requirements.in
requirements.txt
🔥 Exception or Error
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_python version:
Anything else relevant?
Nothing else. Please do let me know if I can provide more information.