0

Following this numpy installation question, I'd failed to install numpy with pip command on mingw64 windows 10. While building my project with bazel, I've dependency on numpy, so other alternative approach I'd followed is to install numpy via pacman package.

I created a numpy-test.py to check if this works, and it ran successfully.

While building my project bazel tries to build wheel and install numpy again, probably using the pip way and I know this fails:

ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects

How to specify Bazel to not build numpy again and use pacman installed numpy. BUILD file :

py_wheel(
    name = "my_wheel",
    distribution = "my",
    python_tag = "py3",
    version = "0.0.1",
    deps = [
        ":my_pkg",
    ],
    requires = [
        "appdirs",
        "importlib_resources",
        "matplotlib",
        "numpy",
        "psutil",
        "PyGObject",
        "pyyaml",
        "more_itertools",
        "termcolor",
    ],
    entry_points = {
        'gui_scripts': [
            'my-gui = my.main:main',
        ],
        'console_scripts': [
            'my_parser = example.my_parser:console_entry',
        ],
    }
)

Installed python and pip details :

pip version 23.1.2 from C:/msys64/mingw64/lib/python3.10/site-packages/pip (python 3.10)
Python 3.10.11 [GCC 12.2.0 64 bit (AMD64)] on win32

requirements.txt file used in pip_deps contain:

importlib-resources==5.8.0
matplotlib
numpy==1.23.1
platformdirs==2.5.2
psutil==5.9.1
pycairo==1.21.0
PyGObject==3.44.1
pyparsing==3.0.9
pytest==7.1.2
pytest-qt
PyYAML==6.0
appdirs
pytest-xvfb
termcolor
more-itertools

and also how to know what python and pip is used by Bazel during this BUILD process?

  • 1
    If I understood it correctly, you wanted to use system numpy instead of installing it aging. If yes, you can create .bazelrc file and add `build --define=numpy=numpy` in that file. By this, Bazel will use system numpy package instead of trying to build it again. Hope this will help! If you want to know more about .bazelrc configuration, please follow this [doc](https://bazel.build/run/bazelrc) – Pavan Singh Jun 19 '23 at 05:25
  • Thanks @PavanSingh, can you provide more details. I've numpy wheels in my system Python's site-packages folder, now when bazel runs pip_install requirements it does so with --isolated flag, this causes numpy to redownload and tries to build wheel again (direct building numpy causes error, so want to avoid it). What I want bazel is to reuse numpy from my Python's site-packages without downloading & building it again. – Swaminath Bera Jul 03 '23 at 05:48
  • You can use --python_path, Bazel will use the specified Python interpreter instead of creating it. By this, Bazel will reuse the existing NumPy installation from your Python's site-packages folder, avoiding the need to download and build it again. How to give Python interpreter, can be found here: https://stackoverflow.com/questions/67512066/how-do-i-select-the-runtime-in-bazel-for-python-and-pip – Pavan Singh Jul 04 '23 at 06:41
  • @PavanSigh This doesn't work, Bazel is using system's python but Bazel adds --isolated flag when doing pip install. – Swaminath Bera Jul 06 '23 at 08:59

0 Answers0