Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 716
build: Starlarkify python flags#3334
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
3b7c956d96804dd3f3dc0ede652ba2055d3d08e3745be1409ebebeca6c9f85561ec7d00c98f2dc0bdbfb98cffb6d99c8baaed97f68dcd6c936d31f64ff54d15b5a5a1623d027File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,6 +2,19 @@ workspace(name = "rules_python_gazelle_plugin") | ||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
| http_archive( | ||
| name = "bazel_skylib", | ||
| sha256 = "6e78f0e57de26801f6f564fa7c4a48dc8b36873e416257a92bbb0937eeac8446", | ||
| urls = [ | ||
| "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.8.2/bazel-skylib-1.8.2.tar.gz", | ||
dougthor42 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| "https://github.com/bazelbuild/bazel-skylib/releases/download/1.8.2/bazel-skylib-1.8.2.tar.gz", | ||
| ], | ||
| ) | ||
| load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") | ||
| bazel_skylib_workspace() | ||
| http_archive( | ||
| name = "io_bazel_rules_go", | ||
| sha256 = "9d72f7b8904128afb98d46bbef82ad7223ec9ff3718d419afb355fddd9f9484a", | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") | ||
| load("@pythons_hub//:versions.bzl", "DEFAULT_PYTHON_VERSION", "MINOR_MAPPING", "PYTHON_VERSIONS") | ||
| load("@rules_python_internal//:rules_python_config.bzl", "config") | ||
| load( | ||
| "//python/private:flags.bzl", | ||
| "AddSrcsToRunfilesFlag", | ||
| @@ -244,5 +245,28 @@ label_flag( | ||
| bool_flag( | ||
| name = "experimental_python_import_all_repositories", | ||
| build_setting_default = True, | ||
| scope = "universal", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| bool_flag( | ||
| name = "build_python_zip", | ||
| build_setting_default = config.build_python_zip_default, | ||
| help = "Build python executable zip. Defaults to on on Windows, off on other platforms", | ||
| scope = "universal", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| bool_flag( | ||
| name = "incompatible_default_to_explicit_init_py", | ||
| build_setting_default = False, | ||
| scope = "universal", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| string_flag( | ||
| name = "python_path", | ||
| build_setting_default = "python", | ||
| scope = "universal", | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
rickeylev marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7,6 +7,7 @@ labels = struct( | ||
| # keep sorted | ||
| ADD_SRCS_TO_RUNFILES = str(Label("//python/config_settings:add_srcs_to_runfiles")), | ||
| BOOTSTRAP_IMPL = str(Label("//python/config_settings:bootstrap_impl")), | ||
| BUILD_PYTHON_ZIP = str(Label("//python/config_settings:build_python_zip")), | ||
rickeylev marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| EXEC_TOOLS_TOOLCHAIN = str(Label("//python/config_settings:exec_tools_toolchain")), | ||
| PIP_ENV_MARKER_CONFIG = str(Label("//python/config_settings:pip_env_marker_config")), | ||
| NONE = str(Label("//python:none")), | ||
| @@ -18,6 +19,7 @@ labels = struct( | ||
| PRECOMPILE = str(Label("//python/config_settings:precompile")), | ||
| PRECOMPILE_SOURCE_RETENTION = str(Label("//python/config_settings:precompile_source_retention")), | ||
| PYC_COLLECTION = str(Label("//python/config_settings:pyc_collection")), | ||
| PYTHON_IMPORT_ALL_REPOSITORIES = str(Label("//python/config_settings:experimental_python_import_all_repositories")), | ||
| PYTHON_SRC = str(Label("//python/bin:python_src")), | ||
| PYTHON_VERSION = str(Label("//python/config_settings:python_version")), | ||
| PYTHON_VERSION_MAJOR_MINOR = str(Label("//python/config_settings:python_version_major_minor")), | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -77,6 +77,13 @@ EXECUTABLE_ATTRS = dicts.add( | ||
| AGNOSTIC_EXECUTABLE_ATTRS, | ||
| PY_SRCS_ATTRS, | ||
| IMPORTS_ATTRS, | ||
| # starlark flags attributes | ||
| { | ||
| "_build_python_zip_flag": attr.label(default = "//python/config_settings:build_python_zip"), | ||
| "_default_to_explicit_init_py_flag": attr.label(default = "//python/config_settings:incompatible_default_to_explicit_init_py"), | ||
| "_python_import_all_repositories_flag": attr.label(default = "//python/config_settings:experimental_python_import_all_repositories"), | ||
| "_python_path_flag": attr.label(default = "//python/config_settings:python_path"), | ||
| }, | ||
| { | ||
| "interpreter_args": lambda: attrb.StringList( | ||
| doc = """ | ||
| @@ -1136,6 +1143,9 @@ def _get_runtime_details(ctx, semantics): | ||
| # TOOD(bazelbuild/bazel#7901): Remove this once --python_path flag is removed. | ||
| flag_interpreter_path = read_possibly_native_flag(ctx, "python_path") | ||
| if not flag_interpreter_path.startswith("python") and not paths.is_absolute(flag_interpreter_path): | ||
rickeylev marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| fail("'python_path' must be an absolute path or a name to be resolved from the system PATH (e.g., 'python', 'python3').") | ||
| toolchain_runtime, effective_runtime = _maybe_get_runtime_from_ctx(ctx) | ||
| if not effective_runtime: | ||
| # Clear these just in case | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.