Skip to content

Commit

Permalink
[SCons] Redirect conda destination if 'stage_dir' is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Feb 11, 2022
1 parent 1632f99 commit 30e90fc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ except subprocess.CalledProcessError:
env["git_commit"] = "unknown"

# Print values of all build options:
# the (updated) "cantera.conf" combines all options that were specified by the user
cantera_conf = Path("cantera.conf").read_text()
logger.info("Configuration variables read from 'cantera.conf' and command line:")
logger.info(textwrap.indent(cantera_conf, " "), print_level=False)
Expand Down Expand Up @@ -1644,15 +1645,14 @@ env['debian'] = any(name.endswith('dist-packages') for name in sys.path)

# Check whether Cantera should be installed into a conda environment
if conda_prefix is not None:
if env["layout"] != "conda":
if env["layout"] != "conda" and sys.executable.startswith(conda_prefix):
# identify options selected either on command line or in cantera.conf
selected_options = set(line.split("=")[0].strip()
for line in cantera_conf.splitlines())
use_conda = (
not selected_options &
{"layout", "prefix", "python_prefix", "python_cmd"})
use_conda &= sys.executable.startswith(conda_prefix)
if use_conda:
blocking_options = {
"layout", "prefix", "python_prefix", "python_cmd"}
# use conda layout unless any 'blocking' options were specified
if not selected_options & blocking_options:
env["layout"] = "conda"
logger.info(
f"Using conda environment as default 'prefix': {conda_prefix}")
Expand All @@ -1662,7 +1662,7 @@ elif env["layout"] == "conda":

# Directories where things will be after actually being installed. These
# variables are the ones that are used to populate header files, scripts, etc.
if env["layout"] == "conda":
if env["layout"] == "conda" and not env["stage_dir"]:
env["prefix"] = os.path.normpath(conda_prefix)

if env["layout"] == "conda" and os.name == "nt":
Expand Down

0 comments on commit 30e90fc

Please sign in to comment.