Skip to content

Commit 6ff51ba

Browse files
committed
🔥 Revert existing PEP 518 support
It might be easier to go about implementing things with a clean state. Please don't hate mate -> takluyver.
1 parent b0a762a commit 6ff51ba

File tree

10 files changed

+6
-668
lines changed

10 files changed

+6
-668
lines changed

src/pip/_internal/commands/wheel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ def run(self, options, args):
180180
finder, preparer, wheel_cache,
181181
build_options=options.build_options or [],
182182
global_options=options.global_options or [],
183-
no_clean=options.no_clean,
184183
)
185184
wheels_built_successfully = wb.build(
186185
requirement_set.requirements.values(), session=session,

src/pip/_internal/req/req_install.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,6 @@ def setup_py(self):
435435

436436
return setup_py
437437

438-
@property
439-
def pyproject_toml(self):
440-
assert self.source_dir, "No source dir for %s" % self
441-
442-
pp_toml = os.path.join(self.setup_py_dir, 'pyproject.toml')
443-
444-
# Python2 __file__ should not be unicode
445-
if six.PY2 and isinstance(pp_toml, six.text_type):
446-
pp_toml = pp_toml.encode(sys.getfilesystemencoding())
447-
448-
return pp_toml
449-
450438
def run_egg_info(self):
451439
assert self.source_dir
452440
if self.name:

src/pip/_internal/wheel.py

Lines changed: 6 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import collections
77
import compileall
8-
import copy
98
import csv
109
import hashlib
1110
import logging
@@ -17,9 +16,8 @@
1716
import warnings
1817
from base64 import urlsafe_b64encode
1918
from email.parser import Parser
20-
from sysconfig import get_paths
2119

22-
from pip._vendor import pkg_resources, pytoml
20+
from pip._vendor import pkg_resources
2321
from pip._vendor.distlib.scripts import ScriptMaker
2422
from pip._vendor.packaging.utils import canonicalize_name
2523
from pip._vendor.six import StringIO
@@ -602,58 +600,6 @@ def supported(self, tags=None):
602600
return bool(set(tags).intersection(self.file_tags))
603601

604602

605-
class BuildEnvironment(object):
606-
"""Context manager to install build deps in a simple temporary environment
607-
"""
608-
def __init__(self, no_clean):
609-
self._temp_dir = TempDirectory(kind="build-env")
610-
self._no_clean = no_clean
611-
612-
def __enter__(self):
613-
self._temp_dir.create()
614-
615-
self.save_path = os.environ.get('PATH', None)
616-
self.save_pythonpath = os.environ.get('PYTHONPATH', None)
617-
618-
install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix'
619-
install_dirs = get_paths(install_scheme, vars={
620-
'base': self._temp_dir.path,
621-
'platbase': self._temp_dir.path,
622-
})
623-
624-
scripts = install_dirs['scripts']
625-
if self.save_path:
626-
os.environ['PATH'] = scripts + os.pathsep + self.save_path
627-
else:
628-
os.environ['PATH'] = scripts + os.pathsep + os.defpath
629-
630-
if install_dirs['purelib'] == install_dirs['platlib']:
631-
lib_dirs = install_dirs['purelib']
632-
else:
633-
lib_dirs = install_dirs['purelib'] + os.pathsep + \
634-
install_dirs['platlib']
635-
if self.save_pythonpath:
636-
os.environ['PYTHONPATH'] = lib_dirs + os.pathsep + \
637-
self.save_pythonpath
638-
else:
639-
os.environ['PYTHONPATH'] = lib_dirs
640-
641-
return self._temp_dir.path
642-
643-
def __exit__(self, exc_type, exc_val, exc_tb):
644-
if not self._no_clean:
645-
self._temp_dir.cleanup()
646-
if self.save_path is None:
647-
os.environ.pop('PATH', None)
648-
else:
649-
os.environ['PATH'] = self.save_path
650-
651-
if self.save_pythonpath is None:
652-
os.environ.pop('PYTHONPATH', None)
653-
else:
654-
os.environ['PYTHONPATH'] = self.save_pythonpath
655-
656-
657603
class WheelBuilder(object):
658604
"""Build wheels from a RequirementSet."""
659605

@@ -667,65 +613,14 @@ def __init__(self, finder, preparer, wheel_cache,
667613

668614
self.build_options = build_options or []
669615
self.global_options = global_options or []
670-
self.no_clean = no_clean
671-
672-
def _find_build_reqs(self, req):
673-
"""Get a list of the packages required to build the project, if any,
674-
and a flag indicating whether pyproject.toml is present, indicating
675-
that the build should be isolated.
676-
677-
Build requirements can be specified in a pyproject.toml, as described
678-
in PEP 518. If this file exists but doesn't specify build
679-
requirements, pip will default to installing setuptools and wheel.
680-
"""
681-
if os.path.isfile(req.pyproject_toml):
682-
with open(req.pyproject_toml) as f:
683-
pp_toml = pytoml.load(f)
684-
return pp_toml.get('build-system', {})\
685-
.get('requires', ['setuptools', 'wheel']), True
686-
687-
return ['setuptools', 'wheel'], False
688-
689-
def _install_build_reqs(self, reqs, prefix):
690-
# Local import to avoid circular import (wheel <-> req_install)
691-
from pip._internal.req.req_install import InstallRequirement
692-
from pip._internal.index import FormatControl
693-
# Ignore the --no-binary option when installing the build system, so
694-
# we don't recurse trying to build a self-hosting build system.
695-
finder = copy.copy(self.finder)
696-
finder.format_control = FormatControl(set(), set())
697-
urls = [finder.find_requirement(InstallRequirement.from_line(r),
698-
upgrade=False).url
699-
for r in reqs]
700-
701-
args = [sys.executable, '-m', 'pip', 'install', '--ignore-installed',
702-
'--prefix', prefix] + list(urls)
703-
with open_spinner("Installing build dependencies") as spinner:
704-
call_subprocess(args, show_stdout=False, spinner=spinner)
705616

706617
def _build_one(self, req, output_dir, python_tag=None):
707618
"""Build one wheel.
708619
709620
:return: The filename of the built wheel, or None if the build failed.
710621
"""
711-
build_reqs, isolate = self._find_build_reqs(req)
712-
if 'setuptools' not in build_reqs:
713-
logger.warning(
714-
"This version of pip does not implement PEP 516, so "
715-
"it cannot build a wheel without setuptools. You may need to "
716-
"upgrade to a newer version of pip.")
717-
# Install build deps into temporary directory (PEP 518)
718-
with BuildEnvironment(self.no_clean) as prefix:
719-
self._install_build_reqs(build_reqs, prefix)
720-
return self._build_one_inside_env(req, output_dir,
721-
python_tag=python_tag,
722-
isolate=True)
723-
724-
def _build_one_inside_env(self, req, output_dir, python_tag=None,
725-
isolate=False):
726622
with TempDirectory(kind="wheel") as temp_dir:
727-
if self.__build_one(req, temp_dir.path, python_tag=python_tag,
728-
isolate=isolate):
623+
if self.__build_one(req, temp_dir.path, python_tag=python_tag):
729624
try:
730625
wheel_name = os.listdir(temp_dir.path)[0]
731626
wheel_path = os.path.join(output_dir, wheel_name)
@@ -740,20 +635,14 @@ def _build_one_inside_env(self, req, output_dir, python_tag=None,
740635
self._clean_one(req)
741636
return None
742637

743-
def _base_setup_args(self, req, isolate=False):
744-
flags = '-u'
745-
# The -S flag currently breaks Python in virtualenvs, because it relies
746-
# on site.py to find parts of the standard library outside the env. So
747-
# isolation is disabled for now.
748-
# if isolate:
749-
# flags += 'S'
638+
def _base_setup_args(self, req):
750639
return [
751-
sys.executable, flags, '-c',
640+
sys.executable, '-u', '-c',
752641
SETUPTOOLS_SHIM % req.setup_py
753642
] + list(self.global_options)
754643

755-
def __build_one(self, req, tempd, python_tag=None, isolate=False):
756-
base_args = self._base_setup_args(req, isolate=isolate)
644+
def __build_one(self, req, tempd, python_tag=None):
645+
base_args = self._base_setup_args(req)
757646

758647
spin_message = 'Running setup.py bdist_wheel for %s' % (req.name,)
759648
with open_spinner(spin_message) as spinner:
@@ -764,13 +653,8 @@ def __build_one(self, req, tempd, python_tag=None, isolate=False):
764653
if python_tag is not None:
765654
wheel_args += ["--python-tag", python_tag]
766655

767-
env = {}
768-
if isolate:
769-
env['PYTHONNOUSERSITE'] = '1'
770-
771656
try:
772657
call_subprocess(wheel_args, cwd=req.setup_py_dir,
773-
extra_environ=env,
774658
show_stdout=False, spinner=spinner)
775659
return True
776660
except:

src/pip/_vendor/pytoml.pyi

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/pip/_vendor/pytoml/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/pip/_vendor/pytoml/core.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)