Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid bazel installation? #560

Open
adamjstewart opened this issue Mar 8, 2024 · 6 comments
Open

How to avoid bazel installation? #560

adamjstewart opened this issue Mar 8, 2024 · 6 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request New feature or request

Comments

@adamjstewart
Copy link

This may come counter to everything this repo stands for, but here it goes anyway...

I'm a developer for the Spack package manager. I'm trying to build a package (tensorstore) which uses bazelisk. However, Spack has a couple constraints that make it difficult to use bazelisk:

  1. We need to be able to build on air-gapped networks, so we can't download things during build-time
  2. We need to use Spack's compiler wrappers, which require environment variables, which bazel purges

Spack has its own bazel recipe, which patches bazel to avoid unsetting these environment variables. However, tensorstore uses bazelisk which downloads and installs its own copy of bazel, so even if I add a dependency on bazel, it's skipped.

Is there a way to tell bazelisk not to do anything and just use a pre-installed bazel from the PATH? Or an env var I can set to tell it to do this? Or is it possible to tell bazel not to unset all env vars?

@tgamblin

@brentleyjones
Copy link

The USE_BAZEL_VERSION environment variable (which can also be set in .bazeliskrc) can point to a path instead of a version number. It won't download anything in that case.

@adamjstewart
Copy link
Author

Unfortunately this didn't work. The code failed on this line:

  Traceback (most recent call last):
    File "/tmp/adam/spack-stage/spack-stage-py-tensorstore-0.1.54-qt43dqks2rfboadkdose2dbxwfl5u47w/spack-src/bazelisk.py", line 492, in <module>
      sys.exit(main())
    File "/tmp/adam/spack-stage/spack-stage-py-tensorstore-0.1.54-qt43dqks2rfboadkdose2dbxwfl5u47w/spack-src/bazelisk.py", line 477, in main
      bazel_path = get_bazel_path()
    File "/tmp/adam/spack-stage/spack-stage-py-tensorstore-0.1.54-qt43dqks2rfboadkdose2dbxwfl5u47w/spack-src/bazelisk.py", line 470, in get_bazel_path
      return download_bazel_into_directory(bazel_version, is_commit, bazel_directory)
    File "/tmp/adam/spack-stage/spack-stage-py-tensorstore-0.1.54-qt43dqks2rfboadkdose2dbxwfl5u47w/spack-src/bazelisk.py", line 294, in download_bazel_into_directory
      bazel_filename = determine_bazel_filename(version)
    File "/tmp/adam/spack-stage/spack-stage-py-tensorstore-0.1.54-qt43dqks2rfboadkdose2dbxwfl5u47w/spack-src/bazelisk.py", line 216, in determine_bazel_filename
      supported_machines = get_supported_machine_archs(version, operating_system)
    File "/tmp/adam/spack-stage/spack-stage-py-tensorstore-0.1.54-qt43dqks2rfboadkdose2dbxwfl5u47w/spack-src/bazelisk.py", line 237, in get_supported_machine_archs
      major, minor = int(versions[0]), int(versions[1])
  ValueError: invalid literal for int() with base 10: '/home/adam/spack/opt/spack/linux-ubuntu22'

The only thing I've found that works so far is to create a symlink in tools/bazel that points to the bazel installation I would like to use.

@jbms
Copy link
Contributor

jbms commented Mar 10, 2024

It looks like the Python implementation does not support USE_BAZEL_VERSION being a path to a binary, but the go implementation does. It would probably make sense to fix the Python implementation.

@meteorcloudy meteorcloudy added P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request New feature or request labels Mar 26, 2024
@meteorcloudy
Copy link
Member

Please migrate to the go version

@jbms
Copy link
Contributor

jbms commented Mar 26, 2024

The tensorstore project uses a copy of Python bazelisk in its repository in order to avoid the need for users building it to install or even know about bazel when building the Python package.

In order to use the go bazelisk for the same purpose we would need a way to bootstrap it, which would basically amount to a python bazeliskisk that is similar to the existing Python bazelisk except it downloads go bazelisk binaries instead of bazel binaries. That would be added complexity for no real benefit.

In principle a Python pypi package version of the go bazelisk would also work, and would have some advantages, though embedding the Python bazelisk is hard to beat in convenience and reliability.

@meteorcloudy
Copy link
Member

Unfortunately, the Bazel team currently doesn't have capacity to maintain the python version of Bazelisk. But happy to take contributions from the community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants