Skip to content

Commit

Permalink
Support for seed packages having dependencies
Browse files Browse the repository at this point in the history
- bump setuptools/wheel
- no OS dependent dependencies allowed

Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Aug 14, 2020
1 parent 10f232b commit 360413e
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 156 deletions.
8 changes: 8 additions & 0 deletions src/virtualenv/seed/embed/base_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from six import add_metaclass

from virtualenv.seed.wheels.embed import get_wheel_deps
from virtualenv.util.path import Path
from virtualenv.util.six import ensure_str, ensure_text

Expand Down Expand Up @@ -49,6 +50,13 @@ def distribution_to_versions(self):
if getattr(self, "no_{}".format(distribution)) is False
}

def get_expanded_distributions(self, creator):
distributions = self.distribution_to_versions()
for dist, value in list(distributions.items()):
for dep in get_wheel_deps(dist, creator.interpreter.version_release_str):
distributions[dep] = value
return distributions

@classmethod
def add_parser_arguments(cls, parser, interpreter, app_data):
group = parser.add_mutually_exclusive_group()
Expand Down
6 changes: 3 additions & 3 deletions src/virtualenv/seed/embed/pip_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run(self, creator):
if not self.enabled:
return
for_py_version = creator.interpreter.version_release_str
with self.get_pip_install_cmd(creator.exe, for_py_version) as cmd:
with self.get_pip_install_cmd(creator.exe, for_py_version, creator) as cmd:
env = pip_wheel_env_run(self.extra_search_dir, self.app_data)
self._execute(cmd, env)

Expand All @@ -32,12 +32,12 @@ def _execute(cmd, env):
return process

