Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/virtualenv/seed/embed/base_embed.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:32:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d30785e31577 | 1:56ad4e20f292 |
|---|---|
| 1 from __future__ import absolute_import, unicode_literals | |
| 2 | |
| 3 from abc import ABCMeta | |
| 4 | |
| 5 from six import add_metaclass | |
| 6 | |
| 7 from virtualenv.util.path import Path | |
| 8 from virtualenv.util.six import ensure_str, ensure_text | |
| 9 | |
| 10 from ..seeder import Seeder | |
| 11 from ..wheels import Version | |
| 12 | |
| 13 PERIODIC_UPDATE_ON_BY_DEFAULT = True | |
| 14 | |
| 15 | |
| 16 @add_metaclass(ABCMeta) | |
| 17 class BaseEmbed(Seeder): | |
| 18 def __init__(self, options): | |
| 19 super(BaseEmbed, self).__init__(options, enabled=options.no_seed is False) | |
| 20 | |
| 21 self.download = options.download | |
| 22 self.extra_search_dir = [i.resolve() for i in options.extra_search_dir if i.exists()] | |
| 23 | |
| 24 self.pip_version = options.pip | |
| 25 self.setuptools_version = options.setuptools | |
| 26 self.wheel_version = options.wheel | |
| 27 | |
| 28 self.no_pip = options.no_pip | |
| 29 self.no_setuptools = options.no_setuptools | |
| 30 self.no_wheel = options.no_wheel | |
| 31 self.app_data = options.app_data | |
| 32 self.periodic_update = not options.no_periodic_update | |
| 33 | |
| 34 if not self.distribution_to_versions(): | |
| 35 self.enabled = False | |
| 36 | |
| 37 @classmethod | |
| 38 def distributions(cls): | |
| 39 return { | |
| 40 "pip": Version.bundle, | |
| 41 "setuptools": Version.bundle, | |
| 42 "wheel": Version.bundle, | |
| 43 } | |
| 44 | |
| 45 def distribution_to_versions(self): | |
| 46 return { | |
| 47 distribution: getattr(self, "{}_version".format(distribution)) | |
| 48 for distribution in self.distributions() | |
| 49 if getattr(self, "no_{}".format(distribution)) is False | |
| 50 } | |
| 51 | |
| 52 @classmethod | |
| 53 def add_parser_arguments(cls, parser, interpreter, app_data): | |
| 54 group = parser.add_mutually_exclusive_group() | |
| 55 group.add_argument( | |
| 56 "--no-download", | |
| 57 "--never-download", | |
| 58 dest="download", | |
| 59 action="store_false", | |
| 60 help="pass to disable download of the latest {} from PyPI".format("/".join(cls.distributions())), | |
| 61 default=True, | |
| 62 ) | |
| 63 group.add_argument( | |
| 64 "--download", | |
| 65 dest="download", | |
| 66 action="store_true", | |
| 67 help="pass to enable download of the latest {} from PyPI".format("/".join(cls.distributions())), | |
| 68 default=False, | |
| 69 ) | |
| 70 parser.add_argument( | |
| 71 "--extra-search-dir", | |
| 72 metavar="d", | |
| 73 type=Path, | |
| 74 nargs="+", | |
| 75 help="a path containing wheels to extend the internal wheel list (can be set 1+ times)", | |
| 76 default=[], | |
| 77 ) | |
| 78 for distribution, default in cls.distributions().items(): | |
| 79 parser.add_argument( | |
| 80 "--{}".format(distribution), | |
| 81 dest=distribution, | |
| 82 metavar="version", | |
| 83 help="version of {} to install as seed: embed, bundle or exact version".format(distribution), | |
| 84 default=default, | |
| 85 ) | |
| 86 for distribution in cls.distributions(): | |
| 87 parser.add_argument( | |
| 88 "--no-{}".format(distribution), | |
| 89 dest="no_{}".format(distribution), | |
| 90 action="store_true", | |
| 91 help="do not install {}".format(distribution), | |
| 92 default=False, | |
| 93 ) | |
| 94 parser.add_argument( | |
| 95 "--no-periodic-update", | |
| 96 dest="no_periodic_update", | |
| 97 action="store_true", | |
| 98 help="disable the periodic (once every 14 days) update of the embedded wheels", | |
| 99 default=not PERIODIC_UPDATE_ON_BY_DEFAULT, | |
| 100 ) | |
| 101 | |
| 102 def __unicode__(self): | |
| 103 result = self.__class__.__name__ | |
| 104 result += "(" | |
| 105 if self.extra_search_dir: | |
| 106 result += "extra_search_dir={},".format(", ".join(ensure_text(str(i)) for i in self.extra_search_dir)) | |
| 107 result += "download={},".format(self.download) | |
| 108 for distribution in self.distributions(): | |
| 109 if getattr(self, "no_{}".format(distribution)): | |
| 110 continue | |
| 111 result += " {}{},".format( | |
| 112 distribution, "={}".format(getattr(self, "{}_version".format(distribution), None) or "latest"), | |
| 113 ) | |
| 114 return result[:-1] + ")" | |
| 115 | |
| 116 def __repr__(self): | |
| 117 return ensure_str(self.__unicode__()) |
