Skip to content

Commit

Permalink
BLD Reduces size of wheels by stripping symbols (#25123)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjpfan committed Dec 7, 2022
1 parent e99cd11 commit 9527920
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/computing/parallelism.rst
Expand Up @@ -299,6 +299,13 @@ When this environment variable is set to a non zero value, the `Cython`
derivative, `boundscheck` is set to `True`. This is useful for finding
segfaults.

`SKLEARN_BUILD_ENABLE_DEBUG_SYMBOLS`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When this environment variable is set to a non zero value, the debug symbols
will be included in the compiled C extensions. Only debug symbols for POSIX
systems is configured.

`SKLEARN_PAIRWISE_DIST_CHUNK_SIZE`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
10 changes: 10 additions & 0 deletions setup.py
Expand Up @@ -509,6 +509,16 @@ def configure_extension_modules():
default_extra_compile_args = [f"/{optimization_level}"]
default_libraries = []

build_with_debug_symbols = (
os.environ.get("SKLEARN_BUILD_ENABLE_DEBUG_SYMBOLS", "0") != "0"
)
if os.name == "posix":
if build_with_debug_symbols:
default_extra_compile_args.append("-g")
else:
# Setting -g0 will strip symbols, reducing the binary size of extensions
default_extra_compile_args.append("-g0")

cython_exts = []
for submodule, extensions in extension_config.items():
submodule_parts = submodule.split(".")
Expand Down

0 comments on commit 9527920

Please sign in to comment.