@@ -29,17 +29,43 @@ def install
2929 # Create Python virtual environment inside libexec (inside Cellar for proper bottling)
3030 venv = libexec /"venv"
3131 system Formula [ "[email protected] " ] . opt_bin /
"python3.12" , "-m" , "venv" , venv 32- system venv /"bin/pip" , "install" , "--upgrade" , "pip" , "setuptools" , "wheel"
32+ system venv /"bin/pip" , "install" , "--upgrade" , "pip" , "setuptools" , "wheel" , "setuptools-scm"
3333
3434 # Install Cantera from PyPI using pre-built wheel (complex package, doesn't need custom flags)
3535 # Cantera has CMake compatibility issues when building from source with newer CMake versions
36- system venv /"bin/pip" , "install" , "cantera==3.1.0"
36+ # Match the version constraint from toolchain/pyproject.toml
37+ system venv /"bin/pip" , "install" , "--only-binary=:all:" , "cantera>=3.1.0"
3738
3839 # Install MFC Python package and dependencies into venv
3940 # Use editable install (-e) to avoid RECORD file issues when venv is symlinked at runtime
4041 # Dependencies will use pre-built wheels from PyPI
4142 # Keep toolchain in buildpath for now - mfc.sh needs it there
42- system venv /"bin/pip" , "install" , "-e" , buildpath /"toolchain"
43+ #
44+ # MFC's toolchain uses VCS-derived versioning (via Hatch/hatch-vcs) and Homebrew builds from
45+ # GitHub release tarballs without a .git directory. Scope pretend-version env vars tightly
46+ # to avoid polluting subsequent pip installs.
47+ pretend_env = {
48+ "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC" => version . to_s ,
49+ "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc" => version . to_s ,
50+ "SETUPTOOLS_SCM_PRETEND_VERSION" => version . to_s , # Fallback for hatch-vcs/setuptools-scm
51+ }
52+ saved_env = { }
53+ pretend_env . each do |k , v |
54+ saved_env [ k ] = ENV . fetch ( k , nil )
55+ ENV [ k ] = v
56+ end
57+
58+ begin
59+ system venv /"bin/pip" , "install" , "-e" , buildpath /"toolchain"
60+ ensure
61+ pretend_env . each_key do |k |
62+ if saved_env [ k ] . nil?
63+ ENV . delete ( k )
64+ else
65+ ENV [ k ] = saved_env [ k ]
66+ end
67+ end
68+ end
4369
4470 # Create symlink so mfc.sh uses our pre-installed venv
4571 mkdir_p "build"
0 commit comments