diff options
author | Benoit Pierre <benoit.pierre@gmail.com> | 2017-11-02 21:19:39 +0100 |
---|---|---|
committer | Benoit Pierre <benoit.pierre@gmail.com> | 2017-11-26 13:19:48 +0100 |
commit | 118edbb2b715c96620b51018c1d28e81f2318053 (patch) | |
tree | dbac555fe8af490e6dcd9d097b1fcb590652c70f /setuptools/command/easy_install.py | |
parent | dce4750aed2d5b0a4ba677b0e308cd10dca2f6ee (diff) | |
download | python-setuptools-git-118edbb2b715c96620b51018c1d28e81f2318053.tar.gz |
easy_install: add support for installing from wheels
Note: wheels are installed as eggs, so each install is self-contained
and multiple versions of the same package can be installed at the same
time.
Limitations:
- headers are not supported
- resulting egg metadata requirements have their markers stripped
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-x | setuptools/command/easy_install.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 71991efa..12e22310 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -53,6 +53,7 @@ from setuptools.package_index import ( PackageIndex, parse_requirement_arg, URL_SCHEME, ) from setuptools.command import bdist_egg, egg_info +from setuptools.wheel import Wheel from pkg_resources import ( yield_lines, normalize_path, resource_string, ensure_directory, get_distribution, find_distributions, Environment, Requirement, @@ -842,6 +843,8 @@ class easy_install(Command): return [self.install_egg(dist_filename, tmpdir)] elif dist_filename.lower().endswith('.exe'): return [self.install_exe(dist_filename, tmpdir)] + elif dist_filename.lower().endswith('.whl'): + return [self.install_wheel(dist_filename, tmpdir)] # Anything else, try to extract and build setup_base = tmpdir @@ -1038,6 +1041,35 @@ class easy_install(Command): f.write('\n'.join(locals()[name]) + '\n') f.close() + def install_wheel(self, wheel_path, tmpdir): + wheel = Wheel(wheel_path) + assert wheel.is_compatible() + destination = os.path.join(self.install_dir, wheel.egg_name()) + destination = os.path.abspath(destination) + if not self.dry_run: + ensure_directory(destination) + if os.path.isdir(destination) and not os.path.islink(destination): + dir_util.remove_tree(destination, dry_run=self.dry_run) + elif os.path.exists(destination): + self.execute( + os.unlink, + (destination,), + "Removing " + destination, + ) + try: + self.execute( + wheel.install_as_egg, + (destination,), + ("Installing %s to %s") % ( + os.path.basename(wheel_path), + os.path.dirname(destination) + ), + ) + finally: + update_dist_caches(destination, fix_zipimporter_caches=False) + self.add_output(destination) + return self.egg_distribution(destination) + __mv_warning = textwrap.dedent(""" Because this distribution was installed --multi-version, before you can import modules from this package in an application, you will need to |