Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install cmake using conda by default #2379

Closed
wants to merge 8 commits into from
Closed

Conversation

guru-desh
Copy link
Contributor

This PR simplifies the build setup process by installing cmake via conda.

Current Behavior:

In the build.sh script, this if statement exists:

if [ -z "`which cmake`" ] || [ "`which cmake`" = "cmake not found" ]; then
  conda install cmake -y
fi

If cmake does not exist on the machine used to build coremltools, then cmake will be installed via conda. BUILDING.md states that the user needs to install cmake. However, if the build.sh script already installs cmake then the following refactor can be done:

  1. Install cmake by default into the conda environment
  2. Remove the requirement for the user to install cmake outside of the coremltools build

New Behavior:

  1. This env_create.sh script installs cmake via the anaconda channel.
  2. The CMake requirement is removed from the requirements section (the user who builds the project no longer needs to install cmake themselves)

This refactor makes it so that the user no longer needs to install cmake before building coremltools (as the build itself will install cmake via conda)

Checks

Running ./scripts/build.sh --python=3.8 created a working build for me locally, but I'm not sure how to run the GitLab CI job. Could I get some help on that? Thanks in advance :)

@YifanShenSZ YifanShenSZ self-requested a review November 1, 2024 22:22
@YifanShenSZ
Copy link
Collaborator

YifanShenSZ commented Nov 1, 2024

Nice catch 🚀 When I added conda install cmake -y to build.sh I forgot to update doc 😅 Thanks for reflecting that in doc!

That being said, could you please elaborate on the motivation for "move conda install to env_create.sh" change? Imho I would prefer to keep it in build.sh, because "install after env got created" will work for env-tweaking cases, e.g. Rosetta

CONDA_SUBDIR=osx-64 conda create -p envs/coremltools-py3.7 -y
conda activate envs/coremltools-py3.7
conda config --env --set subdir osx-64
conda install python=3.7 -y

@guru-desh
Copy link
Contributor Author

could you please elaborate on the motivation for "move conda install to env_create.sh" change?

This was a pure refactoring change. In build.sh, I saw that the majority of the steps build.sh are build-specific steps like setting up the cmake commands and running make, and the conda install -y cmake command doesn't seem like a build-related step but more of an environment config step. This is why I moved it to env_create.sh.

In addition, if conda install -y cmake was in build.sh, then dependency management becomes harder as the dependency of cmake is specified not in env_create.sh but in build.sh, which should not add environment dependencies.

Imho I would prefer to keep it in build.sh, because "install after env got created" will work for env-tweaking cases, e.g. Rosetta

Could you explain what "env-tweaking cases" are? Why can't the env-tweaking cases be done in the env_create.sh script?

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