|
11 | 11 |
|
12 | 12 | import datetime
|
13 | 13 | import importlib
|
| 14 | +import os |
14 | 15 | import platform
|
15 | 16 | import subprocess
|
16 | 17 | import time
|
|
32 | 33 | def watermark(author=None, current_date=False, datename=False,
|
33 | 34 | current_time=False, iso8601=False, timezone=False,
|
34 | 35 | updated=False, custom_time=None, python=False,
|
35 |
| - packages=None, hostname=False, machine=False, |
| 36 | + packages=None, conda=False, hostname=False, machine=False, |
36 | 37 | githash=False, gitrepo=False, gitbranch=False,
|
37 | 38 | watermark=False, iversions=False, watermark_self=None):
|
38 | 39 |
|
@@ -72,6 +73,9 @@ def watermark(author=None, current_date=False, datename=False,
|
72 | 73 | packages :
|
73 | 74 | prints versions of specified Python modules and packages
|
74 | 75 |
|
| 76 | + conda : |
| 77 | + prints name of current conda environment |
| 78 | +
|
75 | 79 | hostname :
|
76 | 80 | prints the host name
|
77 | 81 |
|
@@ -137,6 +141,8 @@ def watermark(author=None, current_date=False, datename=False,
|
137 | 141 | output.append(_get_pyversions())
|
138 | 142 | if args['packages']:
|
139 | 143 | output.append(_get_packages(args['packages']))
|
| 144 | + if args['conda']: |
| 145 | + output.append(_get_conda_env()) |
140 | 146 | if args['machine']:
|
141 | 147 | output.append(_get_sysinfo())
|
142 | 148 | if args['hostname']:
|
@@ -269,3 +275,7 @@ def _get_all_import_versions(vars):
|
269 | 275 | if pkg_version not in ("not installed", "unknown"):
|
270 | 276 | to_print[pkg_name] = pkg_version
|
271 | 277 | return to_print
|
| 278 | + |
| 279 | +def _get_conda_env(): |
| 280 | + name = os.getenv('CONDA_DEFAULT_ENV', 'n/a') |
| 281 | + return {"conda environment": name} |
0 commit comments