Skip to content

Commit a200795

Browse files
authored
Merge pull request winpython#832 from stonebig/master
modernize utils
2 parents 72cc768 + 642bff1 commit a200795

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

winpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '2.3.20200406'
31+
__version__ = '2.3.20200408'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

winpython/data/packages.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,3 +2500,12 @@ description = Backport of pathlib-compatible object wrapper for zip files
25002500
[z3-solver]
25012501
description = an efficient SMT solver library
25022502

2503+
[umap-learn]
2504+
description = Uniform Manifold Approximation and Projection
2505+
2506+
[tensorboard-plugin-wit]
2507+
description = What-If Tool TensorBoard plugin.
2508+
2509+
[tbb]
2510+
description = Intel(R) Threading Building Blocks
2511+

winpython/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,21 @@ def exec_shell_cmd(args, path):
253253
)
254254
return decode_fs_string(process.stdout.read())
255255

256+
def exec_run_cmd(args, path=None):
257+
"""run a single command (*args* is a list of arguments) in optional *path*"""
258+
# only applicable to Python-3.5+
259+
# python-3.7+ allows to replace "stdout and stderr ", per "capture_output=True"
260+
if path:
261+
process = subprocess.run(args,
262+
stdout=subprocess.PIPE,
263+
stderr=subprocess.PIPE,
264+
cwd=path)
265+
else:
266+
process = subprocess.run(args,
267+
stdout=subprocess.PIPE,
268+
stderr=subprocess.PIPE)
269+
return decode_fs_string(process.stdout)
270+
256271

257272
def get_r_version(path):
258273
"""Return version of the R installed in *path*"""

winpython/wppm.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ def get_official_description(name):
5151
dir_path = os.path.dirname(sys.executable)
5252
this = normalize(name)
5353
this_len = len(this)
54-
pip_ask = 'pip search '+ this
54+
pip_ask = ['pip', 'search', this, '--retries', '0']
55+
if len(this)<2: # don't ask stupid things
56+
return ''
5557
try:
56-
pip_res = (utils.exec_shell_cmd(pip_ask, dir_path)+'\n').splitlines()
58+
# .run work when .popen fails when no internet
59+
pip_res = (utils.exec_run_cmd(pip_ask)+'\n').splitlines()
5760
pip_filter = [l for l in pip_res if this + " (" ==
5861
normalize(l[:this_len])+l[this_len:this_len+2]]
5962
pip_desc = (pip_filter[0][len(this)+1:]).split(" - ", 1)[1]

0 commit comments

Comments
 (0)