Skip to content

fix(packaging): guard torch extras on intel macos - #2011

Merged
JerrettDavis merged 2 commits into
headroomlabs-ai:mainfrom
ousamabenyounes:fix/issue-1931
Jul 11, 2026
Merged

fix(packaging): guard torch extras on intel macos#2011
JerrettDavis merged 2 commits into
headroomlabs-ai:mainfrom
ousamabenyounes:fix/issue-1931

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Description

Closes #1931

Guard the ml and voice torch optional dependencies on macOS x86_64 so headroom-ai[all] remains resolvable on Intel Macs where PyTorch does not publish compatible wheels for this version floor. The lockfile metadata is updated with the same markers.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring
  • Performance improvement
  • Test update
  • Other

Changes Made

  • Added macOS x86_64 environment markers to torch in the ml and voice extras.
  • Updated uv.lock optional dependency metadata to match the guarded extras.
  • Added a packaging regression test that checks [all] keeps ml and voice while guarding torch on macOS x86_64.

Testing

  • Unit tests pass (pytest)
  • Linting passes (ruff check)
  • Formatting verified (ruff format --check)
  • Manual testing performed

Test Output

$ python3 -m pytest tests/test_optional_dependencies.py -q
collected 1 item

tests/test_optional_dependencies.py .                                    [100%]

============================== 1 passed in 0.26s ===============================

$ .venv/bin/ruff check tests/test_optional_dependencies.py
All checks passed!

$ .venv/bin/ruff format --check tests/test_optional_dependencies.py pyproject.toml
1 file already formatted

Test verification (RED -> GREEN)

RED, with the torch markers temporarily removed from pyproject.toml:

tests/test_optional_dependencies.py F                                    [100%]
FAILED tests/test_optional_dependencies.py::test_all_extra_does_not_require_torch_on_macos_x86_64
E   assert False

GREEN, with this patch applied:

tests/test_optional_dependencies.py .                                    [100%]
============================== 1 passed in 0.26s ===============================

Real Behavior Proof

  • Environment: Linux, Python 3.12.3, pytest 9.1.1, ruff 0.14.14.
  • Exact command / steps: Removed the environment markers from torch, ran the new packaging test, restored the markers, and reran the test plus targeted ruff checks.
  • Observed result: The test fails without the macOS x86_64 guard and passes once the ml and voice torch requirements are guarded.
  • Not tested: Full uv run pytest, full-project uv run ruff check ., full-project uv run ruff format --check ., and uv run mypy headroom were not run locally for this targeted packaging change.

Review Readiness

  • I have performed a self-review
  • This PR is ready for human review

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective
  • New and existing targeted tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable)

N/A

Additional Notes

No new dependency is added; this only narrows when the existing torch optional dependency is selected.

@github-actions

Copy link
Copy Markdown
Contributor

PR governance

This PR follows the template and is marked ready for human review.

@github-actions github-actions Bot added the status: ready for review Pull request body is complete and the author marked it ready for human review label Jul 10, 2026

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the targeted fix and tests. The local checks pass, but this does not fully solve #1931 for headroom-ai[all] on Intel macOS.

The direct torch entries in [ml] and [voice] are guarded, but [all] still expands to [memory] and [evals], and both include sentence-transformers. In the lock metadata, sentence-transformers has an unguarded dependency on torch (uv.lock has name = "sentence-transformers" with { name = "torch" } under that package), so an Intel macOS [all] resolve can still reach torch transitively.

I verified this from the PR branch with a resolver-style check against pyproject.toml: for sys_platform=darwin and platform_machine=x86_64, [all] still selects sentence-transformers=True and datasets=True, while only direct torch=False. That leaves the original failure path open.

Passing local checks:

  • python -m pytest tests/test_optional_dependencies.py -q
  • python -m ruff check tests/test_optional_dependencies.py
  • python -m ruff format --check tests/test_optional_dependencies.py pyproject.toml
  • git diff --check headroomlabs/main...HEAD

Please update the fix to guard the torch-bearing extras from [all] on Intel macOS, or otherwise prove the full transitive [all] resolve no longer selects torch there.

@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Addressed the remaining Intel macOS [all] path. [memory] and [evals] now guard sentence-transformers with the same darwin/x86_64 exclusion, and uv.lock metadata reflects that [all] no longer selects the torch-bearing sentence-transformers dependency on Intel macOS.\n\nChecks:\n- RED: python3 -m pytest tests/test_optional_dependencies.py -q before the fix -> [all] selected sentence-transformers from the locked torch-bearing set\n- GREEN: python3 -m pytest tests/test_optional_dependencies.py -q -> 1 passed\n- uv run ruff check tests/test_optional_dependencies.py\n- uv run ruff format --check tests/test_optional_dependencies.py pyproject.toml\n- git diff --check upstream/main...HEAD

