Skip to content

Commit c8e1d9b

Browse files
committed
Filter out extra metadata and conda specific setuptools in requirements
1 parent 0d8ad2a commit c8e1d9b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

rsconnect/environment.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ def pip_freeze():
223223
}
224224

225225

226+
def strip_ref(line):
227+
return line.split("@", 1)[0].strip()
228+
229+
230+
def exclude(line):
231+
return line and line.startswith('setuptools') and 'post' in line
232+
233+
226234
def conda_env_export(conda):
227235
"""Inspect the environment using `conda env export`
228236
:param: conda path to the `conda` tool
@@ -267,8 +275,15 @@ def main():
267275
force_generate = True
268276
if "c" in flags:
269277
conda_mode = True
278+
envinfo = detect_environment(directory, force_generate, conda_mode)._asdict()
279+
if 'contents' in envinfo:
280+
keepers = list(map(strip_ref, envinfo['contents'].split('\n')))
281+
if not conda_mode:
282+
keepers = [line for line in keepers if not exclude(line)]
283+
envinfo['contents'] = '\n'.join(keepers)
284+
270285
json.dump(
271-
detect_environment(directory, force_generate, conda_mode)._asdict(), sys.stdout, indent=4,
286+
envinfo, sys.stdout, indent=4,
272287
)
273288
except EnvironmentException as exception:
274289
json.dump(dict(error=str(exception)), sys.stdout, indent=4)

0 commit comments

Comments
 (0)