Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BLD Reduces size of wheels by stripping symbols #25123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/computing/parallelism.rst
Original file line number Diff line number Diff line change
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.
Comment on lines +302 to +307
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't really belong to parallelism.rst though.

Copy link
Member Author

@thomasjpfan thomasjpfan Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this file is named parallelism.rst, the title is "Parallelism, resource management, and configuration". I'm guessing all the environment variables listed here fall under "configuration", which this PR adds onto.

Copy link
Member Author

@thomasjpfan thomasjpfan Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for discoverability, searching for "configuration" places the parallelism.rst page as second. I'm open to figuring out a better location for all the configuration options, but I do not think it is a blocker for this PR.


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

Expand Down
10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
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")
Comment on lines +516 to +517
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it not already set by default ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS+clang and Windows+MSCV, the debug symbols are stripped by default, which resulted in the ~9MB wheels on PyPI. With the new environment variable, I can enable debug symbols without changing the source on my local macOS machine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, right

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