Skip to content

build from source fails on macos #1241

@chizkiyahu

Description

@chizkiyahu

Describe the bug

Running pip install . on macOS fails with the following error:

running build_py
creating build/lib/tensorflow_model_optimization
error: could not create 'build/lib/tensorflow_model_optimization': Not a directory

System information

  • Operating System: macOS
  • File system: Case-insensitive (default macOS file system)

Root cause

macOS uses a case-insensitive file system by default.
In the repository root, there is a file named BUILD. During the pip install . process, pip attempts to create a directory named build.
Because BUILD and build are treated as the same path on a case-insensitive file system, directory creation fails.

Workaround

Building and installing the package via Bazel works correctly:

git clone https://github.com/tensorflow/model-optimization.git
cd model-optimization

bazel build --copt=-O3 --copt=-march=native :pip_pkg
PKGDIR=$(mktemp -d)
./bazel-bin/pip_pkg "$PKGDIR"
python -m pip install --upgrade "$PKGDIR"/*.whl

Expected behavior

pip install . should succeed on macOS without requiring a Bazel-based workaround.

Additional notes

This issue appears to be specific to case-insensitive file systems and may not reproduce on Linux or on macOS systems configured with a case-sensitive file system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions