|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 |
| -import glob |
4 | 3 | import json
|
5 | 4 | import os
|
6 | 5 | import platform
|
|
17 | 16 | )
|
18 | 17 | from sysconfig import get_config_var
|
19 | 18 | from pathlib import Path
|
20 |
| -from typing import Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, cast |
| 19 | +from typing import Dict, List, NamedTuple, Optional, Set, Tuple, cast |
21 | 20 |
|
22 | 21 | import pkg_resources
|
23 |
| -from semantic_version import Version |
24 | 22 | from setuptools.command.build import build as CommandBuild
|
25 | 23 | from setuptools.command.build_ext import build_ext as CommandBuildExt
|
26 | 24 | from setuptools.command.build_ext import get_abi3_suffix
|
|
31 | 29 | from .extension import Binding, RustBin, RustExtension, Strip
|
32 | 30 | from .rustc_info import (
|
33 | 31 | get_rust_host,
|
34 |
| - get_rust_target_list, |
35 | 32 | get_rust_version,
|
36 | 33 | get_rustc_cfgs,
|
37 | 34 | )
|
@@ -155,12 +152,21 @@ def build_extension(
|
155 | 152 | env = _prepare_build_environment()
|
156 | 153 |
|
157 | 154 | if not os.path.exists(ext.path):
|
158 |
| - raise FileError(f"can't find Rust extension project file: {ext.path}") |
| 155 | + raise FileError( |
| 156 | + f"can't find manifest for Rust extension `{ext.name}` at path `{ext.path}`" |
| 157 | + ) |
159 | 158 |
|
160 | 159 | quiet = self.qbuild or ext.quiet
|
161 | 160 | debug = self._is_debug_build(ext)
|
162 | 161 | use_cargo_crate_type = _check_cargo_supports_crate_type_option()
|
163 | 162 |
|
| 163 | + package_id = ext.metadata(quiet=quiet)["resolve"]["root"] |
| 164 | + if package_id is None: |
| 165 | + raise FileError( |
| 166 | + f"manifest for Rust extention `{ext.name}` at path `{ext.path}` is a virtual manifest (a workspace root without a package).\n\n" |
| 167 | + "If you intended to build for a workspace member, set `path` for the extension to the member's Cargo.toml file." |
| 168 | + ) |
| 169 | + |
164 | 170 | cargo_args = self._cargo_args(
|
165 | 171 | ext=ext, target_triple=target_triple, release=not debug, quiet=quiet
|
166 | 172 | )
|
@@ -212,7 +218,7 @@ def build_extension(
|
212 | 218 | "wasm32",
|
213 | 219 | "emscripten",
|
214 | 220 | ):
|
215 |
| - rustc_args.extend(["-C", f"link-args=-sSIDE_MODULE=2 -sWASM_BIGINT"]) |
| 221 | + rustc_args.extend(["-C", "link-args=-sSIDE_MODULE=2 -sWASM_BIGINT"]) |
216 | 222 |
|
217 | 223 | if use_cargo_crate_type and "--crate-type" not in cargo_args:
|
218 | 224 | cargo_args.extend(["--crate-type", "cdylib"])
|
@@ -269,7 +275,6 @@ def build_extension(
|
269 | 275 | # it into the build directory as if it were produced by build_ext.
|
270 | 276 |
|
271 | 277 | dylib_paths = []
|
272 |
| - package_id = ext.metadata(quiet=quiet)["resolve"]["root"] |
273 | 278 |
|
274 | 279 | if ext._uses_exec_binding():
|
275 | 280 | # Find artifact from cargo messages
|
@@ -396,7 +401,7 @@ def install_extension(
|
396 | 401 | args.insert(0, "strip")
|
397 | 402 | args.append(ext_path)
|
398 | 403 | try:
|
399 |
| - output = subprocess.check_output(args) |
| 404 | + subprocess.check_output(args) |
400 | 405 | except subprocess.CalledProcessError:
|
401 | 406 | pass
|
402 | 407 |
|
@@ -643,7 +648,7 @@ def _binding_features(
|
643 | 648 | python_version = py_limited_api[2:]
|
644 | 649 | features.add(f"pyo3/abi3-py{python_version}")
|
645 | 650 | elif py_limited_api:
|
646 |
| - features.add(f"pyo3/abi3") |
| 651 | + features.add("pyo3/abi3") |
647 | 652 | return features
|
648 | 653 | elif ext.binding is Binding.RustCPython:
|
649 | 654 | return {"cpython/python3-sys", "cpython/extension-module"}
|
|
0 commit comments