Skip to content

Commit

Permalink
Filter out extra metadata and conda specific setuptools in requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
bcwu committed Mar 26, 2021
1 parent 0d8ad2a commit c8e1d9b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion rsconnect/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ def pip_freeze():
}


def strip_ref(line):
return line.split("@", 1)[0].strip()


def exclude(line):
return line and line.startswith('setuptools') and 'post' in line


def conda_env_export(conda):
"""Inspect the environment using `conda env export`
:param: conda path to the `conda` tool
Expand Down Expand Up @@ -267,8 +275,15 @@ def main():
force_generate = True
if "c" in flags:
conda_mode = True
envinfo = detect_environment(directory, force_generate, conda_mode)._asdict()
if 'contents' in envinfo:
keepers = list(map(strip_ref, envinfo['contents'].split('\n')))
if not conda_mode:
keepers = [line for line in keepers if not exclude(line)]
envinfo['contents'] = '\n'.join(keepers)

json.dump(
detect_environment(directory, force_generate, conda_mode)._asdict(), sys.stdout, indent=4,
envinfo, sys.stdout, indent=4,
)
except EnvironmentException as exception:
json.dump(dict(error=str(exception)), sys.stdout, indent=4)
Expand Down

1 comment on commit c8e1d9b

@bcwu
Copy link
Contributor Author

@bcwu bcwu commented on c8e1d9b Mar 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #166

Please sign in to comment.