Skip to content

Commit b68ad6d

Browse files
authored
Merge pull request #2791 from regro/redirect-here
BUG redirect right at the source for getting source code
2 parents 2d642da + 79f8199 commit b68ad6d

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

conda_forge_tick/provide_source_code.py

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import logging
22
import os
33
import shutil
4+
import sys
45
import tempfile
56
from contextlib import contextmanager
67

8+
import wurlitzer
9+
710
from conda_forge_tick.os_utils import chmod_plus_rwX, sync_dirs
811
from conda_forge_tick.utils import CB_CONFIG, run_container_task
912

@@ -97,23 +100,38 @@ def provide_source_code_local(recipe_dir):
97100
str
98101
The path to the source code directory.
99102
"""
100-
try:
101-
from conda_build.api import render
102-
from conda_build.config import Config
103-
from conda_build.source import provide
104-
105-
# Use conda build to do all the downloading/extracting bits
106-
md = render(
107-
recipe_dir,
108-
config=Config(**CB_CONFIG),
109-
finalize=False,
110-
bypass_env_check=True,
111-
)
112-
if not md:
113-
return None
114-
md = md[0][0]
103+
out = None
115104

116-
# provide source dir
117-
yield provide(md)
105+
def _print_out():
106+
try:
107+
if out:
108+
sys.stdout.write(out.read())
109+
except Exception as e:
110+
logger.error(
111+
"Error printing out/err in getting conda build src!", exc_info=e
112+
)
113+
114+
try:
115+
with wurlitzer.pipes(stderr=wurlitzer.STDOUT) as (out, _):
116+
from conda_build.api import render
117+
from conda_build.config import Config
118+
from conda_build.source import provide
119+
120+
# Use conda build to do all the downloading/extracting bits
121+
md = render(
122+
recipe_dir,
123+
config=Config(**CB_CONFIG),
124+
finalize=False,
125+
bypass_env_check=True,
126+
)
127+
if not md:
128+
return None
129+
md = md[0][0]
130+
131+
# provide source dir
132+
yield provide(md)
118133
except (SystemExit, Exception) as e:
119-
raise RuntimeError("conda build src exception:" + str(e))
134+
_print_out()
135+
raise RuntimeError("conda build src exception: " + str(e))
136+
137+
_print_out()

docker/run_bot_task.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from contextlib import contextmanager, redirect_stdout
2626

2727
import click
28-
import wurlitzer
2928

3029
existing_feedstock_node_attrs_option = click.option(
3130
"--existing-feedstock-node-attrs",
@@ -154,19 +153,13 @@ def _provide_source_code():
154153
output_source_code = "/cf_tick_dir/source_dir"
155154
os.makedirs(output_source_code, exist_ok=True)
156155

157-
with (
158-
wurlitzer.pipes(stderr=wurlitzer.STDOUT) as (out, _),
159-
provide_source_code_local(recipe_dir) as cb_work_dir,
160-
):
156+
with provide_source_code_local(recipe_dir) as cb_work_dir:
161157
chmod_plus_rwX(cb_work_dir, recursive=True, skip_on_error=True)
162158
sync_dirs(
163159
cb_work_dir, output_source_code, ignore_dot_git=True, update_git=False
164160
)
165161
chmod_plus_rwX(output_source_code, recursive=True, skip_on_error=True)
166162

167-
# report even if not live
168-
sys.stderr.write(out.read())
169-
170163
return dict()
171164

172165

0 commit comments

Comments
 (0)