Skip to content

Commit 3d8293b

Browse files
authored
Refactor pip install commands in mfc.rb
1 parent cf30bbc commit 3d8293b

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

Formula/mfc.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ def install
2929
# Create Python virtual environment inside libexec (inside Cellar for proper bottling)
3030
venv = libexec/"venv"
3131
system Formula["python@3.12"].opt_bin/"python3.12", "-m", "venv", venv
32-
3332
system venv/"bin/pip", "install", "--upgrade",
3433
"pip", "setuptools", "wheel",
3534
"setuptools-scm",
3635
"hatchling", "hatch-vcs",
3736
"editables"
38-
3937
# Install Cantera from PyPI using pre-built wheel (complex package, doesn't need custom flags)
4038
# Cantera has CMake compatibility issues when building from source with newer CMake versions
4139
# Match the version constraint from toolchain/pyproject.toml
@@ -47,8 +45,9 @@ def install
4745
# Keep toolchain in buildpath for now - mfc.sh needs it there
4846
#
4947
# MFC's toolchain uses VCS-derived versioning (via Hatch/hatch-vcs) and Homebrew builds from
50-
# GitHub release tarballs without a .git directory. Scope pretend-version env vars tightly
51-
# to avoid polluting subsequent pip installs.
48+
# GitHub release tarballs without a .git directory. Use --no-build-isolation so the build
49+
# backend can see our environment variables, and set SETUPTOOLS_SCM_PRETEND_VERSION which
50+
# hatch-vcs respects when VCS metadata is unavailable.
5251
pretend_env = {
5352
"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC" => version.to_s,
5453
"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc" => version.to_s,
@@ -61,7 +60,7 @@ def install
6160
end
6261

6362
begin
64-
system venv/"bin/pip", "install", "-e", buildpath/"toolchain"
63+
system venv/"bin/pip", "install", "--no-build-isolation", "-e", buildpath/"toolchain"
6564
ensure
6665
pretend_env.each_key do |k|
6766
if saved_env[k].nil?
@@ -79,7 +78,12 @@ def install
7978
# Now build MFC with pre-configured venv
8079
# Set VIRTUAL_ENV so mfc.sh uses existing venv instead of creating new one
8180
ENV["VIRTUAL_ENV"] = venv
82-
81+
82+
# Also set pretend-version env vars for mfc.sh in case it tries to reinstall toolchain
83+
ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC"] = version.to_s
84+
ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc"] = version.to_s
85+
ENV["SETUPTOOLS_SCM_PRETEND_VERSION"] = version.to_s
86+
8387
# Build MFC using pre-configured venv
8488
# Must run from buildpath (MFC root directory) where toolchain/ exists
8589
Dir.chdir(buildpath) do
@@ -349,4 +353,4 @@ def caveats
349353
assert_path_exists testpath_case/"silo_hdf5"
350354
assert_predicate testpath_case/"silo_hdf5", :directory?
351355
end
352-
end
356+
end

0 commit comments

Comments
 (0)