@@ -243,7 +243,7 @@ def src_path(self, installer: "InstallerBuildExt") -> Path:
243
243
src_path = src_path .replace ("%BUILD_TYPE%" , cfg )
244
244
else :
245
245
# Remove %BUILD_TYPE% from the path.
246
- src_path = src_path . replace ("/ %BUILD_TYPE%" , "" )
246
+ src_path = self . src . replace ("%BUILD_TYPE%/ " , "" )
247
247
248
248
# Construct the full source path, resolving globs. If there are no glob
249
249
# pattern characters, this will just ensure that the source file exists.
@@ -291,7 +291,7 @@ def __init__(
291
291
output is in a subdirectory named after the build type. For single-
292
292
config generators (like Makefile Generators or Ninja), this placeholder
293
293
will be removed.
294
- src_name: The name of the file to install
294
+ src_name: The name of the file to install.
295
295
dst: The path to install to, relative to the root of the pip
296
296
package. If dst ends in "/", it is treated as a directory.
297
297
Otherwise it is treated as a filename.
@@ -345,20 +345,25 @@ def inplace_dir(self, installer: "InstallerBuildExt") -> Path:
345
345
class BuiltExtension (_BaseExtension ):
346
346
"""An extension that installs a python extension that was built by cmake."""
347
347
348
- def __init__ (self , src : str , modpath : str ):
348
+ def __init__ (self , src_dir : str , src_name : str , modpath : str ):
349
349
"""Initializes a BuiltExtension.
350
350
351
351
Args:
352
- src: The path to the file to install (typically a shared library),
353
- relative to the cmake-out directory. May be an fnmatch-style
354
- glob that matches exactly one file. If the path ends in `.so`,
352
+ src_dir: The directory of the file to install, relative to the cmake-out
353
+ directory. A placeholder %BUILD_TYPE% will be replaced with the build
354
+ type for multi-config generators (like Visual Studio) where the build
355
+ output is in a subdirectory named after the build type. For single-
356
+ config generators (like Makefile Generators or Ninja), this placeholder
357
+ will be removed.
358
+ src_name: The name of the file to install. If the path ends in `.so`,
355
359
this class will also look for similarly-named `.dylib` files.
356
360
modpath: The dotted path of the python module that maps to the
357
361
extension.
358
362
"""
359
363
assert (
360
364
"/" not in modpath
361
365
), f"modpath must be a dotted python module path: saw '{ modpath } '"
366
+ src = os .path .join (src_dir , src_name )
362
367
# This is a real extension, so use the modpath as the name.
363
368
super ().__init__ (src = f"%CMAKE_CACHE_DIR%/{ src } " , dst = modpath , name = modpath )
364
369
@@ -783,7 +788,9 @@ def get_ext_modules() -> List[Extension]:
783
788
# portable kernels, and a selection of backends. This lets users
784
789
# load and execute .pte files from python.
785
790
BuiltExtension (
786
- "_portable_lib.*" , "executorch.extension.pybindings._portable_lib"
791
+ src_dir = "%BUILD_TYPE%/" ,
792
+ src_name = "_portable_lib.cp*" ,
793
+ modpath = "executorch.extension.pybindings._portable_lib" ,
787
794
)
788
795
)
789
796
if ShouldBuild .training ():
0 commit comments