@contextmanager
def get_pip_install_cmd(self, exe, for_py_version):
def get_pip_install_cmd(self, exe, for_py_version, creator):
cmd = [str(exe), "-m", "pip", "-q", "install", "--only-binary", ":all:", "--disable-pip-version-check"]
if not self.download:
cmd.append("--no-index")
folders = set()
for dist, version in self.distribution_to_versions().items():
for dist, version in self.get_expanded_distributions(creator).items():
wheel = get_wheel(
distribution=dist,
version=version,
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/seed/embed/via_app_data/via_app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def _get(distribution, version):
with lock:
name_to_whl[distribution] = result

distributions = self.get_expanded_distributions(creator)
threads = list(
Thread(target=_get, args=(distribution, version))
for distribution, version in self.distribution_to_versions().items()
Thread(target=_get, args=(distribution, version)) for distribution, version in distributions.items()
)
for thread in threads:
thread.start()
Expand Down
63 changes: 50 additions & 13 deletions src/virtualenv/seed/wheels/embed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,94 @@
BUNDLE_FOLDER = Path(__file__).absolute().parent
BUNDLE_SUPPORT = {
"3.10": {
"packaging": "packaging-20.4-py2.py3-none-any.whl",
"pip": "pip-20.2.2-py2.py3-none-any.whl",
"setuptools": "setuptools-49.4.0-py3-none-any.whl",
"wheel": "wheel-0.34.2-py2.py3-none-any.whl",
"pyparsing": "pyparsing-2.4.7-py2.py3-none-any.whl",
"setuptools": "setuptools-49.6.0-py3-none-any.whl",
"six": "six-1.15.0-py2.py3-none-any.whl",
"wheel": "wheel-0.35.0-py2.py3-none-any.whl",
},
"3.9": {
"packaging": "packaging-20.4-py2.py3-none-any.whl",
"pip": "pip-20.2.2-py2.py3-none-any.whl",
"setuptools": "setuptools-49.4.0-py3-none-any.whl",
"wheel": "wheel-0.34.2-py2.py3-none-any.whl",
"pyparsing": "pyparsing-2.4.7-py2.py3-none-any.whl",
"setuptools": "setuptools-49.6.0-py3-none-any.whl",
"six": "six-1.15.0-py2.py3-none-any.whl",
"wheel": "wheel-0.35.0-py2.py3-none-any.whl",
},
"3.8": {
"packaging": "packaging-20.4-py2.py3-none-any.whl",
"pip": "pip-20.2.2-py2.py3-none-any.whl",
"setuptools": "setuptools-49.4.0-py3-none-any.whl",
"wheel": "wheel-0.34.2-py2.py3-none-any.whl",
"pyparsing": "pyparsing-2.4.7-py2.py3-none-any.whl",
"setuptools": "setuptools-49.6.0-py3-none-any.whl",
"six": "six-1.15.0-py2.py3-none-any.whl",
"wheel": "wheel-0.35.0-py2.py3-none-any.whl",
},
"3.7": {
"packaging": "packaging-20.4-py2.py3-none-any.whl",
"pip": "pip-20.2.2-py2.py3-none-any.whl",
"setuptools": "setuptools-49.4.0-py3-none-any.whl",
"wheel": "wheel-0.34.2-py2.py3-none-any.whl",
"pyparsing": "pyparsing-2.4.7-py2.py3-none-any.whl",
"setuptools": "setuptools-49.6.0-py3-none-any.whl",
"six": "six-1.15.0-py2.py3-none-any.whl",
"wheel": "wheel-0.35.0-py2.py3-none-any.whl",
},
"3.6": {
"packaging": "packaging-20.4-py2.py3-none-any.whl",
"pip": "pip-20.2.2-py2.py3-none-any.whl",
"setuptools": "setuptools-49.4.0-py3-none-any.whl",
"wheel": "wheel-0.34.2-py2.py3-none-any.whl",
"pyparsing": "pyparsing-2.4.7-py2.py3-none-any.whl",
"setuptools": "setuptools-49.6.0-py3-none-any.whl",
"six": "six-1.15.0-py2.py3-none-any.whl",
"wheel": "wheel-0.35.0-py2.py3-none-any.whl",
},
"3.5": {
"packaging": "packaging-20.4-py2.py3-none-any.whl",
"pip": "pip-20.2.2-py2.py3-none-any.whl",
"setuptools": "setuptools-49.4.0-py3-none-any.whl",
"wheel": "wheel-0.34.2-py2.py3-none-any.whl",
"pyparsing": "pyparsing-2.4.7-py2.py3-none-any.whl",
"setuptools": "setuptools-49.6.0-py3-none-any.whl",
"six": "six-1.15.0-py2.py3-none-any.whl",
"wheel": "wheel-0.35.0-py2.py3-none-any.whl",
},
"3.4": {
"pip": "pip-19.1.1-py2.py3-none-any.whl",
"setuptools": "setuptools-43.0.0-py2.py3-none-any.whl",
"wheel": "wheel-0.33.6-py2.py3-none-any.whl",
},
"2.7": {
"packaging": "packaging-20.4-py2.py3-none-any.whl",
"pip": "pip-20.2.2-py2.py3-none-any.whl",
"pyparsing": "pyparsing-2.4.7-py2.py3-none-any.whl",
"setuptools": "setuptools-44.1.1-py2.py3-none-any.whl",
"wheel": "wheel-0.34.2-py2.py3-none-any.whl",
"six": "six-1.15.0-py2.py3-none-any.whl",
"wheel": "wheel-0.35.0-py2.py3-none-any.whl",
},
}
MAX = "3.10"
VERSION_DEPS = {
"3.10": {"pip": [], "setuptools": [], "wheel": ["packaging", "pyparsing", "six"]},
"3.9": {"pip": [], "setuptools": [], "wheel": ["packaging", "pyparsing", "six"]},
"3.8": {"pip": [], "setuptools": [], "wheel": ["packaging", "pyparsing", "six"]},
"3.7": {"pip": [], "setuptools": [], "wheel": ["packaging", "pyparsing", "six"]},
"3.6": {"pip": [], "setuptools": [], "wheel": ["packaging", "pyparsing", "six"]},
"3.5": {"pip": [], "setuptools": [], "wheel": ["packaging", "pyparsing", "six"]},
"3.4": {"pip": [], "setuptools": [], "wheel": []},
"2.7": {"pip": [], "setuptools": [], "wheel": ["packaging", "pyparsing", "six"]},
}


def get_embed_wheel(distribution, for_py_version):
path = BUNDLE_FOLDER / (BUNDLE_SUPPORT.get(for_py_version, {}) or BUNDLE_SUPPORT[MAX]).get(distribution)
return Wheel.from_path(path)


def get_wheel_deps(distribution, for_py_version):
return VERSION_DEPS.get(for_py_version, {}).get(distribution, [])


__all__ = (
"get_embed_wheel",
"BUNDLE_SUPPORT",
"VERSION_DEPS",
"MAX",
"BUNDLE_FOLDER",
"get_wheel_deps",
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 4 additions & 2 deletions src/virtualenv/seed/wheels/periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def periodic_update(distribution, for_py_version, wheel, search_dirs, app_data,
u_log_older_than_hour = now - u_log.completed > timedelta(hours=1) if u_log.completed is not None else False
for _, group in groupby(u_log.versions, key=lambda v: v.wheel.version_tuple[0:2]):
version = next(group) # use only latest patch version per minor, earlier assumed to be buggy
if wheel is not None and Path(version.filename).name == wheel.name:
updated_wheel = Wheel(app_data.house / version.filename)
if wheel is not None and (
Path(version.filename).name == wheel.name or wheel.version_tuple > updated_wheel.version_tuple
):
break
if u_log.periodic is False or (u_log_older_than_hour and version.use(now)):
updated_wheel = Wheel(app_data.house / version.filename)
logging.debug("using %supdated wheel %s", "periodically " if updated_wheel else "", updated_wheel)
wheel = updated_wheel
break
Expand Down
89 changes: 0 additions & 89 deletions tasks/update_embedded.py

This file was deleted.

0 comments on commit 360413e

Please sign in to comment.