Skip to content

Repository files navigation

DISCLAIMER

This repository is not longer actively maintained due to the unwillingness of the eclipse governing body to grant the maintainers with the permissions needed to approve and merge pull requests of one another. As a consequence security vulnerabilities in the repository and its dependencies will not be fixed.

Bazel Rules Quality Python (bazel_tools_python)

This repository contains bazel integrations for python quality tools.

Offered Tools

Each offered tool has it own README document and can be independently activated and configured.

ToolTool TypeBazel TypeSupported LanguagesWorkspaceBzlmod
pylintCode linteraspectPythonyesno
ruff-checkCode linteraspectPythonyesyes
mypyCode type linteraspectPythonyesyes
blackCode formatteraspectPythonyesyes
ruff-formatCode formatteraspectPythonyesyes
isortImport formatteraspectPythonyesyes
pytestTest FrameworkaspectPythonyesyes
pycoverageCode coverage toolaspectPythonyesyes
pip_auditVulnerability checkerrulePythonyesyes

How to use bazel_tools_python

The next sections explain the steps to achieve a proper config for each Bazel dependency manager. For a fully working setup, take a look at the test workspace as an example.

Requirements

It's important to note that this repository does not supply python toolchains but only its pip dependencies. Therefore one must set up its own python toolchain. This repository support major python versions from 3.8 to 3.12.

Additionaly, one must have the following bazel repositories already in place:

  • bazel_skylib >= 1.7.1
  • rules_python >= 1.4.1

Select python pip hub version

To select the correct python dependency version one only needs to set a string_flag under one's .bazelrc file.

For example if one is using python 3.10, one should select our python 3.10 dependencies by adding the following lines to the respective .bazelrc file.

# .bazelrccommon--flag_alias=python=@rules_python//python/config_settings:python_versioncommon--python=3.10

Using WORKSPACE

Add this to your WORKSPACE file.

# WORKSPACEload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name="bazel_tools_python",
sha256="<omitted>",
urls= ["<domain>/bazel-tools-python/<version>/bazel-tools-python-<version>.tar.gz"],
)
load("@bazel_tools_python//third_party:python_toolchains.bzl", bazel_tools_python_python_toolchains="python_toolchains")
bazel_tools_python_python_toolchains()
load("@bazel_tools_python//third_party:python_pip_parse.bzl", bazel_tools_python_python_pip_parse="python_pip_parse")
bazel_tools_python_python_pip_parse()
load("@bazel_tools_python//third_party:python_pip_hub.bzl", bazel_tools_python_python_pip_hub="python_pip_hub")
bazel_tools_python_python_pip_hub()

Using bzlmod

Add this to your MODULE.bazel file.

# MODULE.bazelbazel_dep(name="score_bazel_tools_python", version="<version>", repo_name="bazel_tools_python")

To generate Bazel integrity value, one can use the following command:

openssl dgst -sha256 -binary bazel-tools-python-<version>.tar.gz | openssl base64 -A | sed 's/^/sha256-/'

Contributing

Please check our contributing guide.

About

Repository for python static code checker

Resources

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages