Skip to content

Commit b5e833c

Browse files
Merge pull request #3469 from AI-Hypercomputer:igorts/fix_macos
PiperOrigin-RevId: 890048921
2 parents aeb7510 + 3146d46 commit b5e833c

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ tmp/
33
logs/
44
.venvs
55
venv*
6+
maxtext_venv/
67
# Byte-compiled / optimized / DLL files
78
__pycache__/
89
*.py[cod]

build_hooks.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,24 @@ def get_tpu_dependencies():
3333

3434

3535
class CustomBuildHook(BuildHookInterface):
36-
"""A custom hook to inject TPU dependencies into the core wheel dependencies."""
36+
"""A custom hook to handle platform-specific package configuration for MaxText."""
3737

3838
def initialize(self, version, build_data): # pylint: disable=unused-argument
39-
tpu_deps = get_tpu_dependencies()
40-
build_data["dependencies"] = tpu_deps
41-
print(f"Successfully injected {len(tpu_deps)} TPU dependencies into the wheel's core requirements.")
39+
"""Adjusts the build_data dictionary to customize the wheel's package structure."""
40+
41+
# Avoid case-sensitivity issues with `MaxText` and `maxtext` directories on case-insensitive platforms.
42+
build_data["force_include"] = build_data.get("force_include", {})
43+
44+
# Detect case-insensitivity by checking if this file can be accessed via a different case.
45+
# On case-insensitive filesystems flipping the case of the filename still points to the same file.
46+
is_case_insensitive = os.path.exists(__file__.upper()) and os.path.exists(__file__.lower())
47+
48+
if is_case_insensitive:
49+
print("Skipping legacy MaxText shims to avoid case-sensitivity conflicts.")
50+
# Always include the __init__.py in the lowercase 'maxtext'.
51+
# This ensures that 'import maxtext' (and thus 'import MaxText') has the proper version and metadata.
52+
build_data["force_include"]["src/MaxText/__init__.py"] = "maxtext/__init__.py"
53+
else:
54+
# On other platforms, include 'src/MaxText' as its own top-level package for legacy support.
55+
# We do NOT add __init__.py to 'maxtext' here to maintain exact parity with previous builds.
56+
build_data["force_include"]["src/MaxText"] = "MaxText"

docs/install_maxtext.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ uv pip install maxtext[runner]==0.2.1 --resolution=lowest
6161
6262
> **Note:** The maxtext package contains a comprehensive list of all direct and transitive dependencies, with lower bounds, generated by [seed-env](https://github.com/google-ml-infra/actions/tree/main/python_seed_env). We highly recommend the `--resolution=lowest` flag. It instructs `uv` to install the specific, tested versions of dependencies defined by MaxText, rather than the latest available ones. This ensures a consistent and reproducible environment, which is critical for stable performance and for running benchmarks.
6363
64+
> **Note:** MaxText is only tested on Linux during releases.
65+
6466
## From Source
6567

6668
If you plan to contribute to MaxText or need the latest unreleased features, install from source.

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ Repository = "https://github.com/AI-Hypercomputer/maxtext.git"
4040
allow-direct-references = true
4141

4242
[tool.hatch.build.targets.wheel]
43-
packages = ["src/MaxText", "src/maxtext", "src/dependencies"]
43+
packages = ["src/maxtext", "src/dependencies"]
4444

45-
# TODO: Add this hook back when it handles device-type parsing
46-
# [tool.hatch.build.targets.wheel.hooks.custom]
47-
# path = "build_hooks.py"
45+
[tool.hatch.build.targets.wheel.hooks.custom]
46+
path = "build_hooks.py"
4847

4948
[project.scripts]
5049
install_maxtext_tpu_github_deps = "dependencies.github_deps.install_pre_train_deps:main"

0 commit comments

Comments
 (0)