Skip to content

Uninstall the PyPI keras so CI only imports the checkout - #73

Open
MarcosAsh wants to merge 5 commits into
mainfrom
install-keras-checkout
Open

MarcosAsh wants to merge 5 commits into
mainfrom
install-keras-checkout

Conversation

@MarcosAsh

@MarcosAsh MarcosAsh commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

tensorflow and keras-mlx both pull keras in from PyPI, and that one has no mlx backend. This uninstalls it after installing keras-mlx, so if anything ends up importing keras from outside the checkout it fails instead of quietly running the wrong one.

numerical_test.py still needs PYTHONPATH=. since running a script puts its own folder on sys.path, not the cwd.

@hertschuh hertschuh left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should find a good pattern and do it across the repos.

A couple of questions:

  • What problem is this addressing?
  • Why did you need PYTHONPATH=. for the numerical test and not the other one?

My idea was to not install keras so that you would know that it's using the local source, which is why keras is not in requirements.txt, which is a little weird in some way.

What I didn't realize is that pip install -e . would install keras. But that's solvable.

  • We can do pip uninstall keras after
  • We can do pip install --no-deps -e . in the keras_mlx folder
  • We can do pip install -e . in the keras folder first so that keras is already installed, but that might have some caveats

I'm not a big fan of this

import os, keras; assert os.path.realpath(keras.__file__).startswith(os.path.realpath('../keras'))

I'd rather make sure keras is not installed at all. But again, I'm not sure why you needed PYTHONPATH=.

@MarcosAsh

Copy link
Copy Markdown
Collaborator Author

Thanks for the review! The PyPI keras comes from tensorflow. pytest from ./keras gets the checkout because the cwd is on its path, but running numerical_test.py directly doesn't, so it picked up PyPI keras instead. I'll switch to --no-deps plus pip uninstall -y keras and drop the assert, makes sense to keep keras uninstalled.

@MarcosAsh MarcosAsh changed the title Install the keras checkout so every step imports it Uninstall the PyPI keras so CI only imports the checkout Oct 2, 2026
@hertschuh

Copy link
Copy Markdown
Contributor

I'll switch to --no-deps plus pip uninstall -y keras and drop the assert, makes sense to keep keras uninstalled.

I don't think you need both. The bulleted list was list of options to pick one from.

@MarcosAsh

Copy link
Copy Markdown
Collaborator Author

Ah got it, I read it as steps! Kept just the uninstall, tensorflow already pulls keras in from the requirements before keras-mlx gets installed, so --no-deps on its own wouldn't change anything. Just pushed.

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.

2 participants