@@ -311,10 +311,12 @@ def __init__(
311311 metadata : Metadata ,
312312 manifest : Dict [str , List [Tuple [pathlib .Path , str ]]],
313313 limited_api : bool ,
314+ shared_libs_win32 : bool ,
314315 ) -> None :
315316 self ._metadata = metadata
316317 self ._manifest = manifest
317318 self ._limited_api = limited_api
319+ self ._shared_libs_win32 = shared_libs_win32
318320
319321 @property
320322 def _has_internal_libs (self ) -> bool :
@@ -430,6 +432,9 @@ def _install_path(self, wheel_file: mesonpy._wheelfile.WheelFile, origin: Path,
430432
431433 if self ._has_internal_libs :
432434 if _is_native (origin ):
435+ if sys .platform == 'win32' and not self ._shared_libs_win32 :
436+ raise NotImplementedError (f'Bundling libraries in wheel is not supported on { sys .platform } ' )
437+
433438 # When an executable, libray, or Python extension module is
434439 # dynamically linked to a library built as part of the project,
435440 # Meson adds a library load path to it pointing to the build
@@ -566,6 +571,7 @@ def _string_or_path(value: Any, name: str) -> str:
566571 scheme = _table ({
567572 'meson' : _string_or_path ,
568573 'limited-api' : _bool ,
574+ 'shared-libs-win32' : _bool ,
569575 'args' : _table ({
570576 name : _strings for name in _MESON_ARGS_KEYS
571577 }),
@@ -757,6 +763,10 @@ def __init__(
757763 if not value :
758764 self ._limited_api = False
759765
766+ # Shared library support on Windows requires collaboration
767+ # from the package, make sure the developpers aknowledge this.
768+ self ._shared_libs_win32 = pyproject_config .get ('shared-libs-win32' , False )
769+
760770 def _run (self , cmd : Sequence [str ]) -> None :
761771 """Invoke a subprocess."""
762772 # Flush the line to ensure that the log line with the executed
@@ -920,13 +930,13 @@ def sdist(self, directory: Path) -> pathlib.Path:
920930 def wheel (self , directory : Path ) -> pathlib .Path :
921931 """Generates a wheel in the specified directory."""
922932 self .build ()
923- builder = _WheelBuilder (self ._metadata , self ._manifest , self ._limited_api )
933+ builder = _WheelBuilder (self ._metadata , self ._manifest , self ._limited_api , self . _shared_libs_win32 )
924934 return builder .build (directory )
925935
926936 def editable (self , directory : Path ) -> pathlib .Path :
927937 """Generates an editable wheel in the specified directory."""
928938 self .build ()
929- builder = _EditableWheelBuilder (self ._metadata , self ._manifest , self ._limited_api )
939+ builder = _EditableWheelBuilder (self ._metadata , self ._manifest , self ._limited_api , self . _shared_libs_win32 )
930940 return builder .build (directory , self ._source_dir , self ._build_dir , self ._build_command , self ._editable_verbose )
931941
932942
0 commit comments