File tree 1 file changed +21
-8
lines changed
1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change 3
3
import re
4
4
import sys
5
5
from collections import namedtuple
6
+ from functools import wraps
6
7
from logging import getLogger
7
8
8
9
from pkg_resources import parse_requirements
29
30
STDLIB .update (STDLIB_PY3 )
30
31
31
32
33
+ def memoize (f ):
34
+ """Cache value returned by the function."""
35
+ @wraps (f )
36
+ def w (* args , ** kw ):
37
+ memoize .mem [f ] = v = f (* args , ** kw )
38
+ return v
39
+ return w
40
+
41
+
42
+ # Initialize cache memory block.
43
+ memoize .mem = {}
44
+
45
+
32
46
def project2module (project ):
33
47
"""Convert project name into a module name."""
34
48
# Name unification in accordance with PEP 426.
@@ -271,16 +285,15 @@ def parse_options(cls, options):
271
285
}
272
286
273
287
@classmethod
288
+ @memoize
274
289
def get_setup (cls ):
275
290
"""Get package setup."""
276
- if not getattr (cls , '_setup' , None ):
277
- try :
278
- with open ("setup.py" ) as f :
279
- cls ._setup = SetupVisitor (ast .parse (f .read ()))
280
- except IOError as e :
281
- LOG .warning ("Couldn't open setup file: %s" , e )
282
- cls ._setup = SetupVisitor (ast .parse ("" ))
283
- return cls ._setup
291
+ try :
292
+ with open ("setup.py" ) as f :
293
+ return SetupVisitor (ast .parse (f .read ()))
294
+ except IOError as e :
295
+ LOG .warning ("Couldn't open setup file: %s" , e )
296
+ return SetupVisitor (ast .parse ("" ))
284
297
285
298
@property
286
299
def processing_setup_py (self ):
You can’t perform that action at this time.
0 commit comments