@github-actions github-actions Bot removed the status: ready for review Pull request body is complete and the author marked it ready for human review label Jul 11, 2026

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. The Intel macOS [all] path is covered: direct torch extras are guarded, and the torch-bearing sentence-transformers entries from [memory] and [evals] are also excluded for darwin/x86_64.

Verified locally:

  • uv run pytest tests/test_optional_dependencies.py -q -> 1 passed
  • uv run ruff check tests/test_optional_dependencies.py
  • uv run ruff format --check tests/test_optional_dependencies.py pyproject.toml
  • git diff --check FETCH_HEAD...HEAD

CI is green as well.

@JerrettDavis
JerrettDavis merged commit fd0d29c into headroomlabs-ai:main Jul 11, 2026
51 checks passed
@chopratejas chopratejas mentioned this pull request Jul 11, 2026
6 tasks
LunarECL added a commit to LunarECL/headroom that referenced this pull request Jul 13, 2026
`headroom wrap omp` lazily imports yaml to parse and merge omp's
models.yml registry, but pyyaml was never declared, so a bare
`pip install headroom-ai` (no extras) fails at wrap time with
ModuleNotFoundError. Dev and test environments masked this: pyyaml
arrives transitively through dev/ml extras (pre-commit, transformers).

CI surfaced it as the lint failure on the merge commit: the lint job
installs no project dependencies, so mypy flags the yaml import as
import-untyped (typeshed publishes stubs for it).

- pyproject.toml: add pyyaml>=6.0 to core dependencies
- uv.lock: surgically add pyyaml to the headroom-ai dependencies and
  requires-dist metadata (same approach as headroomlabs-ai#2011; a full `uv lock`
  regeneration would undo that PR's intel-mac torch guard)
- omp/runtime.py: annotate the import with type: ignore[import-untyped]
  following the psutil precedent (the lint env installs no deps)
JerrettDavis pushed a commit to peterlodri-sec/headroom that referenced this pull request Jul 14, 2026
## Description

Closes headroomlabs-ai#1931

Guard the `ml` and `voice` `torch` optional dependencies on macOS x86_64
so `headroom-ai[all]` remains resolvable on Intel Macs where PyTorch
does not publish compatible wheels for this version floor. The lockfile
metadata is updated with the same markers.

## Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Documentation update
- [ ] Refactoring
- [ ] Performance improvement
- [ ] Test update
- [ ] Other

## Changes Made

- Added macOS x86_64 environment markers to `torch` in the `ml` and
`voice` extras.
- Updated `uv.lock` optional dependency metadata to match the guarded
extras.
- Added a packaging regression test that checks `[all]` keeps `ml` and
`voice` while guarding `torch` on macOS x86_64.

## Testing

- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check`)
- [x] Formatting verified (`ruff format --check`)
- [ ] Manual testing performed

### Test Output

```text
$ python3 -m pytest tests/test_optional_dependencies.py -q
collected 1 item

tests/test_optional_dependencies.py .                                    [100%]

============================== 1 passed in 0.26s ===============================

$ .venv/bin/ruff check tests/test_optional_dependencies.py
All checks passed!

$ .venv/bin/ruff format --check tests/test_optional_dependencies.py pyproject.toml
1 file already formatted
```

## Test verification (RED -> GREEN)

RED, with the `torch` markers temporarily removed from `pyproject.toml`:

```text
tests/test_optional_dependencies.py F                                    [100%]
FAILED tests/test_optional_dependencies.py::test_all_extra_does_not_require_torch_on_macos_x86_64
E   assert False
```

GREEN, with this patch applied:

```text
tests/test_optional_dependencies.py .                                    [100%]
============================== 1 passed in 0.26s ===============================
```

## Real Behavior Proof

- Environment: Linux, Python 3.12.3, pytest 9.1.1, ruff 0.14.14.
- Exact command / steps: Removed the environment markers from `torch`,
ran the new packaging test, restored the markers, and reran the test
plus targeted ruff checks.
- Observed result: The test fails without the macOS x86_64 guard and
passes once the `ml` and `voice` `torch` requirements are guarded.
- Not tested: Full `uv run pytest`, full-project `uv run ruff check .`,
full-project `uv run ruff format --check .`, and `uv run mypy headroom`
were not run locally for this targeted packaging change.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have added tests that prove my fix is effective
- [x] New and existing targeted tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream
modules

## Screenshots (if applicable)

N/A

## Additional Notes

No new dependency is added; this only narrows when the existing `torch`
optional dependency is selected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Dependency resolution fails installing headroom-ai[all]==0.31.0 on macOS 15 x86_64 due to missing torch wheels for macosx_15_0_x86_64

2 participants