File tree 1 file changed +32
-0
lines changed
src/pip/_internal/commands
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 3
3
4
4
from __future__ import absolute_import
5
5
6
+ import functools
7
+ import logging
8
+
6
9
from pip ._vendor import pip_run
7
10
8
11
from pip ._internal .cli .base_command import SUCCESS , Command
9
12
13
+ logger = logging .getLogger (__name__ )
14
+
15
+
16
+ def provisional (msg ):
17
+ """
18
+ Unconditionally warn when func is invoked.
19
+ """
20
+ return provisional_eval (msg , cond = lambda result : True )
21
+
22
+
23
+ def provisional_eval (msg , cond = bool ):
24
+ """
25
+ Warn if cond(func result) evaluates True.
26
+ """
27
+ def decorator (func ):
28
+ @functools .wraps (func )
29
+ def wrapper (* args , ** kwargs ):
30
+ result = func (* args , ** kwargs )
31
+ if cond (result ):
32
+ logger .warning (msg )
33
+ return result
34
+ return wrapper
35
+ return decorator
36
+
37
+
38
+ pip_run .scripts .DepsReader .try_read = classmethod (provisional_eval (
39
+ msg = "Support for reading requirements from a script is provisional." )(
40
+ vars (pip_run .scripts .DepsReader )['try_read' ].__func__ ))
41
+
10
42
11
43
class RunCommand (Command ):
12
44
"""Run a new Python interpreter with packages transient-installed"""
You can’t perform that action at this time.
0 commit comments