Skip to content

Commit

Permalink
link app data needs ro with symlinks (#1480)
Browse files Browse the repository at this point in the history
* fix app data logic

Ensure that what ran with virtualenv 17 will continue running in a post
rewrite world minus the deprecated flags, plus the relocatable feature.

Signed-off-by: Bernat Gabor <[email protected]>

* fix Windows

* fix

* fix

Signed-off-by: Bernat Gabor <[email protected]>
  • Loading branch information
gaborbernat authored Jan 6, 2020
1 parent aaf69cf commit fbdd782
Show file tree
Hide file tree
Showing 19 changed files with 398 additions and 257 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ virtualenv.create =
virtualenv.seed =
none = virtualenv.seed.none:NoneSeeder
pip = virtualenv.seed.embed.pip_invoke:PipInvoke
link-app-data = virtualenv.seed.embed.link_app_data:LinkFromAppData
app-data = virtualenv.seed.via_app_data.via_app_data:FromAppData
virtualenv.activate =
bash = virtualenv.activation.bash:BashActivator
cshell = virtualenv.activation.cshell:CShellActivator
Expand Down
Empty file added src/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion src/virtualenv/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _get_seeder(parser, options):
seed_parser.add_argument(
"--seeder",
choices=list(seeder_types.keys()),
default="link-app-data",
default="app-data",
required=False,
help="seed packages install method",
)
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/seed/embed/base_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
@six.add_metaclass(ABCMeta)
class BaseEmbed(Seeder):
def __init__(self, options):
super(Seeder, self).__init__()
self.enabled = options.without_pip is False
super(BaseEmbed, self).__init__(options, enabled=options.without_pip is False)

self.download = options.download
self.extra_search_dir = [i.resolve() for i in options.extra_search_dir if i.exists()]
self.pip_version = None if options.pip == "latest" else options.pip
Expand Down
233 changes: 0 additions & 233 deletions src/virtualenv/seed/embed/link_app_data.py

This file was deleted.

16 changes: 7 additions & 9 deletions src/virtualenv/seed/embed/pip_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ def __init__(self, options):
super(PipInvoke, self).__init__(options)

def run(self, creator):
if not self.enabled:
return

version = creator.interpreter.version_release_str

cmd = [str(creator.exe), "-m", "pip", "install", "--only-binary", ":all:"]
cmd = self.get_pip_install_cmd(creator.exe, creator.interpreter.version_release_str)
env = pip_wheel_env_run(creator.interpreter.version_release_str)
process = Popen(cmd, env=env)
process.communicate()

def get_pip_install_cmd(self, exe, version):
cmd = [str(exe), "-m", "pip", "install", "--only-binary", ":all:"]
for folder in {get_bundled_wheel(p, version).parent for p in ("pip", "setuptools")}:
cmd.extend(["--find-links", str(folder)])
cmd.extend(self.extra_search_dir)
if not self.download:
cmd.append("--no-index")
for key, version in {"pip": self.pip_version, "setuptools": self.setuptools_version}.items():
cmd.append("{}{}".format(key, "=={}".format(version) if version is not None else ""))

process = Popen(cmd, env=pip_wheel_env_run(version))
process.communicate()
return cmd
7 changes: 2 additions & 5 deletions src/virtualenv/seed/embed/wheels/acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@
BUNDLE_FOLDER = Path(__file__).parent


def get_wheel(for_py_version, cache, extra_search_dir, download, pip, setuptools):
def get_wheels(for_py_version, wheel_cache_dir, extra_search_dir, download, pip, setuptools):
# not all wheels are compatible with all python versions, so we need to py version qualify it
wheel_cache_dir = cache / "acquired" / for_py_version
wheel_cache_dir.mkdir(parents=True, exist_ok=True)

packages = {"pip": pip, "setuptools": setuptools}

# 1. acquire from bundle
acquire_from_bundle(packages, for_py_version, wheel_cache_dir)
# 2. acquire from extra search dir
acquire_from_dir(packages, for_py_version, wheel_cache_dir, extra_search_dir)
# 3. download from the internet
if download:
if download and packages:
download_wheel(packages, for_py_version, wheel_cache_dir)

# in the end just get the wheels
Expand Down
3 changes: 3 additions & 0 deletions src/virtualenv/seed/none.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@


class NoneSeeder(Seeder):
def __init__(self, options):
super(NoneSeeder, self).__init__(options, False)

@classmethod
def add_parser_arguments(cls, parser):
pass
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/seed/seeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

@six.add_metaclass(ABCMeta)
class Seeder(object):
def __init__(self, options):
pass
def __init__(self, options, enabled):
self.enabled = enabled

@classmethod
def add_parser_arguments(cls, parser):
Expand Down
Empty file.
Empty file.
Loading

0 comments on commit fbdd782

Please sign in to comment.