anyone had issues with tensorflow on MacOS (M3)? F...
# general
b
anyone had issues with tensorflow on MacOS (M3)? For some reason only on my Mac I get this error:
Copy code
❯ pants run apps/api:dev
14:40:10.06 [INFO] Completed: Building 20 requirements for dev.pex from the python-default.lock resolve: dependency-injector>=4.41.0, elasticsearch>=8.14.0, fastapi>=0.11.0, google-auth>=2.31.0, google-cloud-secret-manager>=2.20.1... (280 characters truncated)
14:40:10.06 [ERROR] 1 Exception encountered:

Engine traceback:
  in `run` goal

ProcessExecutionFailure: Process 'Building 20 requirements for dev.pex from the python-default.lock resolve: dependency-injector>=4.41.0, elasticsearch>=8.14.0, fastapi>=0.11.0, google-auth>=2.31.0, google-cloud-secret-manager>=2.20.1, google-cloud-storage>=2.17.0, httpx>=0.27.0, loguru>=0.7.2, msgpack>=1.0.8, numpy>=1.26.4, pandas>=2.2.2, pydantic>=2.8.2, pytest>=8.2.2, rapidfuzz>=3.9.6, tensorflow-hub==0.15.0, tensorflow==2.15.0, torch>=2.4.0, transformers>=4.42.4, typing-extensions>=4.12.2, uvicorn>=0.30.1' failed with exit code 1.
stdout:

stderr:
Failed to resolve requirements from PEX environment @ /private/var/folders/jr/blmz79xd14dc0q3glpfq24cm0000gn/T/pants-sandbox-vsW7Bw/dev.pex.
Needed cp311-cp311-macosx_14_0_arm64 compatible dependencies for:
 1: tensorflow-macos==2.15.0; platform_system == "Darwin" and platform_machine == "arm64"
    Required by:
      tensorflow 2.15.0
    But this pex had no ProjectName(raw='tensorflow-macos', validated=False, normalized='tensorflow-macos') distributions.



Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
I found this issue on Github: https://github.com/pantsbuild/pants/issues/20134 but it seems the tensorflow team didnt proceed with fixing metadata do we have any workaround?
h
Does your lockfile contain anything for
tensorflow-macos
?
b
not really, I discovered a way of solving this by setting
Copy code
python_requirements(
    name="reqs",
    source="pyproject.toml",
    overrides={
        "tensorflow": {
            "requirements": (
                # Linux or intel Mac
                "tensorflow == 2.15.0 ; sys_platform != 'darwin' or platform_machine == 'x86_64'",
                # Mac M1
                "tensorflow-macos == 2.15.0 ; sys_platform == 'darwin' and platform_machine == 'arm64'",
            ),
        },
    },
)
on the BUILD file
h
Great!