comparison env/lib/python3.9/site-packages/virtualenv/discovery/discover.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 from __future__ import absolute_import, unicode_literals
2
3 from abc import ABCMeta, abstractmethod
4
5 from six import add_metaclass
6
7
8 @add_metaclass(ABCMeta)
9 class Discover(object):
10 """Discover and provide the requested Python interpreter"""
11
12 @classmethod
13 def add_parser_arguments(cls, parser):
14 """Add CLI arguments for this discovery mechanisms.
15
16 :param parser: the CLI parser
17 """
18 raise NotImplementedError
19
20 # noinspection PyUnusedLocal
21 def __init__(self, options):
22 """Create a new discovery mechanism.
23
24 :param options: the parsed options as defined within :meth:`add_parser_arguments`
25 """
26 self._has_run = False
27 self._interpreter = None
28 self._env = options.env
29
30 @abstractmethod
31 def run(self):
32 """Discovers an interpreter.
33
34
35 :return: the interpreter ready to use for virtual environment creation
36 """
37 raise NotImplementedError
38
39 @property
40 def interpreter(self):
41 """
42 :return: the interpreter as returned by :meth:`run`, cached
43 """
44 if self._has_run is False:
45 self._interpreter = self.run()
46 self._has_run = True
47 return self._interpreter