Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7467c6f

Browse filesBrowse files
authored
docs: tell how to do pyc-only builds (bazel-contrib#2417)
Someone one Slack asked if this was possible and how to do, so document it for better visibility. There's a lot of flags, so its easy to not see how to do this.
1 parent b304fc6 commit 7467c6f
Copy full SHA for 7467c6f

File tree

1 file changed

+24
-0
lines changed
Filter options

1 file changed

+24
-0
lines changed

‎docs/precompiling.md

Copy file name to clipboardExpand all lines: docs/precompiling.md
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ can use an opt-in or opt-out approach by setting its value:
3939
* targets must opt-out: `--@rules_python//python/config_settings:precompile=enabled`
4040
* targets must opt-in: `--@rules_python//python/config_settings:precompile=disabled`
4141

42+
## Pyc-only builds
43+
44+
A pyc-only build (aka "source less" builds) is when only `.pyc` files are
45+
included; the source `.py` files are not included.
46+
47+
To enable this, set
48+
{obj}`--@rules_python//python/config_settings:precompile_source_retention=omit_source`
49+
flag on the command line or the {attr}`precompile_source_retention=omit_source`
50+
attribute on specific targets.
51+
52+
The advantage of pyc-only builds are:
53+
* Fewer total files in a binary.
54+
* Imports _may_ be _slightly_ faster.
55+
56+
The disadvantages are:
57+
* Error messages will be less precise because the precise line and offset
58+
information isn't in an pyc file.
59+
* pyc files are Python major-version specific.
60+
61+
:::{note}
62+
pyc files are not a form of hiding source code. They are trivial to uncompile,
63+
and uncompiling them can recover almost the original source.
64+
:::
65+
4266
## Advanced precompiler customization
4367

4468
The default implementation of the precompiler is a persistent, multiplexed,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.