Skip to content

Commit

Permalink
ENH: adjust default build options
Browse files Browse the repository at this point in the history
Switch from debug=false, optimization=2 to buildtype=release. Despite
what the Meson documentation says, the former does not change the
default buildtype=debug, which undesired effects on other settings
derived from the value of the buildtype option.

Whit the default b_vscrt=from_buildtype option, Meson instructs the
MSVC compiler to use the debug version of the VS runtime library when
buildtype=debug. This causes the linker look for the debug build of
all the linked DLLs. The Python distribution for Windows does not
contain a debug version of the python.dll and linking fails. To avoid
this issue when the user explicitly asks for a debug build, also set
b_vscrt=mt.

The b_ndebug=if-release option set by meson-python also looks at the
value of the buildtype and not to the value of the debug options.
Setting buildtype=release has the desired effect of disabling
assertions.

The prefix, python.purelibdir, and python.platlibdir build options are
no more necessary after the heuristic for determining the location
where installed files need to be placer from their installation
location has been removed in #280. Remove them.

Fixes #381.
  • Loading branch information
dnicolodi committed Apr 6, 2023
1 parent 936eee3 commit 123a198
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ py.install_sources(
'mesonpy/_dylib.py',
'mesonpy/_editable.py',
'mesonpy/_elf.py',
'mesonpy/_introspection.py',
'mesonpy/_tags.py',
'mesonpy/_util.py',
'mesonpy/_wheelfile.py',
Expand Down
20 changes: 4 additions & 16 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import mesonpy._compat
import mesonpy._dylib
import mesonpy._elf
import mesonpy._introspection
import mesonpy._tags
import mesonpy._util
import mesonpy._wheelfile
Expand Down Expand Up @@ -728,26 +727,15 @@ def _run(self, cmd: Sequence[str]) -> None:

def _configure(self, reconfigure: bool = False) -> None:
"""Configure Meson project."""
sys_paths = mesonpy._introspection.SYSCONFIG_PATHS
setup_args = [
f'--prefix={sys.base_prefix}',
os.fspath(self._source_dir),
os.fspath(self._build_dir),
f'--native-file={os.fspath(self._meson_native_file)}',
# TODO: Allow configuring these arguments
'-Ddebug=false',
# default build options
'-Dbuildtype=release',
'-Db_ndebug=if-release',
'-Doptimization=2',

# XXX: This should not be needed, but Meson is using the wrong paths
# in some scenarios, like on macOS.
# https://github.com/mesonbuild/meson-python/pull/87#discussion_r1047041306
'--python.purelibdir',
sys_paths['purelib'],
'--python.platlibdir',
sys_paths['platlib'],

# user args
'-Db_vscrt=md',
# user build options
*self._meson_args['setup'],
]
if reconfigure:
Expand Down
27 changes: 0 additions & 27 deletions mesonpy/_introspection.py

This file was deleted.

0 comments on commit 123a198

Please sign in to comment.