mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Allow build-system requirements to be empty
This commit is contained in:
parent
618720de89
commit
9a79fb5ac4
46
pip/wheel.py
46
pip/wheel.py
|
@ -699,25 +699,21 @@ class WheelBuilder(object):
|
||||||
self.no_clean = no_clean
|
self.no_clean = no_clean
|
||||||
|
|
||||||
def _find_build_reqs(self, req):
|
def _find_build_reqs(self, req):
|
||||||
"""Get a list of the packages required to build the project, if any.
|
"""Get a list of the packages required to build the project, if any,
|
||||||
|
and a flag indicating whether pyproject.toml is present, indicating
|
||||||
|
that the build should be isolated.
|
||||||
|
|
||||||
Build requirements can be specified in a pyproject.toml, as described
|
Build requirements can be specified in a pyproject.toml, as described
|
||||||
in PEP 518. If this file exists but doesn't specify any build
|
in PEP 518. If this file exists but doesn't specify build
|
||||||
requirements, pip will default to installing setuptools and wheel. If
|
requirements, pip will default to installing setuptools and wheel.
|
||||||
pyproject.toml is not present, the build will take place in the current
|
|
||||||
environment.
|
|
||||||
"""
|
"""
|
||||||
if os.path.isfile(req.pyproject_toml):
|
if os.path.isfile(req.pyproject_toml):
|
||||||
with open(req.pyproject_toml) as f:
|
with open(req.pyproject_toml) as f:
|
||||||
pp_toml = pytoml.load(f)
|
pp_toml = pytoml.load(f)
|
||||||
bsr = pp_toml.get('build-system', {}).get('requires', [])
|
return pp_toml.get('build-system', {})\
|
||||||
if not bsr:
|
.get('requires', ['setuptools', 'wheel']), True
|
||||||
# These are required for the most common way to build a wheel,
|
|
||||||
# so we'll install them if no build-system reqs are specified.
|
|
||||||
bsr = ['setuptools', 'wheel']
|
|
||||||
return bsr
|
|
||||||
|
|
||||||
return [] # No pyproject.toml - will result in a non-isolated build.
|
return ['setuptools', 'wheel'], False
|
||||||
|
|
||||||
def _install_build_reqs(self, reqs, prefix):
|
def _install_build_reqs(self, reqs, prefix):
|
||||||
# Local import to avoid circular import (wheel <-> req_install)
|
# Local import to avoid circular import (wheel <-> req_install)
|
||||||
|
@ -736,21 +732,13 @@ class WheelBuilder(object):
|
||||||
|
|
||||||
:return: The filename of the built wheel, or None if the build failed.
|
:return: The filename of the built wheel, or None if the build failed.
|
||||||
"""
|
"""
|
||||||
build_reqs = self._find_build_reqs(req)
|
build_reqs, isolate = self._find_build_reqs(req)
|
||||||
|
# Install build deps into temporary prefix (PEP 518)
|
||||||
if build_reqs:
|
with BuildEnvironment(no_clean=self.no_clean) as prefix:
|
||||||
# Install build deps into temporary prefix (PEP 518)
|
self._install_build_reqs(build_reqs, prefix)
|
||||||
with BuildEnvironment(no_clean=self.no_clean) as prefix:
|
|
||||||
self._install_build_reqs(build_reqs, prefix)
|
|
||||||
return self._build_one_inside_env(req, output_dir,
|
|
||||||
python_tag=python_tag,
|
|
||||||
isolate=True)
|
|
||||||
else:
|
|
||||||
# Build in the current environment, with no isolation.
|
|
||||||
# Used for sdists without a pyproject.toml, as well as build
|
|
||||||
# systems that don't require any external dependencies.
|
|
||||||
return self._build_one_inside_env(req, output_dir,
|
return self._build_one_inside_env(req, output_dir,
|
||||||
python_tag=python_tag)
|
python_tag=python_tag,
|
||||||
|
isolate=True)
|
||||||
|
|
||||||
def _build_one_inside_env(self, req, output_dir, python_tag=None,
|
def _build_one_inside_env(self, req, output_dir, python_tag=None,
|
||||||
isolate=False):
|
isolate=False):
|
||||||
|
@ -774,10 +762,8 @@ class WheelBuilder(object):
|
||||||
|
|
||||||
def _base_setup_args(self, req, isolate=False):
|
def _base_setup_args(self, req, isolate=False):
|
||||||
flags = '-u'
|
flags = '-u'
|
||||||
# The install process needs to be able to import setuptools from where
|
if isolate:
|
||||||
# it's installed as a dependency of pip, so skipping isolation for now.
|
flags += 'S'
|
||||||
# if isolate:
|
|
||||||
# flags += 'S'
|
|
||||||
return [
|
return [
|
||||||
sys.executable, flags, '-c',
|
sys.executable, flags, '-c',
|
||||||
SETUPTOOLS_SHIM % req.setup_py
|
SETUPTOOLS_SHIM % req.setup_py
|
||||||
|
|
Binary file not shown.
|
@ -1,2 +1,2 @@
|
||||||
[build-system]
|
[build-system]
|
||||||
requires=["simple==3.0"]
|
requires=["simple==3.0", "setuptools", "wheel"]
|
||||||
|
|
Loading…
Reference in a new issue