Fix for pyproject.toml dependencies not being included.

This commit is contained in:
Matt Davis
2023-06-30 22:36:13 -04:00
parent cb23498757
commit b246d69889
3 changed files with 37 additions and 37 deletions
+1
View File
@@ -363,6 +363,7 @@ class Resolver:
and is_installable_dir(parsed_line.path)
)
):
setup_info.run_pyproject()
setup_info.run_setup()
requirements = [v for v in getattr(setup_info, "requires", {}).values()]
if req.extras:
+8 -8
View File
@@ -1018,9 +1018,8 @@ def get_metadata(path, pkg_name=None, metadata_type=None):
wheel_allowed = metadata_type == "wheel" or metadata_type is None
egg_allowed = metadata_type == "egg" or metadata_type is None
dist = None # type: Optional[Union[DistInfoDistribution, EggInfoDistribution]]
if wheel_allowed:
dist = get_distinfo_dist(path, pkg_name=pkg_name)
if egg_allowed and dist is None:
dist = get_distinfo_dist(path, pkg_name=pkg_name)
if dist is None:
dist = get_egginfo_dist(path, pkg_name=pkg_name)
if dist is not None:
return get_metadata_from_dist(dist)
@@ -1590,17 +1589,18 @@ build-backend = "{1}"
if self.pyproject and self.pyproject.exists():
result = get_pyproject(self.pyproject.parent)
if result is not None:
requires, backend = result
if self.build_requires is None:
self.build_requires = ()
if backend:
self.build_backend = backend
if result.get("build_backend"):
self.build_backend = result.get("build_backend")
else:
self.build_backend = get_default_pyproject_backend()
if requires:
self.build_requires = tuple(set(requires) | set(self.build_requires))
if result.get("build_requires"):
self.build_requires = tuple(set(result.get("build_requires", [])) | set(self.build_requires))
else:
self.build_requires = ("setuptools", "wheel")
if result.get("dependencies"):
self._requirements += make_base_requirements(tuple(set(result.get("dependencies", []))))
return self
def get_initial_info(self) -> Dict[str, Any]:
+28 -29
View File
@@ -441,47 +441,46 @@ def get_default_pyproject_backend():
return "setuptools.build_meta"
def get_pyproject(path):
# type: (Union[STRING_TYPE, Path]) -> Optional[Tuple[List[STRING_TYPE], STRING_TYPE]]
"""Given a base path, look for the corresponding ``pyproject.toml`` file
def get_pyproject(path: Union[AnyStr, Path]) -> Optional[Dict[str, Union[List[AnyStr], AnyStr]]]:
"""
Given a base path, look for the corresponding ``pyproject.toml`` file
and return its build_requires and build_backend.
:param AnyStr path: The root path of the project, should be a directory (will be truncated)
:return: A 2 tuple of build requirements and the build backend
:rtype: Optional[Tuple[List[AnyStr], AnyStr]]
:param path: The root path of the project, should be a directory (will be truncated)
:return: A dictionary with build requirements, build backend, and dependencies
"""
if not path:
return
if not isinstance(path, Path):
path = Path(path)
if not path.is_dir():
path = path.parent
pp_toml = path.joinpath("pyproject.toml")
setup_py = path.joinpath("setup.py")
if not pp_toml.exists():
if not setup_py.exists():
return None
requires = ["setuptools>=40.8", "wheel"]
backend = get_default_pyproject_backend()
else:
pyproject_data = {}
with open(pp_toml.as_posix(), encoding="utf-8") as fh:
pp_toml = path / "pyproject.toml"
# Default values
requires = ["setuptools>=40.8", "wheel"]
backend = get_default_pyproject_backend()
dependencies = []
if pp_toml.exists():
with open(pp_toml, encoding="utf-8") as fh:
pyproject_data = tomlkit.loads(fh.read())
# Extracting build system information
build_system = pyproject_data.get("build-system", None)
if build_system is None:
if setup_py.exists():
requires = ["setuptools>=40.8", "wheel"]
backend = get_default_pyproject_backend()
else:
requires = ["setuptools>=40.8", "wheel"]
backend = get_default_pyproject_backend()
build_system = {"requires": requires, "build-backend": backend}
pyproject_data["build_system"] = build_system
else:
requires = build_system.get("requires", ["setuptools>=40.8", "wheel"])
backend = build_system.get("build-backend", get_default_pyproject_backend())
return requires, backend
if build_system is not None:
requires = build_system.get("requires", requires)
backend = build_system.get("build-backend", backend)
# Extracting project dependencies
project_data = pyproject_data.get("project", None)
if project_data is not None:
dependencies = project_data.get("dependencies", [])
return {"build_requires": requires, "build_backend": backend, "dependencies": dependencies}
def split_markers_from_line(line):