-
Notifications
You must be signed in to change notification settings - Fork 4
Feature: Python Rules #92
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
Open
KetanReddy
wants to merge
16
commits into
main
Choose a base branch
from
feature/python-rules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sugarmanz
reviewed
Oct 3, 2025
sugarmanz
reviewed
Oct 3, 2025
505d8ac to
cbd5c35
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Python Pipeline
TLDR: An initial offering of a Python pipeline similar to our offerings for other languages to allow for easy integration into a Player Plugin.
Basics
This pipeline serves as a convenience wrapper around a lot of the
rules_pythonrules that allows for packages to be created that are more similar to the layout of our other language packages while still being compliant with the Python ecosystem.Setup/Requirements
MODULE.bazelYou'll need to add
aspect_bazel_lib,rules_pythonandplatformsto your bazel deps and configure the Python toolchain for rules_python (steps here) and dependencies (steps here). For most simple use cases the basicrequirements.txtapproach will work fine.Layout
Source code should be placed in a
srcfolder that is peer to theBUILDfile. Underneath it, is where a__init__.pyand your source code should live. Additionally, a__tests__folder should be created to contain the tests for the module. E.glibraryBUILDsrc__tests____init__.pytest_source.py__init__.pysource.pyBuild
Python files don't have a traditional build step but there is orchestration to create the standard python package layout and a local library target that can be referenced. Runtime dependencies should be supplied in the
depsattribute. Thenamesupplied to the pipeline will be what should be used to reference the library locally as well as what the library will be published as.Tests
Out of the box this pipelines offers unit and lint tests. Tests are orchestrated through pytest via a wrapper included in the rules.
Unit
Dependencies that are only required for unit tests can be provided via the
test_depsargument. Tests are orchestrated wholly, as in there is a single test target for all tests in the__tests__folder. Non test files and or non Python helper files (e.g static JSON file) can be placed in a subfolder called__helpers__that will be included in the test environment.Lint
Lint currently runs only across source code.
pytestlint plugins can be supplied via thelint_depsargument to customize the linting rules. Customization of those lint rules can be achieved by customizing the.pylintrcfile.Packaging
A virtual
requirement.txtfile will be created via the specified runtime dependencies. The version/ranges in the baserequirements.txtfile will be used for external packages and the exact version specified in theVERSIONfile will be used for intra-repository dependencies.The pipeline will produce a
.whlfile with name, version (provided via theVERSIONfile), and any additional kwargs supplied to the pipeline that match the args in the underlyingpy_wheelrule (docs here).The target to run the publish will be the
wheeltarget on the pipeline.Release Notes
Add
py_pipelinemacro to offer a simple, slightly opinionated, pipeline for building/testing Python libraries.