+
Skip to content

Resolve python prerequisites #44

@AlexanderLanin

Description

@AlexanderLanin

🧱 Simplify Usage of score_python_basics

🎯 Goal

Reduce the boilerplate needed to use score_python_basics by providing a single-line setup for consumers.


✅ Current Situation

  • Setting up Python with score_python_basics currently requires ~20 lines of boilerplate.
  • Users must manually configure rules_python, define toolchains, and parse requirements.txt.
  • This complexity creates friction, leads to inconsistencies, and clutters MODULE.bazel files.

Example of current usage:

# -- Python boilerplate --
PYTHON_VERSION = "3.12"
bazel_dep(name = "rules_python", version = "1.0.0")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(is_default = True, python_version = PYTHON_VERSION)
use_repo(python)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    hub_name = "pip",
    python_version = PYTHON_VERSION,
    requirements_lock = "//tools:requirements.txt",
)
use_repo(pip, "pip")
# -- End of Python boilerplate --

bazel_dep(name = "score_python_basics", version = "0.3.0")

🚀 Solution

Make score_python_basics self-contained and declarative. It should:

  • Automatically bring in rules_python with default configuration.
  • Provide a default pip.parse() setup.
  • Require minimal or no user-provided boilerplate.

Target usage: one bazel_dep and a single use_extension() call.


🛠️ Concrete Tasks

  • Provide a setup extension in score_python_basics (e.g. setup.bzl) that wraps rules_python and pip.
  • Add default toolchain registration and pip.parse() under the hood.
  • Document the new one-liner setup.
  • Migrate a few central repos (score, process_description, bazel_registry etc)

🔄 Considered Alternatives

Alternative: Keep the current boilerplate and document it more clearly.

Pros:

  • No implementation effort.
  • Explicit control remains with the user.

Cons:

  • Still tedious and error-prone.
  • Discourages adoption.
  • Leads to inconsistent setup across teams.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Ready-for-implementation

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载