-
Notifications
You must be signed in to change notification settings - Fork 47
pycross_wheel_library: enable implicit namespace packages
#216
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") | ||
|
|
||
| bool_flag( | ||
| name = "default_enable_implicit_namespace_packages", | ||
| build_setting_default = False, | ||
| visibility = ["//visibility:public"], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| """Implementation of the pycross_wheel_library rule.""" | ||
|
|
||
| load("@bazel_skylib//lib:paths.bzl", "paths") | ||
| load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") | ||
| load("@rules_python//python:py_info.bzl", "PyInfo") | ||
| load(":providers.bzl", "PycrossWheelInfo") | ||
|
|
||
|
|
@@ -25,7 +26,10 @@ def _pycross_wheel_library_impl(ctx): | |
| inputs.append(name_file) | ||
| args.add("--wheel-name-file", name_file) | ||
|
|
||
| if ctx.attr.enable_implicit_namespace_pkgs: | ||
| enable_implicit_namespace_pkgs = ( | ||
| ctx.attr.enable_implicit_namespace_pkgs if enable_implicit_namespace_pkgs == -1 else ctx.attr._default_enable_implicit_namespace_pkgs[BuildSettingInfo].value | ||
| ) | ||
| if enable_implicit_namespace_pkgs: | ||
| args.add("--enable-implicit-namespace-pkgs") | ||
|
|
||
| for install_exclude_glob in ctx.attr.install_exclude_globs: | ||
|
|
@@ -111,13 +115,14 @@ pycross_wheel_library = rule( | |
| doc = "A list of patches to apply after installation.", | ||
| allow_files = True, | ||
| ), | ||
| "enable_implicit_namespace_pkgs": attr.bool( | ||
| default = True, | ||
| "enable_implicit_namespace_pkgs": attr.int( | ||
| default = -1, | ||
|
Comment on lines
+118
to
+119
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no tests for this option. I'd be happy to add some, but I'm not sure where they should go - in |
||
| doc = """ | ||
| If true, disables conversion of native namespace packages into pkg-util style namespace packages. When set all py_binary | ||
| and py_test targets must specify either `legacy_create_init=False` or the global Bazel option | ||
| `--incompatible_default_to_explicit_init_py` to prevent `__init__.py` being automatically generated in every directory. | ||
| This option is required to support some packages which cannot handle the conversion to pkg-util style. | ||
| This option is required to support some packages which cannot handle the conversion to pkg-util style. The default is | ||
| derived from the flag `@rules_pycross//config_settings:default_enable_implicit_namespace_pkgs`. | ||
| """, | ||
| ), | ||
| "python_version": attr.string( | ||
|
|
@@ -129,5 +134,8 @@ This option is required to support some packages which cannot handle the convers | |
| cfg = "exec", | ||
| executable = True, | ||
| ), | ||
| "_default_enable_implicit_namespace_pkgs": attr.label( | ||
| default = "//config_settings:default_enable_implicit_namespace_pkgs", | ||
| ), | ||
| }, | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, I wrote this doc by hand, it's not generated 😅 I couldn't figure out a way to use
stardocto generate docs for a Bazel flag. LMK if there's a preferred way to generate this doc.