Skip to content

Commit

Permalink
Set PIP_* env vars for outputs/script (#5368)
Browse files Browse the repository at this point in the history
* Set PIP_* env vars for outputs/script

* Add test

* add news
  • Loading branch information
isuruf committed Jun 21, 2024
1 parent 4457362 commit ee7d0ce
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
20 changes: 13 additions & 7 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,7 @@ def bundle_conda(
env_output["RECIPE_DIR"] = metadata.path
env_output["MSYS2_PATH_TYPE"] = "inherit"
env_output["CHERE_INVOKING"] = "1"
_set_env_variables_for_build(metadata, env_output)
for var in utils.ensure_list(metadata.get_value("build/script_env")):
if "=" in var:
val = var.split("=", 1)[1]
Expand Down Expand Up @@ -3060,13 +3061,7 @@ def construct_metadata_for_test(recipedir_or_package, config):
return m, hash_input


def write_build_scripts(m, script, build_file):
# TODO: Prepending the prefixes here should probably be guarded by
# if not m.activate_build_script:
# Leaving it as is, for now, since we need a quick, non-disruptive patch release.
with utils.path_prepended(m.config.host_prefix, False):
with utils.path_prepended(m.config.build_prefix, False):
env = environ.get_dict(m=m)
def _set_env_variables_for_build(m, env):
env["CONDA_BUILD_STATE"] = "BUILD"

# hard-code this because we never want pip's build isolation
Expand Down Expand Up @@ -3098,6 +3093,17 @@ def write_build_scripts(m, script, build_file):
if "replacements" in env:
del env["replacements"]


def write_build_scripts(m, script, build_file):
# TODO: Prepending the prefixes here should probably be guarded by
# if not m.activate_build_script:
# Leaving it as is, for now, since we need a quick, non-disruptive patch release.
with utils.path_prepended(m.config.host_prefix, False):
with utils.path_prepended(m.config.build_prefix, False):
env = environ.get_dict(m=m)

_set_env_variables_for_build(m, env)

work_file = join(m.config.work_dir, "conda_build.sh")
env_file = join(m.config.work_dir, "build_env_setup.sh")
with open(env_file, "w") as bf:
Expand Down
19 changes: 19 additions & 0 deletions news/5368-pip-outputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* PIP_* env variables are set when building outputs in multi-output recipes. (#3993 via #5368)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

out_path = os.path.join(os.environ['PREFIX'], 'subpackage_file_1')

assert "PIP_NO_INDEX" in os.environ

with open(out_path, 'w') as f:
f.write("weeee")

Expand Down

0 comments on commit ee7d0ce

Please sign in to comment.