```
Currently the `WORKSPACE` file needs to be updated manually as per [Getting
started](#Getting-started) above.
Note that Starlark-defined bundled symbols underneath
`@bazel_tools//tools/python` are also deprecated. These are not yet rewritten
by buildifier.
rules_python-0.22.1/WORKSPACE 0000664 0000000 0000000 00000005747 14540404546 0015633 0 ustar 00root root 0000000 0000000 # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
workspace(name = "rules_python")
# Everything below this line is used only for developing rules_python. Users
# should not copy it to their WORKSPACE.
load("//:internal_deps.bzl", "rules_python_internal_deps")
rules_python_internal_deps()
load("//:internal_setup.bzl", "rules_python_internal_setup")
rules_python_internal_setup()
load("//python:repositories.bzl", "python_register_multi_toolchains")
load("//python:versions.bzl", "MINOR_MAPPING")
python_register_multi_toolchains(
name = "python",
default_version = MINOR_MAPPING.values()[-1],
python_versions = MINOR_MAPPING.values(),
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Used for Bazel CI
http_archive(
name = "bazelci_rules",
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
strip_prefix = "bazelci_rules-1.0.0",
url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
)
load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
# Creates a default toolchain config for RBE.
# Use this as is if you are using the rbe_ubuntu16_04 container,
# otherwise refer to RBE docs.
rbe_preconfig(
name = "buildkite_config",
toolchain = "ubuntu1804-bazel-java11",
)
local_repository(
name = "rules_python_gazelle_plugin",
path = "gazelle",
)
# The rules_python gazelle extension has some third-party go dependencies
# which we need to fetch in order to compile it.
load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
# See: https://github.com/bazelbuild/rules_python/blob/main/gazelle/README.md
# This rule loads and compiles various go dependencies that running gazelle
# for python requirements.
_py_gazelle_deps()
#####################
# Install twine for our own runfiles wheel publishing.
# Eventually we might want to install twine automatically for users too, see:
# https://github.com/bazelbuild/rules_python/issues/1016.
load("@python//3.11.1:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")
pip_parse(
name = "publish_deps",
python_interpreter_target = interpreter,
requirements_darwin = "//tools/publish:requirements_darwin.txt",
requirements_lock = "//tools/publish:requirements.txt",
requirements_windows = "//tools/publish:requirements_windows.txt",
)
load("@publish_deps//:requirements.bzl", "install_deps")
install_deps()
rules_python-0.22.1/addlicense.sh 0000775 0000000 0000000 00000001545 14540404546 0016774 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if ! command -v addlicense @>&1 >/dev/null; then
echo "ERROR: addlicense not installed."
echo "Install using https://github.com/google/addlicense#install"
exit 1
fi
addlicense -v -l apache -c 'The Bazel Authors. All rights reserved.' "$@"
rules_python-0.22.1/docs/ 0000775 0000000 0000000 00000000000 14540404546 0015265 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/docs/BUILD.bazel 0000664 0000000 0000000 00000010065 14540404546 0017145 0 ustar 00root root 0000000 0000000 # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
_DOCS = {
"packaging": "//docs:packaging-docs",
"pip": "//docs:pip-docs",
"pip_repository": "//docs:pip-repository",
"python": "//docs:core-docs",
}
# We define these bzl_library targets here rather than in the //python package
# because they're only used for doc generation. This way, we avoid requiring
# our users to depend on Skylib.
bzl_library(
name = "bazel_repo_tools",
srcs = [
"@bazel_tools//tools:bzl_srcs",
],
)
bzl_library(
name = "defs",
srcs = [
"//python:defs.bzl",
"//python/private:reexports.bzl",
],
deps = [
":bazel_repo_tools",
"//python:defs_bzl",
"//python/private:reexports_bzl",
],
)
bzl_library(
name = "pip_install_bzl",
srcs = [
"//python:bzl",
"//python/pip_install:bzl",
],
deps = [
":defs",
"//:version.bzl",
],
)
bzl_library(
name = "requirements_parser_bzl",
srcs = [
"//python/pip_install:requirements_parser.bzl",
],
)
bzl_library(
name = "packaging_bzl",
srcs = [
"//python:packaging.bzl",
"//python/private:py_package.bzl",
"//python/private:py_wheel.bzl",
"//python/private:stamp.bzl",
"//python/private:util.bzl",
],
deps = [
"//python/private:util_bzl",
],
)
# TODO: Stardoc does not guarantee consistent outputs accross platforms (Unix/Windows).
# As a result we do not build or test docs on Windows.
_NOT_WINDOWS = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
})
stardoc(
name = "core-docs",
out = "python.md_",
input = "//python:defs.bzl",
target_compatible_with = _NOT_WINDOWS,
deps = [":defs"],
)
stardoc(
name = "pip-docs",
out = "pip.md_",
input = "//python:pip.bzl",
target_compatible_with = _NOT_WINDOWS,
deps = [
":bazel_repo_tools",
":pip_install_bzl",
"@bazel_skylib//lib:versions",
],
)
stardoc(
name = "pip-repository",
out = "pip_repository.md_",
input = "//python/pip_install:pip_repository.bzl",
target_compatible_with = _NOT_WINDOWS,
deps = [
":bazel_repo_tools",
":pip_install_bzl",
":requirements_parser_bzl",
"@bazel_skylib//lib:versions",
],
)
stardoc(
name = "packaging-docs",
out = "packaging.md_",
input = "//python:packaging.bzl",
target_compatible_with = _NOT_WINDOWS,
deps = [":packaging_bzl"],
)
[
diff_test(
name = "check_" + k,
failure_message = "Please run: bazel run //docs:update",
file1 = k + ".md",
file2 = k + ".md_",
target_compatible_with = _NOT_WINDOWS,
)
for k in _DOCS.keys()
]
write_file(
name = "gen_update",
out = "update.sh",
content = [
"#!/usr/bin/env bash",
"cd $BUILD_WORKSPACE_DIRECTORY",
] + [
"cp -fv bazel-bin/docs/{0}.md_ docs/{0}.md".format(k)
for k in _DOCS.keys()
],
target_compatible_with = _NOT_WINDOWS,
)
sh_binary(
name = "update",
srcs = ["update.sh"],
data = _DOCS.values(),
target_compatible_with = _NOT_WINDOWS,
)
rules_python-0.22.1/docs/coverage.md 0000664 0000000 0000000 00000003510 14540404546 0017401 0 ustar 00root root 0000000 0000000 # Setting up coverage
As of Bazel 6, the Python toolchains and bootstrap logic supports providing
coverage information using the `coverage` library.
As of `rules_python` version `0.18.1`, builtin coverage support can be enabled
when configuring toolchains.
## Enabling `rules_python` coverage support
Enabling the coverage support bundled with `rules_python` just requires setting an
argument when registerting toolchains.
For Bzlmod:
```starlark
python.toolchain(
"@python3_9_toolchains//:all",
configure_coverage_tool = True,
)
```
For WORKSPACE configuration:
```starlark
python_register_toolchains(
register_coverage_tool = True,
)
```
NOTE: This will implicitly add the version of `coverage` bundled with
`rules_python` to the dependencies of `py_test` rules when `bazel coverage` is
run. If a target already transitively depends on a different version of
`coverage`, then behavior is undefined -- it is undefined which version comes
first in the import path. If you find yourself in this situation, then you'll
need to manually configure coverage (see below).
## Manually configuring coverage
To manually configure coverage support, you'll need to set the
`py_runtime.coverage_tool` attribute. This attribute is a target that specifies
the coverage entry point file and, optionally, client libraries that are added
to `py_test` targets. Typically, this would be a `filegroup` that looked like:
```starlark
filegroup(
name = "coverage",
srcs = ["coverage_main.py"],
data = ["coverage_lib1.py", ...]
)
```
Using `filegroup` isn't required, nor are including client libraries. The
important behaviors of the target are:
* It provides a single output file OR it provides an executable output; this
output is treated as the coverage entry point.
* If it provides runfiles, then `runfiles.files` are included into `py_test`.
rules_python-0.22.1/docs/packaging.md 0000775 0000000 0000000 00000032444 14540404546 0017545 0 ustar 00root root 0000000 0000000
Public API for for building wheels.
## py_package
py_package(name, deps, packages)
A rule to select all files in transitive dependencies of deps which
belong to given set of Python packages.
This rule is intended to be used as data dependency to py_wheel rule.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
| deps | - | List of labels | optional | [] |
| packages | List of Python packages to include in the distribution. Sub-packages are automatically included. | List of strings | optional | [] |
## py_wheel_dist
py_wheel_dist(name, out, wheel)
Prepare a dist/ folder, following Python's packaging standard practice.
See https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives
which recommends a dist/ folder containing the wheel file(s), source distributions, etc.
This also has the advantage that stamping information is included in the wheel's filename.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
| out | name of the resulting directory | String | required | |
| wheel | a [py_wheel rule](/docs/packaging.md#py_wheel_rule) | Label | optional | None |
## py_wheel_rule
py_wheel_rule(name, abi, author, author_email, classifiers, console_scripts, deps, description_file,
distribution, entry_points, extra_distinfo_files, extra_requires, homepage, license,
platform, python_requires, python_tag, requires, stamp, strip_path_prefixes, version)
Internal rule used by the [py_wheel macro](/docs/packaging.md#py_wheel).
These intentionally have the same name to avoid sharp edges with Bazel macros.
For example, a `bazel query` for a user's `py_wheel` macro expands to `py_wheel` targets,
in the way they expect.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
| abi | Python ABI tag. 'none' for pure-Python wheels. | String | optional | "none" |
| author | A string specifying the author of the package. | String | optional | "" |
| author_email | A string specifying the email address of the package author. | String | optional | "" |
| classifiers | A list of strings describing the categories for the package. For valid classifiers see https://pypi.org/classifiers | List of strings | optional | [] |
| console_scripts | Deprecated console_script entry points, e.g. {'main': 'examples.wheel.main:main'}.
Deprecated: prefer the entry_points attribute, which supports console_scripts as well as other entry points. | Dictionary: String -> String | optional | {} |
| deps | Targets to be included in the distribution.
The targets to package are usually py_library rules or filesets (for packaging data files).
Note it's usually better to package py_library targets and use entry_points attribute to specify console_scripts than to package py_binary rules. py_binary targets would wrap a executable script that tries to locate .runfiles directory which is not packaged in the wheel. | List of labels | optional | [] |
| description_file | A file containing text describing the package. | Label | optional | None |
| distribution | Name of the distribution.
This should match the project name onm PyPI. It's also the name that is used to refer to the package in other packages' dependencies. | String | required | |
| entry_points | entry_points, e.g. {'console_scripts': ['main = examples.wheel.main:main']}. | Dictionary: String -> List of strings | optional | {} |
| extra_distinfo_files | Extra files to add to distinfo directory in the archive. | Dictionary: Label -> String | optional | {} |
| extra_requires | List of optional requirements for this package | Dictionary: String -> List of strings | optional | {} |
| homepage | A string specifying the URL for the package homepage. | String | optional | "" |
| license | A string specifying the license of the package. | String | optional | "" |
| platform | Supported platform. Use 'any' for pure-Python wheel.
If you have included platform-specific data, such as a .pyd or .so extension module, you will need to specify the platform in standard pip format. If you support multiple platforms, you can define platform constraints, then use a select() to specify the appropriate specifier, eg:
platform = select({ "//platforms:windows_x86_64": "win_amd64", "//platforms:macos_x86_64": "macosx_10_7_x86_64", "//platforms:linux_x86_64": "manylinux2014_x86_64", }) | String | optional | "any" |
| python_requires | Python versions required by this distribution, e.g. '>=3.5,<3.7' | String | optional | "" |
| python_tag | Supported Python version(s), eg py3, cp35.cp36, etc | String | optional | "py3" |
| requires | List of requirements for this package. See the section on [Declaring required dependency](https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#declaring-dependencies) for details and examples of the format of this argument. | List of strings | optional | [] |
| stamp | Whether to encode build information into the wheel. Possible values:
- stamp = 1: Always stamp the build information into the wheel, even in [--nostamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.
- stamp = 0: Always replace build information by constant values. This gives good build result caching.
- stamp = -1: Embedding of build information is controlled by the [--[no]stamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) flag.
Stamped targets are not rebuilt unless their dependencies change. | Integer | optional | -1 |
| strip_path_prefixes | path prefixes to strip from files added to the generated package | List of strings | optional | [] |
| version | Version number of the package.
Note that this attribute supports stamp format strings as well as 'make variables'. For example: - version = "1.2.3-{BUILD_TIMESTAMP}" - version = "{BUILD_EMBED_LABEL}" - version = "$(VERSION)"
Note that Bazel's output filename cannot include the stamp information, as outputs must be known during the analysis phase and the stamp data is available only during the action execution.
The [py_wheel](/docs/packaging.md#py_wheel) macro produces a .dist-suffix target which creates a dist/ folder containing the wheel with the stamped name, suitable for publishing.
See [py_wheel_dist](/docs/packaging.md#py_wheel_dist) for more info. | String | required | |
## PyWheelInfo
PyWheelInfo(name_file, wheel)
Information about a wheel produced by `py_wheel`
**FIELDS**
| Name | Description |
| :------------- | :------------- |
| name_file | File: A file containing the canonical name of the wheel (after stamping, if enabled). |
| wheel | File: The wheel file itself. |
## py_wheel
py_wheel(name, twine, kwargs)
Builds a Python Wheel.
Wheels are Python distribution format defined in https://www.python.org/dev/peps/pep-0427/.
This macro packages a set of targets into a single wheel.
It wraps the [py_wheel rule](#py_wheel_rule).
Currently only pure-python wheels are supported.
Examples:
```python
# Package some specific py_library targets, without their dependencies
py_wheel(
name = "minimal_with_py_library",
# Package data. We're building "example_minimal_library-0.0.1-py3-none-any.whl"
distribution = "example_minimal_library",
python_tag = "py3",
version = "0.0.1",
deps = [
"//examples/wheel/lib:module_with_data",
"//examples/wheel/lib:simple_module",
],
)
# Use py_package to collect all transitive dependencies of a target,
# selecting just the files within a specific python package.
py_package(
name = "example_pkg",
# Only include these Python packages.
packages = ["examples.wheel"],
deps = [":main"],
)
py_wheel(
name = "minimal_with_py_package",
# Package data. We're building "example_minimal_package-0.0.1-py3-none-any.whl"
distribution = "example_minimal_package",
python_tag = "py3",
version = "0.0.1",
deps = [":example_pkg"],
)
```
To publish the wheel to Pypi, the twine package is required.
rules_python doesn't provide twine itself, see https://github.com/bazelbuild/rules_python/issues/1016
However you can install it with pip_parse, just like we do in the WORKSPACE file in rules_python.
Once you've installed twine, you can pass its label to the `twine` attribute of this macro,
to get a "[name].publish" target.
Example:
```python
py_wheel(
name = "my_wheel",
twine = "@publish_deps_twine//:pkg",
...
)
```
Now you can run a command like the following, which publishes to https://test.pypi.org/
```sh
% TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-*** \
bazel run --stamp --embed_label=1.2.4 -- \
//path/to:my_wheel.publish --repository testpypi
```
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| name | A unique name for this target. | none |
| twine | A label of the external location of the py_library target for twine | None |
| kwargs | other named parameters passed to the underlying [py_wheel rule](#py_wheel_rule) | none |
rules_python-0.22.1/docs/pip.md 0000664 0000000 0000000 00000033221 14540404546 0016400 0 ustar 00root root 0000000 0000000
Import pip requirements into Bazel.
## whl_library_alias
whl_library_alias(name, default_version, repo_mapping, version_map, wheel_name)
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this repository. | Name | required | |
| default_version | - | String | required | |
| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | |
| version_map | - | Dictionary: String -> String | required | |
| wheel_name | - | String | required | |
## compile_pip_requirements
compile_pip_requirements(name, extra_args, extra_deps, py_binary, py_test, requirements_in,
requirements_txt, requirements_darwin, requirements_linux,
requirements_windows, visibility, tags, kwargs)
Generates targets for managing pip dependencies with pip-compile.
By default this rules generates a filegroup named "[name]" which can be included in the data
of some other compile_pip_requirements rule that references these requirements
(e.g. with `-r ../other/requirements.txt`).
It also generates two targets for running pip-compile:
- validate with `bazel test [name]_test`
- update with `bazel run [name].update`
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| name | base name for generated targets, typically "requirements". | none |
| extra_args | passed to pip-compile. | [] |
| extra_deps | extra dependencies passed to pip-compile. | [] |
| py_binary | the py_binary rule to be used. | <function py_binary> |
| py_test | the py_test rule to be used. | <function py_test> |
| requirements_in | file expressing desired dependencies. | None |
| requirements_txt | result of "compiling" the requirements.in file. | None |
| requirements_darwin | File of darwin specific resolve output to check validate if requirement.in has changes. | None |
| requirements_linux | File of linux specific resolve output to check validate if requirement.in has changes. | None |
| requirements_windows | File of windows specific resolve output to check validate if requirement.in has changes. | None |
| visibility | passed to both the _test and .update rules. | ["//visibility:private"] |
| tags | tagging attribute common to all build rules, passed to both the _test and .update rules. | None |
| kwargs | other bazel attributes passed to the "_test" rule. | none |
## multi_pip_parse
multi_pip_parse(name, default_version, python_versions, python_interpreter_target,
requirements_lock, kwargs)
NOT INTENDED FOR DIRECT USE!
This is intended to be used by the multi_pip_parse implementation in the template of the
multi_toolchain_aliases repository rule.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| name | the name of the multi_pip_parse repository. | none |
| default_version | the default Python version. | none |
| python_versions | all Python toolchain versions currently registered. | none |
| python_interpreter_target | a dictionary which keys are Python versions and values are resolved host interpreters. | none |
| requirements_lock | a dictionary which keys are Python versions and values are locked requirements files. | none |
| kwargs | extra arguments passed to all wrapped pip_parse. | none |
**RETURNS**
The internal implementation of multi_pip_parse repository rule.
## package_annotation
package_annotation(additive_build_content, copy_files, copy_executables, data, data_exclude_glob,
srcs_exclude_glob)
Annotations to apply to the BUILD file content from package generated from a `pip_repository` rule.
[cf]: https://github.com/bazelbuild/bazel-skylib/blob/main/docs/copy_file_doc.md
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| additive_build_content | Raw text to add to the generated BUILD file of a package. | None |
| copy_files | A mapping of src and out files for [@bazel_skylib//rules:copy_file.bzl][cf] | {} |
| copy_executables | A mapping of src and out files for [@bazel_skylib//rules:copy_file.bzl][cf]. Targets generated here will also be flagged as executable. | {} |
| data | A list of labels to add as data dependencies to the generated py_library target. | [] |
| data_exclude_glob | A list of exclude glob patterns to add as data to the generated py_library target. | [] |
| srcs_exclude_glob | A list of labels to add as srcs to the generated py_library target. | [] |
**RETURNS**
str: A json encoded string of the provided content.
## pip_install
pip_install(requirements, name, kwargs)
Accepts a locked/compiled requirements file and installs the dependencies listed within.
```python
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
name = "pip_deps",
requirements = ":requirements.txt",
)
load("@pip_deps//:requirements.bzl", "install_deps")
install_deps()
```
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| requirements | A 'requirements.txt' pip requirements file. | None |
| name | A unique name for the created external repository (default 'pip'). | "pip" |
| kwargs | Additional arguments to the [pip_repository](./pip_repository.md) repository rule. | none |
## pip_parse
pip_parse(requirements, requirements_lock, name, kwargs)
Accepts a locked/compiled requirements file and installs the dependencies listed within.
Those dependencies become available in a generated `requirements.bzl` file.
You can instead check this `requirements.bzl` file into your repo, see the "vendoring" section below.
This macro wraps the [`pip_repository`](./pip_repository.md) rule that invokes `pip`.
In your WORKSPACE file:
```python
load("@rules_python//python:pip.bzl", "pip_parse")
pip_parse(
name = "pip_deps",
requirements_lock = ":requirements.txt",
)
load("@pip_deps//:requirements.bzl", "install_deps")
install_deps()
```
You can then reference installed dependencies from a `BUILD` file with:
```python
load("@pip_deps//:requirements.bzl", "requirement")
py_library(
name = "bar",
...
deps = [
"//my/other:dep",
requirement("requests"),
requirement("numpy"),
],
)
```
In addition to the `requirement` macro, which is used to access the generated `py_library`
target generated from a package's wheel, The generated `requirements.bzl` file contains
functionality for exposing [entry points][whl_ep] as `py_binary` targets as well.
[whl_ep]: https://packaging.python.org/specifications/entry-points/
```python
load("@pip_deps//:requirements.bzl", "entry_point")
alias(
name = "pip-compile",
actual = entry_point(
pkg = "pip-tools",
script = "pip-compile",
),
)
```
Note that for packages whose name and script are the same, only the name of the package
is needed when calling the `entry_point` macro.
```python
load("@pip_deps//:requirements.bzl", "entry_point")
alias(
name = "flake8",
actual = entry_point("flake8"),
)
```
## Vendoring the requirements.bzl file
In some cases you may not want to generate the requirements.bzl file as a repository rule
while Bazel is fetching dependencies. For example, if you produce a reusable Bazel module
such as a ruleset, you may want to include the requirements.bzl file rather than make your users
install the WORKSPACE setup to generate it.
See https://github.com/bazelbuild/rules_python/issues/608
This is the same workflow as Gazelle, which creates `go_repository` rules with
[`update-repos`](https://github.com/bazelbuild/bazel-gazelle#update-repos)
To do this, use the "write to source file" pattern documented in
https://blog.aspect.dev/bazel-can-write-to-the-source-folder
to put a copy of the generated requirements.bzl into your project.
Then load the requirements.bzl file directly rather than from the generated repository.
See the example in rules_python/examples/pip_parse_vendored.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| requirements | Deprecated. See requirements_lock. | None |
| requirements_lock | A fully resolved 'requirements.txt' pip requirement file containing the transitive set of your dependencies. If this file is passed instead of 'requirements' no resolve will take place and pip_repository will create individual repositories for each of your dependencies so that wheels are fetched/built only for the targets specified by 'build/run/test'. Note that if your lockfile is platform-dependent, you can use the requirements_[platform] attributes. | None |
| name | The name of the generated repository. The generated repositories containing each requirement will be of the form <name>_<requirement-name>. | "pip_parsed_deps" |
| kwargs | Additional arguments to the [pip_repository](./pip_repository.md) repository rule. | none |
rules_python-0.22.1/docs/pip_repository.md 0000664 0000000 0000000 00000051571 14540404546 0020707 0 ustar 00root root 0000000 0000000
## pip_repository
pip_repository(name, annotations, download_only, enable_implicit_namespace_pkgs, environment,
extra_pip_args, incompatible_generate_aliases, isolated, pip_data_exclude,
python_interpreter, python_interpreter_target, quiet, repo_mapping, repo_prefix,
requirements_darwin, requirements_linux, requirements_lock, requirements_windows,
timeout)
A rule for importing `requirements.txt` dependencies into Bazel.
This rule imports a `requirements.txt` file and generates a new
`requirements.bzl` file. This is used via the `WORKSPACE` pattern:
```python
pip_repository(
name = "foo",
requirements = ":requirements.txt",
)
```
You can then reference imported dependencies from your `BUILD` file with:
```python
load("@foo//:requirements.bzl", "requirement")
py_library(
name = "bar",
...
deps = [
"//my/other:dep",
requirement("requests"),
requirement("numpy"),
],
)
```
Or alternatively:
```python
load("@foo//:requirements.bzl", "all_requirements")
py_binary(
name = "baz",
...
deps = [
":foo",
] + all_requirements,
)
```
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this repository. | Name | required | |
| annotations | Optional annotations to apply to packages | Dictionary: String -> String | optional | {} |
| download_only | Whether to use "pip download" instead of "pip wheel". Disables building wheels from source, but allows use of --platform, --python-version, --implementation, and --abi in --extra_pip_args to download wheels for a different platform from the host platform. | Boolean | optional | False |
| enable_implicit_namespace_pkgs | 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. | Boolean | optional | False |
| environment | Environment variables to set in the pip subprocess. Can be used to set common variables such as http_proxy, https_proxy and no_proxy Note that pip is run with "--isolated" on the CLI so PIP_<VAR>_<NAME> style env vars are ignored, but env vars that control requests and urllib3 can be passed. | Dictionary: String -> String | optional | {} |
| extra_pip_args | Extra arguments to pass on to pip. Must not contain spaces. | List of strings | optional | [] |
| incompatible_generate_aliases | Allow generating aliases '@pip//<pkg>' -> '@pip_<pkg>//:pkg'. | Boolean | optional | False |
| isolated | Whether or not to pass the [--isolated](https://pip.pypa.io/en/stable/cli/pip/#cmdoption-isolated) flag to the underlying pip command. Alternatively, the RULES_PYTHON_PIP_ISOLATED environment variable can be used to control this flag. | Boolean | optional | True |
| pip_data_exclude | Additional data exclusion parameters to add to the pip packages BUILD file. | List of strings | optional | [] |
| python_interpreter | The python interpreter to use. This can either be an absolute path or the name of a binary found on the host's PATH environment variable. If no value is set python3 is defaulted for Unix systems and python.exe for Windows. | String | optional | "" |
| python_interpreter_target | If you are using a custom python interpreter built by another repository rule, use this attribute to specify its BUILD target. This allows pip_repository to invoke pip using the same interpreter as your toolchain. If set, takes precedence over python_interpreter. An example value: "@python3_x86_64-unknown-linux-gnu//:python". | Label | optional | None |
| quiet | If True, suppress printing stdout and stderr output to the terminal. | Boolean | optional | True |
| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | |
| repo_prefix | Prefix for the generated packages will be of the form @<prefix><sanitized-package-name>//... | String | optional | "" |
| requirements_darwin | Override the requirements_lock attribute when the host platform is Mac OS | Label | optional | None |
| requirements_linux | Override the requirements_lock attribute when the host platform is Linux | Label | optional | None |
| requirements_lock | A fully resolved 'requirements.txt' pip requirement file containing the transitive set of your dependencies. If this file is passed instead of 'requirements' no resolve will take place and pip_repository will create individual repositories for each of your dependencies so that wheels are fetched/built only for the targets specified by 'build/run/test'. | Label | optional | None |
| requirements_windows | Override the requirements_lock attribute when the host platform is Windows | Label | optional | None |
| timeout | Timeout (in seconds) on the rule's execution duration. | Integer | optional | 600 |
## pip_repository_bzlmod
pip_repository_bzlmod(name, incompatible_generate_aliases, repo_mapping, repo_name,
requirements_darwin, requirements_linux, requirements_lock,
requirements_windows)
A rule for bzlmod pip_repository creation. Intended for private use only.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this repository. | Name | required | |
| incompatible_generate_aliases | Allow generating aliases in '@pip//:<pkg>' -> '@pip_<pkg>//:pkg'. This replaces the aliases generated by the bzlmod tooling. | Boolean | optional | False |
| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | |
| repo_name | The apparent name of the repo. This is needed because in bzlmod, the name attribute becomes the canonical name | String | required | |
| requirements_darwin | Override the requirements_lock attribute when the host platform is Mac OS | Label | optional | None |
| requirements_linux | Override the requirements_lock attribute when the host platform is Linux | Label | optional | None |
| requirements_lock | A fully resolved 'requirements.txt' pip requirement file containing the transitive set of your dependencies. If this file is passed instead of 'requirements' no resolve will take place and pip_repository will create individual repositories for each of your dependencies so that wheels are fetched/built only for the targets specified by 'build/run/test'. | Label | optional | None |
| requirements_windows | Override the requirements_lock attribute when the host platform is Windows | Label | optional | None |
## whl_library
whl_library(name, annotation, download_only, enable_implicit_namespace_pkgs, environment,
extra_pip_args, isolated, pip_data_exclude, python_interpreter, python_interpreter_target,
quiet, repo, repo_mapping, repo_prefix, requirement, timeout)
Download and extracts a single wheel based into a bazel repo based on the requirement string passed in.
Instantiated from pip_repository and inherits config options from there.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this repository. | Name | required | |
| annotation | Optional json encoded file containing annotation to apply to the extracted wheel. See package_annotation | Label | optional | None |
| download_only | Whether to use "pip download" instead of "pip wheel". Disables building wheels from source, but allows use of --platform, --python-version, --implementation, and --abi in --extra_pip_args to download wheels for a different platform from the host platform. | Boolean | optional | False |
| enable_implicit_namespace_pkgs | 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. | Boolean | optional | False |
| environment | Environment variables to set in the pip subprocess. Can be used to set common variables such as http_proxy, https_proxy and no_proxy Note that pip is run with "--isolated" on the CLI so PIP_<VAR>_<NAME> style env vars are ignored, but env vars that control requests and urllib3 can be passed. | Dictionary: String -> String | optional | {} |
| extra_pip_args | Extra arguments to pass on to pip. Must not contain spaces. | List of strings | optional | [] |
| isolated | Whether or not to pass the [--isolated](https://pip.pypa.io/en/stable/cli/pip/#cmdoption-isolated) flag to the underlying pip command. Alternatively, the RULES_PYTHON_PIP_ISOLATED environment variable can be used to control this flag. | Boolean | optional | True |
| pip_data_exclude | Additional data exclusion parameters to add to the pip packages BUILD file. | List of strings | optional | [] |
| python_interpreter | The python interpreter to use. This can either be an absolute path or the name of a binary found on the host's PATH environment variable. If no value is set python3 is defaulted for Unix systems and python.exe for Windows. | String | optional | "" |
| python_interpreter_target | If you are using a custom python interpreter built by another repository rule, use this attribute to specify its BUILD target. This allows pip_repository to invoke pip using the same interpreter as your toolchain. If set, takes precedence over python_interpreter. An example value: "@python3_x86_64-unknown-linux-gnu//:python". | Label | optional | None |
| quiet | If True, suppress printing stdout and stderr output to the terminal. | Boolean | optional | True |
| repo | Pointer to parent repo name. Used to make these rules rerun if the parent repo changes. | String | required | |
| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | |
| repo_prefix | Prefix for the generated packages will be of the form @<prefix><sanitized-package-name>//... | String | optional | "" |
| requirement | Python requirement string describing the package to make available | String | required | |
| timeout | Timeout (in seconds) on the rule's execution duration. | Integer | optional | 600 |
## locked_requirements_label
locked_requirements_label(ctx, attr)
Get the preferred label for a locked requirements file based on platform.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| ctx | repository or module context | none |
| attr | attributes for the repo rule or tag extension | none |
**RETURNS**
Label
## package_annotation
package_annotation(additive_build_content, copy_files, copy_executables, data, data_exclude_glob,
srcs_exclude_glob)
Annotations to apply to the BUILD file content from package generated from a `pip_repository` rule.
[cf]: https://github.com/bazelbuild/bazel-skylib/blob/main/docs/copy_file_doc.md
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| additive_build_content | Raw text to add to the generated BUILD file of a package. | None |
| copy_files | A mapping of src and out files for [@bazel_skylib//rules:copy_file.bzl][cf] | {} |
| copy_executables | A mapping of src and out files for [@bazel_skylib//rules:copy_file.bzl][cf]. Targets generated here will also be flagged as executable. | {} |
| data | A list of labels to add as data dependencies to the generated py_library target. | [] |
| data_exclude_glob | A list of exclude glob patterns to add as data to the generated py_library target. | [] |
| srcs_exclude_glob | A list of labels to add as srcs to the generated py_library target. | [] |
**RETURNS**
str: A json encoded string of the provided content.
## use_isolated
use_isolated(ctx, attr)
Determine whether or not to pass the pip `--isolated` flag to the pip invocation.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| ctx | repository or module context | none |
| attr | attributes for the repo rule or tag extension | none |
**RETURNS**
True if --isolated should be passed
rules_python-0.22.1/docs/python.md 0000775 0000000 0000000 00000015145 14540404546 0017141 0 ustar 00root root 0000000 0000000
Core rules for building Python projects.
## current_py_toolchain
current_py_toolchain(name)
This rule exists so that the current python toolchain can be used in the `toolchains` attribute of
other rules, such as genrule. It allows exposing a python toolchain after toolchain resolution has
happened, to a rule which expects a concrete implementation of a toolchain, rather than a
toolchain_type which could be resolved to that toolchain.
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
## py_import
py_import(name, deps, srcs)
This rule allows the use of Python packages as dependencies.
It imports the given `.egg` file(s), which might be checked in source files,
fetched externally as with `http_file`, or produced as outputs of other rules.
It may be used like a `py_library`, in the `deps` of other Python rules.
This is similar to [java_import](https://docs.bazel.build/versions/master/be/java.html#java_import).
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
| deps | The list of other libraries to be linked in to the binary target. | List of labels | optional | [] |
| srcs | The list of Python package files provided to Python targets that depend on this target. Note that currently only the .egg format is accepted. For .whl files, try the whl_library rule. We accept contributions to extend py_import to handle .whl. | List of labels | optional | [] |
## py_binary
py_binary(attrs)
See the Bazel core [py_binary](https://docs.bazel.build/versions/master/be/python.html#py_binary) documentation.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| attrs | Rule attributes | none |
## py_library
py_library(attrs)
See the Bazel core [py_library](https://docs.bazel.build/versions/master/be/python.html#py_library) documentation.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| attrs | Rule attributes | none |
## py_runtime
py_runtime(attrs)
See the Bazel core [py_runtime](https://docs.bazel.build/versions/master/be/python.html#py_runtime) documentation.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| attrs | Rule attributes | none |
## py_runtime_pair
py_runtime_pair(name, py2_runtime, py3_runtime, attrs)
A toolchain rule for Python.
This used to wrap up to two Python runtimes, one for Python 2 and one for Python 3.
However, Python 2 is no longer supported, so it now only wraps a single Python 3
runtime.
Usually the wrapped runtimes are declared using the `py_runtime` rule, but any
rule returning a `PyRuntimeInfo` provider may be used.
This rule returns a `platform_common.ToolchainInfo` provider with the following
schema:
```python
platform_common.ToolchainInfo(
py2_runtime = None,
py3_runtime = <PyRuntimeInfo or None>,
)
```
Example usage:
```python
# In your BUILD file...
load("@rules_python//python:defs.bzl", "py_runtime_pair")
py_runtime(
name = "my_py3_runtime",
interpreter_path = "/system/python3",
python_version = "PY3",
)
py_runtime_pair(
name = "my_py_runtime_pair",
py3_runtime = ":my_py3_runtime",
)
toolchain(
name = "my_toolchain",
target_compatible_with = <...>,
toolchain = ":my_py_runtime_pair",
toolchain_type = "@rules_python//python:toolchain_type",
)
```
```python
# In your WORKSPACE...
register_toolchains("//my_pkg:my_toolchain")
```
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| name | str, the name of the target | none |
| py2_runtime | optional Label; must be unset or None; an error is raised otherwise. | None |
| py3_runtime | Label; a target with PyRuntimeInfo for Python 3. | None |
| attrs | Extra attrs passed onto the native rule | none |
## py_test
py_test(attrs)
See the Bazel core [py_test](https://docs.bazel.build/versions/master/be/python.html#py_test) documentation.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| attrs | Rule attributes | none |
## find_requirements
find_requirements(name)
The aspect definition. Can be invoked on the command line as
bazel build //pkg:my_py_binary_target --aspects=@rules_python//python:defs.bzl%find_requirements --output_groups=pyversioninfo
**ASPECT ATTRIBUTES**
| Name | Type |
| :------------- | :------------- |
| deps| String |
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| name | A unique name for this target. | Name | required | |
rules_python-0.22.1/examples/ 0000775 0000000 0000000 00000000000 14540404546 0016153 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/BUILD.bazel 0000664 0000000 0000000 00000003410 14540404546 0020027 0 ustar 00root root 0000000 0000000 # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("//tools/bazel_integration_test:bazel_integration_test.bzl", "bazel_integration_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
bazel_integration_test(
name = "build_file_generation_example",
timeout = "long",
)
bazel_integration_test(
name = "bzlmod_build_file_generation_example",
timeout = "long",
)
bazel_integration_test(
name = "pip_install_example",
timeout = "long",
)
bazel_integration_test(
name = "pip_parse_example",
timeout = "long",
)
bazel_integration_test(
name = "pip_parse_vendored_example",
timeout = "long",
tags = ["fix-windows"],
)
bazel_integration_test(
name = "pip_repository_annotations_example",
timeout = "long",
)
bazel_integration_test(
name = "py_proto_library_example",
timeout = "long",
)
bazel_integration_test(
name = "py_proto_library_example_bzlmod",
timeout = "long",
bzlmod = True,
dirname = "py_proto_library",
)
bazel_integration_test(
name = "multi_python_versions_example",
timeout = "long",
)
bazel_integration_test(
name = "bzlmod_example",
bzlmod = True,
override_bazel_version = "6.0.0",
)
rules_python-0.22.1/examples/build_file_generation/ 0000775 0000000 0000000 00000000000 14540404546 0022464 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/build_file_generation/.bazelrc 0000664 0000000 0000000 00000000232 14540404546 0024104 0 ustar 00root root 0000000 0000000 test --test_output=errors --enable_runfiles
# Windows requires these for multi-python support:
build --enable_runfiles
startup --windows_enable_symlinks
rules_python-0.22.1/examples/build_file_generation/.gitignore 0000664 0000000 0000000 00000000010 14540404546 0024443 0 ustar 00root root 0000000 0000000 bazel-*
rules_python-0.22.1/examples/build_file_generation/BUILD.bazel 0000664 0000000 0000000 00000007670 14540404546 0024354 0 ustar 00root root 0000000 0000000 # Load various rules so that we can have bazel download
# various rulesets and dependencies.
# The `load` statement imports the symbol for the rule, in the defined
# ruleset. When the symbol is loaded you can use the rule.
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock.txt",
requirements_windows = "requirements_windows.txt",
)
# This repository rule fetches the metadata for python packages we
# depend on. That data is required for the gazelle_python_manifest
# rule to update our manifest file.
# To see what this rule does, try `bazel run @modules_map//:print`
modules_mapping(
name = "modules_map",
exclude_patterns = [
"^_|(\\._)+", # This is the default.
"(\\.tests)+", # Add a custom one to get rid of the psutil tests.
],
wheels = all_whl_requirements,
)
# Gazelle python extension needs a manifest file mapping from
# an import to the installed package that provides it.
# This macro produces two targets:
# - //:gazelle_python_manifest.update can be used with `bazel run`
# to recalculate the manifest
# - //:gazelle_python_manifest.test is a test target ensuring that
# the manifest doesn't need to be updated
gazelle_python_manifest(
name = "gazelle_python_manifest",
modules_mapping = ":modules_map",
pip_repository_name = "pip",
requirements = "//:requirements_lock.txt",
# NOTE: we can use this flag in order to make our setup compatible with
# bzlmod.
use_pip_repository_aliases = True,
)
# Our gazelle target points to the python gazelle binary.
# This is the simple case where we only need one language supported.
# If you also had proto, go, or other gazelle-supported languages,
# you would also need a gazelle_binary rule.
# See https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.rst#example
gazelle(
name = "gazelle",
data = GAZELLE_PYTHON_RUNTIME_DEPS,
gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
# This rule is auto-generated and managed by Gazelle,
# because it found the __init__.py file in this folder.
# See: https://bazel.build/reference/be/python#py_library
py_library(
name = "build_file_generation",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
deps = [
"//random_number_generator",
"@pip//flask",
],
)
# A py_binary is an executable Python program consisting of a collection of .py source files.
# See: https://bazel.build/reference/be/python#py_binary
#
# This rule is auto-generated and managed by Gazelle,
# because it found the __main__.py file in this folder.
# This rule creates a target named //:build_file_generation_bin and you can use
# bazel to run the target:
# `bazel run //:build_file_generation_bin`
py_binary(
name = "build_file_generation_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [":build_file_generation"],
)
# A py_test is a Python unit test.
# See: https://bazel.build/reference/be/python#py_test
#
# This rule is auto-generated and managed by Gazelle,
# because it found the __test__.py file in this folder.
# This rule creates a target named //:build_file_generation_test and you can use
# bazel to run the target:
# `bazel test //:build_file_generation_test`
py_test(
name = "build_file_generation_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":build_file_generation"],
)
rules_python-0.22.1/examples/build_file_generation/README.md 0000664 0000000 0000000 00000001440 14540404546 0023742 0 ustar 00root root 0000000 0000000 # Build file generation with Gazelle
This example shows a project that has Gazelle setup with the rules_python
extension, so that targets like `py_library` and `py_binary` can be
automatically created just by running
```sh
bazel run //:requirements.update
bazel run //:gazelle_python_manifest.update
bazel run //:gazelle
```
As a demo, try creating a `__main__.py` file in this directory, then
re-run that gazelle command. You'll see that a `py_binary` target
is created in the `BUILD` file.
Or, try importing the `requests` library in `__init__.py`.
You'll see that `deps = ["@pip//pypi__requests"]` is automatically
added to the `py_library` target in the `BUILD` file.
For more information on the behavior of the rules_python gazelle extension,
see the README.md file in the /gazelle folder.
rules_python-0.22.1/examples/build_file_generation/WORKSPACE 0000664 0000000 0000000 00000012344 14540404546 0023751 0 ustar 00root root 0000000 0000000 # Set the name of the bazel workspace.
workspace(name = "build_file_generation_example")
# Load the http_archive rule so that we can have bazel download
# various rulesets and dependencies.
# The `load` statement imports the symbol for http_archive from the http.bzl
# file. When the symbol is loaded you can use the rule.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
######################################################################
# We need rules_go and bazel_gazelle, to build the gazelle plugin from source.
# Setup instructions for this section are at
# https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
# You may need to update the version of the rule, which is listed in the above
# documentation.
######################################################################
# Define an http_archive rule that will download the below ruleset,
# test the sha, and extract the ruleset to you local bazel cache.
http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
],
)
# Download the bazel_gazelle ruleset.
http_archive(
name = "bazel_gazelle",
sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
],
)
# Load rules_go ruleset and expose the toolchain and dep rules.
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
# go_rules_dependencies is a function that registers external dependencies
# needed by the Go rules.
# See: https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies
go_rules_dependencies()
# go_rules_dependencies is a function that registers external dependencies
# needed by the Go rules.
# See: https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies
go_register_toolchains(version = "1.19.4")
# The following call configured the gazelle dependencies, Go environment and Go SDK.
gazelle_dependencies()
# Remaining setup is for rules_python.
# DON'T COPY_PASTE THIS.
# Our example uses `local_repository` to point to the HEAD version of rules_python.
# Users should instead use the installation instructions from the release they use.
# See https://github.com/bazelbuild/rules_python/releases
local_repository(
name = "rules_python",
path = "../..",
)
local_repository(
name = "rules_python_gazelle_plugin",
path = "../../gazelle",
)
# Next we load the toolchain from rules_python.
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
# We now register a hermetic Python interpreter rather than relying on a system-installed interpreter.
# This toolchain will allow bazel to download a specific python version, and use that version
# for compilation.
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
# Load the interpreter and pip_parse rules.
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")
# This macro wraps the `pip_repository` rule that invokes `pip`, with `incremental` set.
# Accepts a locked/compiled requirements file and installs the dependencies listed within.
# Those dependencies become available in a generated `requirements.bzl` file.
# You can instead check this `requirements.bzl` file into your repo.
pip_parse(
name = "pip",
# Generate user friendly alias labels for each dependency that we have.
incompatible_generate_aliases = True,
# (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
# acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
# 1. Python interpreter that you compile in the build file.
# 2. Pre-compiled python interpreter included with http_archive.
# 3. Wrapper script, like in the autodetecting python toolchain.
#
# Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain.
python_interpreter_target = interpreter,
# Set the location of the lock file.
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
)
# Load the install_deps macro.
load("@pip//:requirements.bzl", "install_deps")
# Initialize repositories for all packages in requirements_lock.txt.
install_deps()
# The rules_python gazelle extension has some third-party go dependencies
# which we need to fetch in order to compile it.
load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
# See: https://github.com/bazelbuild/rules_python/blob/main/gazelle/README.md
# This rule loads and compiles various go dependencies that running gazelle
# for python requirements.
_py_gazelle_deps()
rules_python-0.22.1/examples/build_file_generation/__init__.py 0000664 0000000 0000000 00000001645 14540404546 0024603 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from flask import Flask, jsonify
from random_number_generator import generate_random_number
app = Flask(__name__)
@app.route('/random-number', methods=['GET'])
def get_random_number():
return jsonify({'number': generate_random_number.generate_random_number()})
"""Start the python web server"""
def main():
app.run()
rules_python-0.22.1/examples/build_file_generation/__main__.py 0000664 0000000 0000000 00000001236 14540404546 0024560 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __init__ import main
if __name__ == '__main__':
main()
rules_python-0.22.1/examples/build_file_generation/__test__.py 0000664 0000000 0000000 00000001742 14540404546 0024615 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from __init__ import app
class TestServer(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def test_get_random_number(self):
response = self.app.get('/random-number')
self.assertEqual(response.status_code, 200)
self.assertIn('number', response.json)
if __name__ == '__main__':
unittest.main()
rules_python-0.22.1/examples/build_file_generation/gazelle_python.yaml 0000664 0000000 0000000 00000006676 14540404546 0026413 0 ustar 00root root 0000000 0000000 # GENERATED FILE - DO NOT EDIT!
#
# To update this file, run:
# bazel run //:gazelle_python_manifest.update
manifest:
modules_mapping:
click: click
click.core: click
click.decorators: click
click.exceptions: click
click.formatting: click
click.globals: click
click.parser: click
click.shell_completion: click
click.termui: click
click.testing: click
click.types: click
click.utils: click
flask: Flask
flask.app: Flask
flask.blueprints: Flask
flask.cli: Flask
flask.config: Flask
flask.ctx: Flask
flask.debughelpers: Flask
flask.globals: Flask
flask.helpers: Flask
flask.json: Flask
flask.json.provider: Flask
flask.json.tag: Flask
flask.logging: Flask
flask.scaffold: Flask
flask.sessions: Flask
flask.signals: Flask
flask.templating: Flask
flask.testing: Flask
flask.typing: Flask
flask.views: Flask
flask.wrappers: Flask
importlib_metadata: importlib_metadata
itsdangerous: itsdangerous
itsdangerous.encoding: itsdangerous
itsdangerous.exc: itsdangerous
itsdangerous.serializer: itsdangerous
itsdangerous.signer: itsdangerous
itsdangerous.timed: itsdangerous
itsdangerous.url_safe: itsdangerous
jinja2: Jinja2
jinja2.async_utils: Jinja2
jinja2.bccache: Jinja2
jinja2.compiler: Jinja2
jinja2.constants: Jinja2
jinja2.debug: Jinja2
jinja2.defaults: Jinja2
jinja2.environment: Jinja2
jinja2.exceptions: Jinja2
jinja2.ext: Jinja2
jinja2.filters: Jinja2
jinja2.idtracking: Jinja2
jinja2.lexer: Jinja2
jinja2.loaders: Jinja2
jinja2.meta: Jinja2
jinja2.nativetypes: Jinja2
jinja2.nodes: Jinja2
jinja2.optimizer: Jinja2
jinja2.parser: Jinja2
jinja2.runtime: Jinja2
jinja2.sandbox: Jinja2
jinja2.utils: Jinja2
jinja2.visitor: Jinja2
markupsafe: MarkupSafe
werkzeug: Werkzeug
werkzeug.datastructures: Werkzeug
werkzeug.debug: Werkzeug
werkzeug.debug.console: Werkzeug
werkzeug.debug.repr: Werkzeug
werkzeug.debug.tbtools: Werkzeug
werkzeug.exceptions: Werkzeug
werkzeug.formparser: Werkzeug
werkzeug.http: Werkzeug
werkzeug.local: Werkzeug
werkzeug.middleware: Werkzeug
werkzeug.middleware.dispatcher: Werkzeug
werkzeug.middleware.http_proxy: Werkzeug
werkzeug.middleware.lint: Werkzeug
werkzeug.middleware.profiler: Werkzeug
werkzeug.middleware.proxy_fix: Werkzeug
werkzeug.middleware.shared_data: Werkzeug
werkzeug.routing: Werkzeug
werkzeug.routing.converters: Werkzeug
werkzeug.routing.exceptions: Werkzeug
werkzeug.routing.map: Werkzeug
werkzeug.routing.matcher: Werkzeug
werkzeug.routing.rules: Werkzeug
werkzeug.sansio: Werkzeug
werkzeug.sansio.http: Werkzeug
werkzeug.sansio.multipart: Werkzeug
werkzeug.sansio.request: Werkzeug
werkzeug.sansio.response: Werkzeug
werkzeug.sansio.utils: Werkzeug
werkzeug.security: Werkzeug
werkzeug.serving: Werkzeug
werkzeug.test: Werkzeug
werkzeug.testapp: Werkzeug
werkzeug.urls: Werkzeug
werkzeug.user_agent: Werkzeug
werkzeug.utils: Werkzeug
werkzeug.wrappers: Werkzeug
werkzeug.wrappers.request: Werkzeug
werkzeug.wrappers.response: Werkzeug
werkzeug.wsgi: Werkzeug
zipp: zipp
zipp.py310compat: zipp
pip_repository:
name: pip
use_pip_repository_aliases: true
integrity: 030d6d99b56c32d6577e616b617260d0a93588af791269162e43391a5a4fa576
rules_python-0.22.1/examples/build_file_generation/random_number_generator/ 0000775 0000000 0000000 00000000000 14540404546 0027362 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/build_file_generation/random_number_generator/BUILD.bazel 0000664 0000000 0000000 00000000660 14540404546 0031242 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "random_number_generator",
srcs = [
"__init__.py",
"generate_random_number.py",
],
imports = [".."],
visibility = ["//:__subpackages__"],
)
py_test(
name = "random_number_generator_test",
srcs = ["__test__.py"],
imports = [".."],
main = "__test__.py",
deps = [":random_number_generator"],
)
rules_python-0.22.1/examples/build_file_generation/random_number_generator/__init__.py 0000664 0000000 0000000 00000001134 14540404546 0031472 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rules_python-0.22.1/examples/build_file_generation/random_number_generator/__test__.py 0000664 0000000 0000000 00000001752 14540404546 0031514 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import random_number_generator.generate_random_number as generate_random_number
class TestRandomNumberGenerator(unittest.TestCase):
def test_generate_random_number(self):
number = generate_random_number.generate_random_number()
self.assertGreaterEqual(number, 1)
self.assertLessEqual(number, 10)
if __name__ == '__main__':
unittest.main()
rules_python-0.22.1/examples/build_file_generation/random_number_generator/generate_random_number.py0000664 0000000 0000000 00000001312 14540404546 0034433 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import random
"""Generate a random number"""
def generate_random_number():
return random.randint(1, 10)
rules_python-0.22.1/examples/build_file_generation/requirements.in 0000664 0000000 0000000 00000000006 14540404546 0025533 0 ustar 00root root 0000000 0000000 flask
rules_python-0.22.1/examples/build_file_generation/requirements_lock.txt 0000664 0000000 0000000 00000011653 14540404546 0026766 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
click==8.1.3 \
--hash=sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e \
--hash=sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48
# via flask
flask==2.2.2 \
--hash=sha256:642c450d19c4ad482f96729bd2a8f6d32554aa1e231f4f6b4e7e5264b16cca2b \
--hash=sha256:b9c46cc36662a7949f34b52d8ec7bb59c0d74ba08ba6cb9ce9adc1d8676d9526
# via -r requirements.in
importlib-metadata==5.2.0 \
--hash=sha256:0eafa39ba42bf225fc00e67f701d71f85aead9f878569caf13c3724f704b970f \
--hash=sha256:404d48d62bba0b7a77ff9d405efd91501bef2e67ff4ace0bed40a0cf28c3c7cd
# via flask
itsdangerous==2.1.2 \
--hash=sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44 \
--hash=sha256:5dbbc68b317e5e42f327f9021763545dc3fc3bfe22e6deb96aaf1fc38874156a
# via flask
jinja2==3.1.2 \
--hash=sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852 \
--hash=sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61
# via flask
markupsafe==2.1.1 \
--hash=sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003 \
--hash=sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88 \
--hash=sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5 \
--hash=sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7 \
--hash=sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a \
--hash=sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603 \
--hash=sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1 \
--hash=sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135 \
--hash=sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247 \
--hash=sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6 \
--hash=sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601 \
--hash=sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77 \
--hash=sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02 \
--hash=sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e \
--hash=sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63 \
--hash=sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f \
--hash=sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980 \
--hash=sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b \
--hash=sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812 \
--hash=sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff \
--hash=sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96 \
--hash=sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1 \
--hash=sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925 \
--hash=sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a \
--hash=sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6 \
--hash=sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e \
--hash=sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f \
--hash=sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4 \
--hash=sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f \
--hash=sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3 \
--hash=sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c \
--hash=sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a \
--hash=sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417 \
--hash=sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a \
--hash=sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a \
--hash=sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37 \
--hash=sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452 \
--hash=sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933 \
--hash=sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a \
--hash=sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7
# via
# jinja2
# werkzeug
werkzeug==2.2.2 \
--hash=sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f \
--hash=sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5
# via flask
zipp==3.11.0 \
--hash=sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa \
--hash=sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766
# via importlib-metadata
rules_python-0.22.1/examples/build_file_generation/requirements_windows.txt 0000664 0000000 0000000 00000012307 14540404546 0027525 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
click==8.1.3 \
--hash=sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e \
--hash=sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48
# via flask
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via click
flask==2.2.2 \
--hash=sha256:642c450d19c4ad482f96729bd2a8f6d32554aa1e231f4f6b4e7e5264b16cca2b \
--hash=sha256:b9c46cc36662a7949f34b52d8ec7bb59c0d74ba08ba6cb9ce9adc1d8676d9526
# via -r requirements.in
importlib-metadata==5.2.0 \
--hash=sha256:0eafa39ba42bf225fc00e67f701d71f85aead9f878569caf13c3724f704b970f \
--hash=sha256:404d48d62bba0b7a77ff9d405efd91501bef2e67ff4ace0bed40a0cf28c3c7cd
# via flask
itsdangerous==2.1.2 \
--hash=sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44 \
--hash=sha256:5dbbc68b317e5e42f327f9021763545dc3fc3bfe22e6deb96aaf1fc38874156a
# via flask
jinja2==3.1.2 \
--hash=sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852 \
--hash=sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61
# via flask
markupsafe==2.1.1 \
--hash=sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003 \
--hash=sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88 \
--hash=sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5 \
--hash=sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7 \
--hash=sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a \
--hash=sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603 \
--hash=sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1 \
--hash=sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135 \
--hash=sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247 \
--hash=sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6 \
--hash=sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601 \
--hash=sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77 \
--hash=sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02 \
--hash=sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e \
--hash=sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63 \
--hash=sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f \
--hash=sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980 \
--hash=sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b \
--hash=sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812 \
--hash=sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff \
--hash=sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96 \
--hash=sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1 \
--hash=sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925 \
--hash=sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a \
--hash=sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6 \
--hash=sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e \
--hash=sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f \
--hash=sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4 \
--hash=sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f \
--hash=sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3 \
--hash=sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c \
--hash=sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a \
--hash=sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417 \
--hash=sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a \
--hash=sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a \
--hash=sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37 \
--hash=sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452 \
--hash=sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933 \
--hash=sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a \
--hash=sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7
# via
# jinja2
# werkzeug
werkzeug==2.2.2 \
--hash=sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f \
--hash=sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5
# via flask
zipp==3.11.0 \
--hash=sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa \
--hash=sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766
# via importlib-metadata
rules_python-0.22.1/examples/bzlmod/ 0000775 0000000 0000000 00000000000 14540404546 0017442 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/.bazelignore 0000664 0000000 0000000 00000000015 14540404546 0021740 0 ustar 00root root 0000000 0000000 other_module
rules_python-0.22.1/examples/bzlmod/.bazelrc 0000664 0000000 0000000 00000000122 14540404546 0021060 0 ustar 00root root 0000000 0000000 common --experimental_enable_bzlmod
coverage --java_runtime_version=remotejdk_11
rules_python-0.22.1/examples/bzlmod/.bazelversion 0000664 0000000 0000000 00000000006 14540404546 0022142 0 ustar 00root root 0000000 0000000 6.0.0
rules_python-0.22.1/examples/bzlmod/.gitignore 0000664 0000000 0000000 00000000010 14540404546 0021421 0 ustar 00root root 0000000 0000000 bazel-*
rules_python-0.22.1/examples/bzlmod/BUILD.bazel 0000664 0000000 0000000 00000002454 14540404546 0021325 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@pip//:requirements.bzl", "all_requirements", "all_whl_requirements", "requirement")
load("@python3_9//:defs.bzl", py_test_with_transition = "py_test")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock.txt",
requirements_windows = "requirements_windows.txt",
)
py_library(
name = "lib",
srcs = ["lib.py"],
deps = [
requirement("pylint"),
requirement("tabulate"),
requirement("python-dateutil"),
],
)
py_binary(
name = "bzlmod",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [
":lib",
],
)
py_test(
name = "test",
srcs = ["test.py"],
main = "test.py",
deps = [":lib"],
)
py_test_with_transition(
name = "test_with_transition",
srcs = ["test.py"],
main = "test.py",
deps = [":lib"],
)
build_test(
name = "all_wheels",
targets = all_whl_requirements,
)
build_test(
name = "all_requirements",
targets = all_requirements,
)
rules_python-0.22.1/examples/bzlmod/MODULE.bazel 0000664 0000000 0000000 00000002652 14540404546 0021453 0 ustar 00root root 0000000 0000000 module(
name = "example_bzlmod",
version = "0.0.0",
compatibility_level = 1,
)
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "rules_python", version = "0.0.0")
local_path_override(
module_name = "rules_python",
path = "../..",
)
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
name = "python3_9",
configure_coverage_tool = True,
python_version = "3.9",
)
use_repo(python, "python3_9")
use_repo(python, "python3_9_toolchains")
register_toolchains(
"@python3_9_toolchains//:all",
)
interpreter = use_extension("@rules_python//python/extensions:interpreter.bzl", "interpreter")
interpreter.install(
name = "interpreter_python3_9",
python_name = "python3_9",
)
use_repo(interpreter, "interpreter_python3_9")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
name = "pip",
# Intentionally set it false because the "true" case is already covered by examples/bzlmod_build_file_generation
incompatible_generate_aliases = False,
python_interpreter_target = "@interpreter_python3_9//:python",
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
)
use_repo(pip, "pip")
bazel_dep(name = "other_module", version = "", repo_name = "our_other_module")
local_path_override(
module_name = "other_module",
path = "other_module",
)
rules_python-0.22.1/examples/bzlmod/WORKSPACE 0000664 0000000 0000000 00000000145 14540404546 0020723 0 ustar 00root root 0000000 0000000 # Empty file indicating the root of a Bazel workspace.
# Dependencies and setup are in MODULE.bazel.
rules_python-0.22.1/examples/bzlmod/__main__.py 0000664 0000000 0000000 00000001263 14540404546 0021536 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from lib import main
if __name__ == "__main__":
print(main([["A", 1], ["B", 2]]))
rules_python-0.22.1/examples/bzlmod/entry_point/ 0000775 0000000 0000000 00000000000 14540404546 0022014 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/entry_point/BUILD.bazel 0000664 0000000 0000000 00000000702 14540404546 0023671 0 ustar 00root root 0000000 0000000 load("@pip//:requirements.bzl", "entry_point")
load("@rules_python//python:defs.bzl", "py_test")
alias(
name = "yamllint",
actual = entry_point("yamllint"),
)
py_test(
name = "entry_point_test",
srcs = ["test_entry_point.py"],
data = [
":yamllint",
],
env = {
"YAMLLINT_ENTRY_POINT": "$(rlocationpath :yamllint)",
},
main = "test_entry_point.py",
deps = ["@rules_python//python/runfiles"],
)
rules_python-0.22.1/examples/bzlmod/entry_point/test_entry_point.py 0000664 0000000 0000000 00000002665 14540404546 0026010 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pathlib
import subprocess
import unittest
from python.runfiles import runfiles
class ExampleTest(unittest.TestCase):
def test_entry_point(self):
rlocation_path = os.environ.get("YAMLLINT_ENTRY_POINT")
assert (
rlocation_path is not None
), "expected 'YAMLLINT_ENTRY_POINT' env variable to be set to rlocation of the tool"
entry_point = pathlib.Path(runfiles.Create().Rlocation(rlocation_path))
self.assertTrue(entry_point.exists(), f"'{entry_point}' does not exist")
proc = subprocess.run(
[str(entry_point), "--version"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.28.0")
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/bzlmod/gazelle_python.yaml 0000664 0000000 0000000 00000051053 14540404546 0023356 0 ustar 00root root 0000000 0000000 # GENERATED FILE - DO NOT EDIT!
#
# To update this file, run:
# bazel run //:gazelle_python_manifest.update
manifest:
modules_mapping:
S3: s3cmd
S3.ACL: s3cmd
S3.AccessLog: s3cmd
S3.BidirMap: s3cmd
S3.CloudFront: s3cmd
S3.Config: s3cmd
S3.ConnMan: s3cmd
S3.Crypto: s3cmd
S3.Custom_httplib27: s3cmd
S3.Custom_httplib3x: s3cmd
S3.Exceptions: s3cmd
S3.ExitCodes: s3cmd
S3.FileDict: s3cmd
S3.FileLists: s3cmd
S3.HashCache: s3cmd
S3.MultiPart: s3cmd
S3.PkgInfo: s3cmd
S3.Progress: s3cmd
S3.S3: s3cmd
S3.S3Uri: s3cmd
S3.SortedDict: s3cmd
S3.Utils: s3cmd
astroid: astroid
astroid.arguments: astroid
astroid.astroid_manager: astroid
astroid.bases: astroid
astroid.brain: astroid
astroid.brain.brain_argparse: astroid
astroid.brain.brain_attrs: astroid
astroid.brain.brain_boto3: astroid
astroid.brain.brain_builtin_inference: astroid
astroid.brain.brain_collections: astroid
astroid.brain.brain_crypt: astroid
astroid.brain.brain_ctypes: astroid
astroid.brain.brain_curses: astroid
astroid.brain.brain_dataclasses: astroid
astroid.brain.brain_dateutil: astroid
astroid.brain.brain_fstrings: astroid
astroid.brain.brain_functools: astroid
astroid.brain.brain_gi: astroid
astroid.brain.brain_hashlib: astroid
astroid.brain.brain_http: astroid
astroid.brain.brain_hypothesis: astroid
astroid.brain.brain_io: astroid
astroid.brain.brain_mechanize: astroid
astroid.brain.brain_multiprocessing: astroid
astroid.brain.brain_namedtuple_enum: astroid
astroid.brain.brain_nose: astroid
astroid.brain.brain_numpy_core_einsumfunc: astroid
astroid.brain.brain_numpy_core_fromnumeric: astroid
astroid.brain.brain_numpy_core_function_base: astroid
astroid.brain.brain_numpy_core_multiarray: astroid
astroid.brain.brain_numpy_core_numeric: astroid
astroid.brain.brain_numpy_core_numerictypes: astroid
astroid.brain.brain_numpy_core_umath: astroid
astroid.brain.brain_numpy_ma: astroid
astroid.brain.brain_numpy_ndarray: astroid
astroid.brain.brain_numpy_random_mtrand: astroid
astroid.brain.brain_numpy_utils: astroid
astroid.brain.brain_pathlib: astroid
astroid.brain.brain_pkg_resources: astroid
astroid.brain.brain_pytest: astroid
astroid.brain.brain_qt: astroid
astroid.brain.brain_random: astroid
astroid.brain.brain_re: astroid
astroid.brain.brain_responses: astroid
astroid.brain.brain_scipy_signal: astroid
astroid.brain.brain_signal: astroid
astroid.brain.brain_six: astroid
astroid.brain.brain_sqlalchemy: astroid
astroid.brain.brain_ssl: astroid
astroid.brain.brain_subprocess: astroid
astroid.brain.brain_threading: astroid
astroid.brain.brain_type: astroid
astroid.brain.brain_typing: astroid
astroid.brain.brain_unittest: astroid
astroid.brain.brain_uuid: astroid
astroid.brain.helpers: astroid
astroid.builder: astroid
astroid.const: astroid
astroid.context: astroid
astroid.decorators: astroid
astroid.exceptions: astroid
astroid.filter_statements: astroid
astroid.helpers: astroid
astroid.inference: astroid
astroid.inference_tip: astroid
astroid.interpreter: astroid
astroid.interpreter.dunder_lookup: astroid
astroid.interpreter.objectmodel: astroid
astroid.manager: astroid
astroid.mixins: astroid
astroid.modutils: astroid
astroid.node_classes: astroid
astroid.nodes: astroid
astroid.nodes.as_string: astroid
astroid.nodes.const: astroid
astroid.nodes.node_classes: astroid
astroid.nodes.node_ng: astroid
astroid.nodes.scoped_nodes: astroid
astroid.nodes.scoped_nodes.mixin: astroid
astroid.nodes.scoped_nodes.scoped_nodes: astroid
astroid.nodes.scoped_nodes.utils: astroid
astroid.nodes.utils: astroid
astroid.objects: astroid
astroid.protocols: astroid
astroid.raw_building: astroid
astroid.rebuilder: astroid
astroid.scoped_nodes: astroid
astroid.test_utils: astroid
astroid.transforms: astroid
astroid.typing: astroid
astroid.util: astroid
certifi: certifi
certifi.core: certifi
chardet: chardet
chardet.big5freq: chardet
chardet.big5prober: chardet
chardet.chardistribution: chardet
chardet.charsetgroupprober: chardet
chardet.charsetprober: chardet
chardet.cli: chardet
chardet.cli.chardetect: chardet
chardet.codingstatemachine: chardet
chardet.compat: chardet
chardet.cp949prober: chardet
chardet.enums: chardet
chardet.escprober: chardet
chardet.escsm: chardet
chardet.eucjpprober: chardet
chardet.euckrfreq: chardet
chardet.euckrprober: chardet
chardet.euctwfreq: chardet
chardet.euctwprober: chardet
chardet.gb2312freq: chardet
chardet.gb2312prober: chardet
chardet.hebrewprober: chardet
chardet.jisfreq: chardet
chardet.jpcntx: chardet
chardet.langbulgarianmodel: chardet
chardet.langgreekmodel: chardet
chardet.langhebrewmodel: chardet
chardet.langhungarianmodel: chardet
chardet.langrussianmodel: chardet
chardet.langthaimodel: chardet
chardet.langturkishmodel: chardet
chardet.latin1prober: chardet
chardet.mbcharsetprober: chardet
chardet.mbcsgroupprober: chardet
chardet.mbcssm: chardet
chardet.metadata: chardet
chardet.metadata.languages: chardet
chardet.sbcharsetprober: chardet
chardet.sbcsgroupprober: chardet
chardet.sjisprober: chardet
chardet.universaldetector: chardet
chardet.utf8prober: chardet
chardet.version: chardet
dateutil: python_dateutil
dateutil.easter: python_dateutil
dateutil.parser: python_dateutil
dateutil.parser.isoparser: python_dateutil
dateutil.relativedelta: python_dateutil
dateutil.rrule: python_dateutil
dateutil.tz: python_dateutil
dateutil.tz.tz: python_dateutil
dateutil.tz.win: python_dateutil
dateutil.tzwin: python_dateutil
dateutil.utils: python_dateutil
dateutil.zoneinfo: python_dateutil
dateutil.zoneinfo.rebuild: python_dateutil
dill: dill
dill.detect: dill
dill.logger: dill
dill.objtypes: dill
dill.pointers: dill
dill.session: dill
dill.settings: dill
dill.source: dill
dill.temp: dill
idna: idna
idna.codec: idna
idna.compat: idna
idna.core: idna
idna.idnadata: idna
idna.intranges: idna
idna.package_data: idna
idna.uts46data: idna
isort: isort
isort.api: isort
isort.comments: isort
isort.core: isort
isort.deprecated: isort
isort.deprecated.finders: isort
isort.exceptions: isort
isort.files: isort
isort.format: isort
isort.hooks: isort
isort.identify: isort
isort.io: isort
isort.literal: isort
isort.logo: isort
isort.main: isort
isort.output: isort
isort.parse: isort
isort.place: isort
isort.profiles: isort
isort.pylama_isort: isort
isort.sections: isort
isort.settings: isort
isort.setuptools_commands: isort
isort.sorting: isort
isort.stdlibs: isort
isort.stdlibs.all: isort
isort.stdlibs.py2: isort
isort.stdlibs.py27: isort
isort.stdlibs.py3: isort
isort.stdlibs.py310: isort
isort.stdlibs.py311: isort
isort.stdlibs.py36: isort
isort.stdlibs.py37: isort
isort.stdlibs.py38: isort
isort.stdlibs.py39: isort
isort.utils: isort
isort.wrap: isort
isort.wrap_modes: isort
lazy_object_proxy: lazy_object_proxy
lazy_object_proxy.compat: lazy_object_proxy
lazy_object_proxy.simple: lazy_object_proxy
lazy_object_proxy.slots: lazy_object_proxy
lazy_object_proxy.utils: lazy_object_proxy
magic: python_magic
magic.compat: python_magic
magic.loader: python_magic
mccabe: mccabe
pathspec: pathspec
pathspec.gitignore: pathspec
pathspec.pathspec: pathspec
pathspec.pattern: pathspec
pathspec.patterns: pathspec
pathspec.patterns.gitwildmatch: pathspec
pathspec.util: pathspec
pkg_resources: setuptools
pkg_resources.extern: setuptools
platformdirs: platformdirs
platformdirs.android: platformdirs
platformdirs.api: platformdirs
platformdirs.macos: platformdirs
platformdirs.unix: platformdirs
platformdirs.version: platformdirs
platformdirs.windows: platformdirs
pylint: pylint
pylint.checkers: pylint
pylint.checkers.async: pylint
pylint.checkers.base: pylint
pylint.checkers.base.basic_checker: pylint
pylint.checkers.base.basic_error_checker: pylint
pylint.checkers.base.comparison_checker: pylint
pylint.checkers.base.docstring_checker: pylint
pylint.checkers.base.name_checker: pylint
pylint.checkers.base.name_checker.checker: pylint
pylint.checkers.base.name_checker.naming_style: pylint
pylint.checkers.base.pass_checker: pylint
pylint.checkers.base_checker: pylint
pylint.checkers.classes: pylint
pylint.checkers.classes.class_checker: pylint
pylint.checkers.classes.special_methods_checker: pylint
pylint.checkers.deprecated: pylint
pylint.checkers.design_analysis: pylint
pylint.checkers.dunder_methods: pylint
pylint.checkers.ellipsis_checker: pylint
pylint.checkers.exceptions: pylint
pylint.checkers.format: pylint
pylint.checkers.imports: pylint
pylint.checkers.lambda_expressions: pylint
pylint.checkers.logging: pylint
pylint.checkers.mapreduce_checker: pylint
pylint.checkers.method_args: pylint
pylint.checkers.misc: pylint
pylint.checkers.modified_iterating_checker: pylint
pylint.checkers.newstyle: pylint
pylint.checkers.non_ascii_names: pylint
pylint.checkers.raw_metrics: pylint
pylint.checkers.refactoring: pylint
pylint.checkers.refactoring.implicit_booleaness_checker: pylint
pylint.checkers.refactoring.not_checker: pylint
pylint.checkers.refactoring.recommendation_checker: pylint
pylint.checkers.refactoring.refactoring_checker: pylint
pylint.checkers.similar: pylint
pylint.checkers.spelling: pylint
pylint.checkers.stdlib: pylint
pylint.checkers.strings: pylint
pylint.checkers.threading_checker: pylint
pylint.checkers.typecheck: pylint
pylint.checkers.unicode: pylint
pylint.checkers.unsupported_version: pylint
pylint.checkers.utils: pylint
pylint.checkers.variables: pylint
pylint.config: pylint
pylint.config.argument: pylint
pylint.config.arguments_manager: pylint
pylint.config.arguments_provider: pylint
pylint.config.callback_actions: pylint
pylint.config.config_file_parser: pylint
pylint.config.config_initialization: pylint
pylint.config.configuration_mixin: pylint
pylint.config.deprecation_actions: pylint
pylint.config.environment_variable: pylint
pylint.config.exceptions: pylint
pylint.config.find_default_config_files: pylint
pylint.config.help_formatter: pylint
pylint.config.option: pylint
pylint.config.option_manager_mixin: pylint
pylint.config.option_parser: pylint
pylint.config.options_provider_mixin: pylint
pylint.config.utils: pylint
pylint.constants: pylint
pylint.epylint: pylint
pylint.exceptions: pylint
pylint.extensions: pylint
pylint.extensions.bad_builtin: pylint
pylint.extensions.broad_try_clause: pylint
pylint.extensions.check_elif: pylint
pylint.extensions.code_style: pylint
pylint.extensions.comparetozero: pylint
pylint.extensions.comparison_placement: pylint
pylint.extensions.confusing_elif: pylint
pylint.extensions.consider_ternary_expression: pylint
pylint.extensions.docparams: pylint
pylint.extensions.docstyle: pylint
pylint.extensions.empty_comment: pylint
pylint.extensions.emptystring: pylint
pylint.extensions.eq_without_hash: pylint
pylint.extensions.for_any_all: pylint
pylint.extensions.mccabe: pylint
pylint.extensions.no_self_use: pylint
pylint.extensions.overlapping_exceptions: pylint
pylint.extensions.private_import: pylint
pylint.extensions.redefined_loop_name: pylint
pylint.extensions.redefined_variable_type: pylint
pylint.extensions.set_membership: pylint
pylint.extensions.typing: pylint
pylint.extensions.while_used: pylint
pylint.graph: pylint
pylint.interfaces: pylint
pylint.lint: pylint
pylint.lint.base_options: pylint
pylint.lint.caching: pylint
pylint.lint.expand_modules: pylint
pylint.lint.message_state_handler: pylint
pylint.lint.parallel: pylint
pylint.lint.pylinter: pylint
pylint.lint.report_functions: pylint
pylint.lint.run: pylint
pylint.lint.utils: pylint
pylint.message: pylint
pylint.message.message: pylint
pylint.message.message_definition: pylint
pylint.message.message_definition_store: pylint
pylint.message.message_id_store: pylint
pylint.pyreverse: pylint
pylint.pyreverse.diadefslib: pylint
pylint.pyreverse.diagrams: pylint
pylint.pyreverse.dot_printer: pylint
pylint.pyreverse.inspector: pylint
pylint.pyreverse.main: pylint
pylint.pyreverse.mermaidjs_printer: pylint
pylint.pyreverse.plantuml_printer: pylint
pylint.pyreverse.printer: pylint
pylint.pyreverse.printer_factory: pylint
pylint.pyreverse.utils: pylint
pylint.pyreverse.vcg_printer: pylint
pylint.pyreverse.writer: pylint
pylint.reporters: pylint
pylint.reporters.base_reporter: pylint
pylint.reporters.collecting_reporter: pylint
pylint.reporters.json_reporter: pylint
pylint.reporters.multi_reporter: pylint
pylint.reporters.reports_handler_mix_in: pylint
pylint.reporters.text: pylint
pylint.reporters.ureports: pylint
pylint.reporters.ureports.base_writer: pylint
pylint.reporters.ureports.nodes: pylint
pylint.reporters.ureports.text_writer: pylint
pylint.testutils: pylint
pylint.testutils.checker_test_case: pylint
pylint.testutils.configuration_test: pylint
pylint.testutils.constants: pylint
pylint.testutils.decorator: pylint
pylint.testutils.functional: pylint
pylint.testutils.functional.find_functional_tests: pylint
pylint.testutils.functional.lint_module_output_update: pylint
pylint.testutils.functional.test_file: pylint
pylint.testutils.functional_test_file: pylint
pylint.testutils.get_test_info: pylint
pylint.testutils.global_test_linter: pylint
pylint.testutils.lint_module_test: pylint
pylint.testutils.output_line: pylint
pylint.testutils.pyreverse: pylint
pylint.testutils.reporter_for_tests: pylint
pylint.testutils.tokenize_str: pylint
pylint.testutils.unittest_linter: pylint
pylint.testutils.utils: pylint
pylint.typing: pylint
pylint.utils: pylint
pylint.utils.ast_walker: pylint
pylint.utils.docs: pylint
pylint.utils.file_state: pylint
pylint.utils.linterstats: pylint
pylint.utils.pragma_parser: pylint
pylint.utils.utils: pylint
requests: requests
requests.adapters: requests
requests.api: requests
requests.auth: requests
requests.certs: requests
requests.compat: requests
requests.cookies: requests
requests.exceptions: requests
requests.help: requests
requests.hooks: requests
requests.models: requests
requests.packages: requests
requests.sessions: requests
requests.status_codes: requests
requests.structures: requests
requests.utils: requests
setuptools: setuptools
setuptools.archive_util: setuptools
setuptools.build_meta: setuptools
setuptools.command: setuptools
setuptools.command.alias: setuptools
setuptools.command.bdist_egg: setuptools
setuptools.command.bdist_rpm: setuptools
setuptools.command.build: setuptools
setuptools.command.build_clib: setuptools
setuptools.command.build_ext: setuptools
setuptools.command.build_py: setuptools
setuptools.command.develop: setuptools
setuptools.command.dist_info: setuptools
setuptools.command.easy_install: setuptools
setuptools.command.editable_wheel: setuptools
setuptools.command.egg_info: setuptools
setuptools.command.install: setuptools
setuptools.command.install_egg_info: setuptools
setuptools.command.install_lib: setuptools
setuptools.command.install_scripts: setuptools
setuptools.command.py36compat: setuptools
setuptools.command.register: setuptools
setuptools.command.rotate: setuptools
setuptools.command.saveopts: setuptools
setuptools.command.sdist: setuptools
setuptools.command.setopt: setuptools
setuptools.command.test: setuptools
setuptools.command.upload: setuptools
setuptools.command.upload_docs: setuptools
setuptools.config: setuptools
setuptools.config.expand: setuptools
setuptools.config.pyprojecttoml: setuptools
setuptools.config.setupcfg: setuptools
setuptools.dep_util: setuptools
setuptools.depends: setuptools
setuptools.discovery: setuptools
setuptools.dist: setuptools
setuptools.errors: setuptools
setuptools.extension: setuptools
setuptools.extern: setuptools
setuptools.glob: setuptools
setuptools.installer: setuptools
setuptools.launch: setuptools
setuptools.logging: setuptools
setuptools.monkey: setuptools
setuptools.msvc: setuptools
setuptools.namespaces: setuptools
setuptools.package_index: setuptools
setuptools.py34compat: setuptools
setuptools.sandbox: setuptools
setuptools.unicode_utils: setuptools
setuptools.version: setuptools
setuptools.wheel: setuptools
setuptools.windows_support: setuptools
six: six
tabulate: tabulate
tabulate.version: tabulate
tomli: tomli
tomlkit: tomlkit
tomlkit.api: tomlkit
tomlkit.container: tomlkit
tomlkit.exceptions: tomlkit
tomlkit.items: tomlkit
tomlkit.parser: tomlkit
tomlkit.source: tomlkit
tomlkit.toml_char: tomlkit
tomlkit.toml_document: tomlkit
tomlkit.toml_file: tomlkit
typing_extensions: typing_extensions
urllib3: urllib3
urllib3.connection: urllib3
urllib3.connectionpool: urllib3
urllib3.contrib: urllib3
urllib3.contrib.appengine: urllib3
urllib3.contrib.ntlmpool: urllib3
urllib3.contrib.pyopenssl: urllib3
urllib3.contrib.securetransport: urllib3
urllib3.contrib.socks: urllib3
urllib3.exceptions: urllib3
urllib3.fields: urllib3
urllib3.filepost: urllib3
urllib3.packages: urllib3
urllib3.packages.backports: urllib3
urllib3.packages.backports.makefile: urllib3
urllib3.packages.six: urllib3
urllib3.poolmanager: urllib3
urllib3.request: urllib3
urllib3.response: urllib3
urllib3.util: urllib3
urllib3.util.connection: urllib3
urllib3.util.proxy: urllib3
urllib3.util.queue: urllib3
urllib3.util.request: urllib3
urllib3.util.response: urllib3
urllib3.util.retry: urllib3
urllib3.util.ssl_: urllib3
urllib3.util.ssl_match_hostname: urllib3
urllib3.util.ssltransport: urllib3
urllib3.util.timeout: urllib3
urllib3.util.url: urllib3
urllib3.util.wait: urllib3
wrapt: wrapt
wrapt.arguments: wrapt
wrapt.decorators: wrapt
wrapt.importer: wrapt
wrapt.wrappers: wrapt
yaml: PyYAML
yaml.composer: PyYAML
yaml.constructor: PyYAML
yaml.cyaml: PyYAML
yaml.dumper: PyYAML
yaml.emitter: PyYAML
yaml.error: PyYAML
yaml.events: PyYAML
yaml.loader: PyYAML
yaml.nodes: PyYAML
yaml.parser: PyYAML
yaml.reader: PyYAML
yaml.representer: PyYAML
yaml.resolver: PyYAML
yaml.scanner: PyYAML
yaml.serializer: PyYAML
yaml.tokens: PyYAML
yamllint: yamllint
yamllint.cli: yamllint
yamllint.config: yamllint
yamllint.linter: yamllint
yamllint.parser: yamllint
yamllint.rules: yamllint
yamllint.rules.braces: yamllint
yamllint.rules.brackets: yamllint
yamllint.rules.colons: yamllint
yamllint.rules.commas: yamllint
yamllint.rules.comments: yamllint
yamllint.rules.comments_indentation: yamllint
yamllint.rules.common: yamllint
yamllint.rules.document_end: yamllint
yamllint.rules.document_start: yamllint
yamllint.rules.empty_lines: yamllint
yamllint.rules.empty_values: yamllint
yamllint.rules.float_values: yamllint
yamllint.rules.hyphens: yamllint
yamllint.rules.indentation: yamllint
yamllint.rules.key_duplicates: yamllint
yamllint.rules.key_ordering: yamllint
yamllint.rules.line_length: yamllint
yamllint.rules.new_line_at_end_of_file: yamllint
yamllint.rules.new_lines: yamllint
yamllint.rules.octal_values: yamllint
yamllint.rules.quoted_strings: yamllint
yamllint.rules.trailing_spaces: yamllint
yamllint.rules.truthy: yamllint
pip_repository:
name: pip
use_pip_repository_aliases: true
integrity: d979738b10adbbaff0884837e4414688990491c6c40f6a25d58b9bb564411477
rules_python-0.22.1/examples/bzlmod/lib.py 0000664 0000000 0000000 00000001250 14540404546 0020560 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from tabulate import tabulate
def main(table):
return tabulate(table)
rules_python-0.22.1/examples/bzlmod/other_module/ 0000775 0000000 0000000 00000000000 14540404546 0022130 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/other_module/MODULE.bazel 0000664 0000000 0000000 00000000125 14540404546 0024132 0 ustar 00root root 0000000 0000000 module(
name = "other_module",
)
bazel_dep(name = "rules_python", version = "")
rules_python-0.22.1/examples/bzlmod/other_module/WORKSPACE 0000664 0000000 0000000 00000000000 14540404546 0023377 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/other_module/other_module/ 0000775 0000000 0000000 00000000000 14540404546 0024616 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/other_module/other_module/pkg/ 0000775 0000000 0000000 00000000000 14540404546 0025377 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/other_module/other_module/pkg/BUILD.bazel 0000664 0000000 0000000 00000000406 14540404546 0027255 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "lib",
srcs = ["lib.py"],
data = ["data/data.txt"],
visibility = ["//visibility:public"],
deps = ["@rules_python//python/runfiles"],
)
exports_files(["data/data.txt"])
rules_python-0.22.1/examples/bzlmod/other_module/other_module/pkg/data/ 0000775 0000000 0000000 00000000000 14540404546 0026310 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/other_module/other_module/pkg/data/data.txt 0000664 0000000 0000000 00000000025 14540404546 0027757 0 ustar 00root root 0000000 0000000 Hello, other_module!
rules_python-0.22.1/examples/bzlmod/other_module/other_module/pkg/lib.py 0000664 0000000 0000000 00000002044 14540404546 0026517 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from python.runfiles import runfiles
def GetRunfilePathWithCurrentRepository():
r = runfiles.Create()
own_repo = r.CurrentRepository()
# For a non-main repository, the name of the runfiles directory is equal to
# the canonical repository name.
return r.Rlocation(own_repo + "/other_module/pkg/data/data.txt")
def GetRunfilePathWithRepoMapping():
return runfiles.Create().Rlocation("other_module/other_module/pkg/data/data.txt")
rules_python-0.22.1/examples/bzlmod/requirements.in 0000664 0000000 0000000 00000000145 14540404546 0022515 0 ustar 00root root 0000000 0000000 requests~=2.25.1
s3cmd~=2.1.0
yamllint>=1.28.0
tabulate~=0.9.0
pylint~=2.15.5
python-dateutil>=2.8.2
rules_python-0.22.1/examples/bzlmod/requirements_lock.txt 0000664 0000000 0000000 00000035714 14540404546 0023750 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
astroid==2.12.13 \
--hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \
--hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7
# via pylint
certifi==2022.12.7 \
--hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \
--hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18
# via requests
chardet==4.0.0 \
--hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \
--hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5
# via requests
dill==0.3.6 \
--hash=sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0 \
--hash=sha256:e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373
# via pylint
idna==2.10 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
# via requests
isort==5.11.4 \
--hash=sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6 \
--hash=sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b
# via pylint
lazy-object-proxy==1.8.0 \
--hash=sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada \
--hash=sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d \
--hash=sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7 \
--hash=sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe \
--hash=sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd \
--hash=sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c \
--hash=sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858 \
--hash=sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288 \
--hash=sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec \
--hash=sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f \
--hash=sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891 \
--hash=sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c \
--hash=sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25 \
--hash=sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156 \
--hash=sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8 \
--hash=sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f \
--hash=sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e \
--hash=sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0 \
--hash=sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b
# via astroid
mccabe==0.7.0 \
--hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \
--hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e
# via pylint
pathspec==0.10.3 \
--hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \
--hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6
# via yamllint
platformdirs==2.6.0 \
--hash=sha256:1a89a12377800c81983db6be069ec068eee989748799b946cce2a6e80dcc54ca \
--hash=sha256:b46ffafa316e6b83b47489d240ce17173f123a9b9c83282141c3daf26ad9ac2e
# via pylint
pylint==2.15.9 \
--hash=sha256:18783cca3cfee5b83c6c5d10b3cdb66c6594520ffae61890858fe8d932e1c6b4 \
--hash=sha256:349c8cd36aede4d50a0754a8c0218b43323d13d5d88f4b2952ddfe3e169681eb
# via -r requirements.in
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via
# -r requirements.in
# s3cmd
python-magic==0.4.27 \
--hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \
--hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3
# via s3cmd
pyyaml==6.0 \
--hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
requests==2.25.1 \
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e
# via -r requirements.in
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via yamllint
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
tabulate==0.9.0 \
--hash=sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c \
--hash=sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f
# via -r requirements.in
tomli==2.0.1 \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
# via pylint
tomlkit==0.11.6 \
--hash=sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b \
--hash=sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73
# via pylint
typing-extensions==4.4.0 \
--hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \
--hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e
# via
# astroid
# pylint
urllib3==1.26.13 \
--hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \
--hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8
# via requests
wrapt==1.14.1 \
--hash=sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3 \
--hash=sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b \
--hash=sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4 \
--hash=sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2 \
--hash=sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656 \
--hash=sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3 \
--hash=sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff \
--hash=sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310 \
--hash=sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a \
--hash=sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57 \
--hash=sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069 \
--hash=sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383 \
--hash=sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe \
--hash=sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87 \
--hash=sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d \
--hash=sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b \
--hash=sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907 \
--hash=sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f \
--hash=sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0 \
--hash=sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28 \
--hash=sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1 \
--hash=sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853 \
--hash=sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc \
--hash=sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3 \
--hash=sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3 \
--hash=sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164 \
--hash=sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1 \
--hash=sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c \
--hash=sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1 \
--hash=sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7 \
--hash=sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1 \
--hash=sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320 \
--hash=sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed \
--hash=sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1 \
--hash=sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248 \
--hash=sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c \
--hash=sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456 \
--hash=sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77 \
--hash=sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef \
--hash=sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1 \
--hash=sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7 \
--hash=sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86 \
--hash=sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4 \
--hash=sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d \
--hash=sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d \
--hash=sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8 \
--hash=sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5 \
--hash=sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471 \
--hash=sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00 \
--hash=sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68 \
--hash=sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3 \
--hash=sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d \
--hash=sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735 \
--hash=sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d \
--hash=sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569 \
--hash=sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7 \
--hash=sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59 \
--hash=sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5 \
--hash=sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb \
--hash=sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b \
--hash=sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f \
--hash=sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462 \
--hash=sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015 \
--hash=sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af
# via astroid
yamllint==1.28.0 \
--hash=sha256:89bb5b5ac33b1ade059743cf227de73daa34d5e5a474b06a5e17fc16583b0cf2 \
--hash=sha256:9e3d8ddd16d0583214c5fdffe806c9344086721f107435f68bad990e5a88826b
# via -r requirements.in
rules_python-0.22.1/examples/bzlmod/requirements_windows.txt 0000664 0000000 0000000 00000036227 14540404546 0024512 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
astroid==2.12.13 \
--hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \
--hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7
# via pylint
certifi==2022.12.7 \
--hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \
--hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18
# via requests
chardet==4.0.0 \
--hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \
--hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5
# via requests
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via pylint
dill==0.3.6 \
--hash=sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0 \
--hash=sha256:e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373
# via pylint
idna==2.10 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
# via requests
isort==5.11.4 \
--hash=sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6 \
--hash=sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b
# via pylint
lazy-object-proxy==1.8.0 \
--hash=sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada \
--hash=sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d \
--hash=sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7 \
--hash=sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe \
--hash=sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd \
--hash=sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c \
--hash=sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858 \
--hash=sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288 \
--hash=sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec \
--hash=sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f \
--hash=sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891 \
--hash=sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c \
--hash=sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25 \
--hash=sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156 \
--hash=sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8 \
--hash=sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f \
--hash=sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e \
--hash=sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0 \
--hash=sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b
# via astroid
mccabe==0.7.0 \
--hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \
--hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e
# via pylint
pathspec==0.10.3 \
--hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \
--hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6
# via yamllint
platformdirs==2.6.0 \
--hash=sha256:1a89a12377800c81983db6be069ec068eee989748799b946cce2a6e80dcc54ca \
--hash=sha256:b46ffafa316e6b83b47489d240ce17173f123a9b9c83282141c3daf26ad9ac2e
# via pylint
pylint==2.15.9 \
--hash=sha256:18783cca3cfee5b83c6c5d10b3cdb66c6594520ffae61890858fe8d932e1c6b4 \
--hash=sha256:349c8cd36aede4d50a0754a8c0218b43323d13d5d88f4b2952ddfe3e169681eb
# via -r requirements.in
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via
# -r requirements.in
# s3cmd
python-magic==0.4.27 \
--hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \
--hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3
# via s3cmd
pyyaml==6.0 \
--hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
requests==2.25.1 \
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e
# via -r requirements.in
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via yamllint
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
tabulate==0.9.0 \
--hash=sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c \
--hash=sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f
# via -r requirements.in
tomli==2.0.1 \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
# via pylint
tomlkit==0.11.6 \
--hash=sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b \
--hash=sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73
# via pylint
typing-extensions==4.4.0 \
--hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \
--hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e
# via
# astroid
# pylint
urllib3==1.26.13 \
--hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \
--hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8
# via requests
wrapt==1.14.1 \
--hash=sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3 \
--hash=sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b \
--hash=sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4 \
--hash=sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2 \
--hash=sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656 \
--hash=sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3 \
--hash=sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff \
--hash=sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310 \
--hash=sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a \
--hash=sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57 \
--hash=sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069 \
--hash=sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383 \
--hash=sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe \
--hash=sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87 \
--hash=sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d \
--hash=sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b \
--hash=sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907 \
--hash=sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f \
--hash=sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0 \
--hash=sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28 \
--hash=sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1 \
--hash=sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853 \
--hash=sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc \
--hash=sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3 \
--hash=sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3 \
--hash=sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164 \
--hash=sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1 \
--hash=sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c \
--hash=sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1 \
--hash=sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7 \
--hash=sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1 \
--hash=sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320 \
--hash=sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed \
--hash=sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1 \
--hash=sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248 \
--hash=sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c \
--hash=sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456 \
--hash=sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77 \
--hash=sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef \
--hash=sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1 \
--hash=sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7 \
--hash=sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86 \
--hash=sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4 \
--hash=sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d \
--hash=sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d \
--hash=sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8 \
--hash=sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5 \
--hash=sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471 \
--hash=sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00 \
--hash=sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68 \
--hash=sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3 \
--hash=sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d \
--hash=sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735 \
--hash=sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d \
--hash=sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569 \
--hash=sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7 \
--hash=sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59 \
--hash=sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5 \
--hash=sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb \
--hash=sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b \
--hash=sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f \
--hash=sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462 \
--hash=sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015 \
--hash=sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af
# via astroid
yamllint==1.28.0 \
--hash=sha256:89bb5b5ac33b1ade059743cf227de73daa34d5e5a474b06a5e17fc16583b0cf2 \
--hash=sha256:9e3d8ddd16d0583214c5fdffe806c9344086721f107435f68bad990e5a88826b
# via -r requirements.in
rules_python-0.22.1/examples/bzlmod/runfiles/ 0000775 0000000 0000000 00000000000 14540404546 0021271 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/runfiles/BUILD.bazel 0000664 0000000 0000000 00000001053 14540404546 0023146 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_test")
# gazelle:ignore
py_test(
name = "runfiles_test",
srcs = ["runfiles_test.py"],
data = [
"data/data.txt",
"@our_other_module//other_module/pkg:data/data.txt",
],
env = {
"DATA_RLOCATIONPATH": "$(rlocationpath data/data.txt)",
"OTHER_MODULE_DATA_RLOCATIONPATH": "$(rlocationpath @our_other_module//other_module/pkg:data/data.txt)",
},
deps = [
"@our_other_module//other_module/pkg:lib",
"@rules_python//python/runfiles",
],
)
rules_python-0.22.1/examples/bzlmod/runfiles/data/ 0000775 0000000 0000000 00000000000 14540404546 0022202 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod/runfiles/data/data.txt 0000664 0000000 0000000 00000000027 14540404546 0023653 0 ustar 00root root 0000000 0000000 Hello, example_bzlmod!
rules_python-0.22.1/examples/bzlmod/runfiles/runfiles_test.py 0000664 0000000 0000000 00000004717 14540404546 0024542 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import unittest
from other_module.pkg import lib
from python.runfiles import runfiles
class RunfilesTest(unittest.TestCase):
# """Unit tests for `runfiles.Runfiles`."""
def testCurrentRepository(self):
self.assertEqual(runfiles.Create().CurrentRepository(), "")
def testRunfilesWithRepoMapping(self):
data_path = runfiles.Create().Rlocation("example_bzlmod/runfiles/data/data.txt")
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, example_bzlmod!")
def testRunfileWithRlocationpath(self):
data_rlocationpath = os.getenv("DATA_RLOCATIONPATH")
data_path = runfiles.Create().Rlocation(data_rlocationpath)
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, example_bzlmod!")
def testRunfileInOtherModuleWithOurRepoMapping(self):
data_path = runfiles.Create().Rlocation(
"our_other_module/other_module/pkg/data/data.txt"
)
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
def testRunfileInOtherModuleWithItsRepoMapping(self):
data_path = lib.GetRunfilePathWithRepoMapping()
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
def testRunfileInOtherModuleWithCurrentRepository(self):
data_path = lib.GetRunfilePathWithCurrentRepository()
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
def testRunfileInOtherModuleWithRlocationpath(self):
data_rlocationpath = os.getenv("OTHER_MODULE_DATA_RLOCATIONPATH")
data_path = runfiles.Create().Rlocation(data_rlocationpath)
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/bzlmod/test.py 0000664 0000000 0000000 00000004627 14540404546 0021004 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pathlib
import sys
import unittest
from lib import main
class ExampleTest(unittest.TestCase):
def test_coverage_doesnt_shadow_stdlib(self):
# When we try to import the html module
import html as html_stdlib
try:
import coverage.html as html_coverage
except ImportError:
self.skipTest("not running under coverage, skipping")
self.assertNotEqual(
html_stdlib,
html_coverage,
"'html' import should not be shadowed by coverage",
)
def test_coverage_sys_path(self):
all_paths = ",\n ".join(sys.path)
for i, path in enumerate(sys.path[1:-2]):
self.assertFalse(
"/coverage" in path,
f"Expected {i + 2}th '{path}' to not contain 'coverage.py' paths, "
f"sys.path has {len(sys.path)} items:\n {all_paths}",
)
first_item, last_item = sys.path[0], sys.path[-1]
self.assertFalse(
first_item.endswith("coverage"),
f"Expected the first item in sys.path '{first_item}' to not be related to coverage",
)
if os.environ.get("COVERAGE_MANIFEST"):
# we are running under the 'bazel coverage :test'
self.assertTrue(
"pypi__coverage_cp" in last_item,
f"Expected {last_item} to be related to coverage",
)
self.assertEqual(pathlib.Path(last_item).name, "coverage")
else:
self.assertFalse(
"coverage" in last_item, f"Expected coverage tooling to not be present"
)
def test_main(self):
self.assertEquals(
"""\
- -
A 1
B 2
- -""",
main([["A", 1], ["B", 2]]),
)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/bzlmod_build_file_generation/ 0000775 0000000 0000000 00000000000 14540404546 0024033 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/.bazelignore 0000664 0000000 0000000 00000000015 14540404546 0026331 0 ustar 00root root 0000000 0000000 other_module
rules_python-0.22.1/examples/bzlmod_build_file_generation/.bazelrc 0000664 0000000 0000000 00000000355 14540404546 0025461 0 ustar 00root root 0000000 0000000 test --test_output=errors --enable_runfiles
# Windows requires these for multi-python support:
build --enable_runfiles
startup --windows_enable_symlinks
common --experimental_enable_bzlmod
coverage --java_runtime_version=remotejdk_11
rules_python-0.22.1/examples/bzlmod_build_file_generation/.bazelversion 0000664 0000000 0000000 00000000006 14540404546 0026533 0 ustar 00root root 0000000 0000000 6.0.0
rules_python-0.22.1/examples/bzlmod_build_file_generation/.gitignore 0000664 0000000 0000000 00000000010 14540404546 0026012 0 ustar 00root root 0000000 0000000 bazel-*
rules_python-0.22.1/examples/bzlmod_build_file_generation/BUILD.bazel 0000664 0000000 0000000 00000007460 14540404546 0025720 0 ustar 00root root 0000000 0000000 # Load various rules so that we can have bazel download
# various rulesets and dependencies.
# The `load` statement imports the symbol for the rule, in the defined
# ruleset. When the symbol is loaded you can use the rule.
# The following code loads the base python requirements and gazelle
# requirements.
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@python3//:defs.bzl", py_test_with_transition = "py_test")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
# This stanza calls a rule that generates targets for managing pip dependencies
# with pip-compile.
compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock.txt",
requirements_windows = "requirements_windows.txt",
)
# This repository rule fetches the metadata for python packages we
# depend on. That data is required for the gazelle_python_manifest
# rule to update our manifest file.
modules_mapping(
name = "modules_map",
exclude_patterns = [
"^_|(\\._)+", # This is the default.
"(\\.tests)+", # Add a custom one to get rid of the psutil tests.
],
wheels = all_whl_requirements,
)
# Gazelle python extension needs a manifest file mapping from
# an import to the installed package that provides it.
# This macro produces two targets:
# - //:gazelle_python_manifest.update can be used with `bazel run`
# to recalculate the manifest
# - //:gazelle_python_manifest.test is a test target ensuring that
# the manifest doesn't need to be updated
# This target updates a file called gazelle_python.yaml, and
# requires that file exist before the target is run.
# When you are using gazelle you need to run this target first.
gazelle_python_manifest(
name = "gazelle_python_manifest",
modules_mapping = ":modules_map",
pip_repository_name = "pip",
requirements = "//:requirements_lock.txt",
# NOTE: we can use this flag in order to make our setup compatible with
# bzlmod.
use_pip_repository_aliases = True,
)
# Our gazelle target points to the python gazelle binary.
# This is the simple case where we only need one language supported.
# If you also had proto, go, or other gazelle-supported languages,
# you would also need a gazelle_binary rule.
# See https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.rst#example
# This is the primary gazelle target to run, so that you can update BUILD.bazel files.
# You can execute:
# - bazel run //:gazelle update
# - bazel run //:gazelle fix
# See: https://github.com/bazelbuild/bazel-gazelle#fix-and-update
gazelle(
name = "gazelle",
data = GAZELLE_PYTHON_RUNTIME_DEPS,
gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
py_test_with_transition(
name = "test_with_transition",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":bzlmod_build_file_generation"],
)
# The following targets are created and maintained by gazelle
py_library(
name = "bzlmod_build_file_generation",
srcs = ["lib.py"],
visibility = ["//:__subpackages__"],
deps = ["@pip//tabulate"],
)
py_binary(
name = "bzlmod_build_file_generation_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [":bzlmod_build_file_generation"],
)
py_test(
name = "bzlmod_build_file_generation_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":bzlmod_build_file_generation"],
)
rules_python-0.22.1/examples/bzlmod_build_file_generation/MODULE.bazel 0000664 0000000 0000000 00000011660 14540404546 0026043 0 ustar 00root root 0000000 0000000 # This file replaces the WORKSPACE file when using bzlmod.
# module declares certain properties of the Bazel module represented by the current Bazel repo.
# These properties are either essential metadata of the module (such as the name and version),
# or affect behavior of the current module and its dependents.
module(
name = "example_bzlmod_build_file_generation",
version = "0.0.0",
compatibility_level = 1,
)
# The following stanza defines the dependency rules_python.
# For typical setups you set the version.
# See the releases page for available versions.
# https://github.com/bazelbuild/rules_python/releases
bazel_dep(name = "rules_python", version = "0.0.0")
# The following loads rules_python from the file system.
# For usual setups you should remove this local_path_override block.
local_path_override(
module_name = "rules_python",
path = "../..",
)
# The following stanza defines the dependency rules_python_gazelle_plugin.
# For typical setups you set the version.
# See the releases page for available versions.
# https://github.com/bazelbuild/rules_python/releases
bazel_dep(name = "rules_python_gazelle_plugin", version = "0.0.0")
# The following starlark loads the gazelle plugin from the file system.
# For usual setups you should remove this local_path_override block.
local_path_override(
module_name = "rules_python_gazelle_plugin",
path = "../../gazelle",
)
# The following stanza defines the dependency for gazelle
# See here https://github.com/bazelbuild/bazel-gazelle/releases/ for the
# latest version.
bazel_dep(name = "gazelle", version = "0.30.0", repo_name = "bazel_gazelle")
# The following stanze returns a proxy object representing a module extension;
# its methods can be invoked to create module extension tags.
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
# This name is passed into python.toolchain and it's use_repo statement.
# We also use the same name for python.host_python_interpreter.
PYTHON_NAME = "python3"
# We next initialize the python toolchain using the extension.
# You can set different Python versions in this block.
python.toolchain(
# This name is used in the various use_repo statements
# below, and in the local extension that is in this
# example.
name = PYTHON_NAME,
configure_coverage_tool = True,
python_version = "3.9",
)
# Import the python repositories generated by the given module extension
# into the scope of the current module.
# All of the python3 repositories use the PYTHON_NAME as there prefix. They
# are not catenated for ease of reading.
use_repo(python, PYTHON_NAME, "python3_toolchains")
# Register an already-defined toolchain so that Bazel can use it during
# toolchain resolution.
register_toolchains(
"@python3_toolchains//:all",
)
# The interpreter extension discovers the platform specific Python binary.
# It creates a symlink to the binary, and we pass the label to the following
# pip.parse call.
interpreter = use_extension("@rules_python//python/extensions:interpreter.bzl", "interpreter")
interpreter.install(
name = "interpreter_python3",
python_name = PYTHON_NAME,
)
use_repo(interpreter, "interpreter_python3")
# Use the extension, pip.parse, to call the `pip_repository` rule that invokes
# `pip`, with `incremental` set. The pip call accepts a locked/compiled
# requirements file and installs the dependencies listed within.
# Those dependencies become available in a generated `requirements.bzl` file.
# You can instead check this `requirements.bzl` file into your repo.
# Because this project has different requirements for windows vs other
# operating systems, we have requirements for each.
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
name = "pip",
# When using gazelle you must use set the following flag
# in order for the generation of gazelle dependency resolution.
incompatible_generate_aliases = True,
# The interpreter_target attribute points to the interpreter to
# use for running pip commands to download the packages in the
# requirements file.
# As a best practice, we use the same interpreter as the toolchain
# that was configured above; this ensures the same Python version
# is used for both resolving dependencies and running tests/binaries.
# If this isn't specified, then you'll get whatever is locally installed
# on your system.
python_interpreter_target = "@interpreter_python3//:python",
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
)
# Imports the pip toolchain generated by the given module extension into the scope of the current module.
use_repo(pip, "pip")
# This project includes a different module that is on the local file system.
# Add the module to this parent project.
bazel_dep(name = "other_module", version = "", repo_name = "our_other_module")
local_path_override(
module_name = "other_module",
path = "other_module",
)
rules_python-0.22.1/examples/bzlmod_build_file_generation/README.md 0000664 0000000 0000000 00000002103 14540404546 0025306 0 ustar 00root root 0000000 0000000 # Bzlmod build file generation example
This example demostrates how to use `rules_python` and gazelle with `bzlmod` enabled.
[Bzlmod](https://bazel.build/external/overview#bzlmod), the new external dependency
subsystem, does not directly work with repo definitions. Instead, it builds a dependency
graph from modules, runs extensions on top of the graph, and defines repos accordingly.
Gazelle is setup with the `rules_python`
extension, so that targets like `py_library` and `py_binary` can be
automatically created just by running:
```sh
$ bazel run //:gazelle update
```
The are other targets that allow you to update the gazelle dependency management
when you update the requirements.in file. See:
```bash
bazel run //:gazelle_python_manifest.update
```
For more information on the behavior of the `rules_python` gazelle extension,
see the [README.md](../../gazelle/README.md) file in the /gazelle folder.
This example uses a `MODULE.bazel` file that configures the bzlmod dependency
management. See comments in the `MODULE.bazel` and `BUILD.bazel` files for more
information.
rules_python-0.22.1/examples/bzlmod_build_file_generation/WORKSPACE 0000664 0000000 0000000 00000000145 14540404546 0025314 0 ustar 00root root 0000000 0000000 # Empty file indicating the root of a Bazel workspace.
# Dependencies and setup are in MODULE.bazel.
rules_python-0.22.1/examples/bzlmod_build_file_generation/__main__.py 0000664 0000000 0000000 00000001263 14540404546 0026127 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from lib import main
if __name__ == "__main__":
print(main([["A", 1], ["B", 2]]))
rules_python-0.22.1/examples/bzlmod_build_file_generation/__test__.py 0000664 0000000 0000000 00000001552 14540404546 0026163 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from lib import main
class ExampleTest(unittest.TestCase):
def test_main(self):
self.assertEquals(
"""\
- -
A 1
B 2
- -""",
main([["A", 1], ["B", 2]]),
)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/bzlmod_build_file_generation/gazelle_python.yaml 0000664 0000000 0000000 00000051053 14540404546 0027747 0 ustar 00root root 0000000 0000000 # GENERATED FILE - DO NOT EDIT!
#
# To update this file, run:
# bazel run //:gazelle_python_manifest.update
manifest:
modules_mapping:
S3: s3cmd
S3.ACL: s3cmd
S3.AccessLog: s3cmd
S3.BidirMap: s3cmd
S3.CloudFront: s3cmd
S3.Config: s3cmd
S3.ConnMan: s3cmd
S3.Crypto: s3cmd
S3.Custom_httplib27: s3cmd
S3.Custom_httplib3x: s3cmd
S3.Exceptions: s3cmd
S3.ExitCodes: s3cmd
S3.FileDict: s3cmd
S3.FileLists: s3cmd
S3.HashCache: s3cmd
S3.MultiPart: s3cmd
S3.PkgInfo: s3cmd
S3.Progress: s3cmd
S3.S3: s3cmd
S3.S3Uri: s3cmd
S3.SortedDict: s3cmd
S3.Utils: s3cmd
astroid: astroid
astroid.arguments: astroid
astroid.astroid_manager: astroid
astroid.bases: astroid
astroid.brain: astroid
astroid.brain.brain_argparse: astroid
astroid.brain.brain_attrs: astroid
astroid.brain.brain_boto3: astroid
astroid.brain.brain_builtin_inference: astroid
astroid.brain.brain_collections: astroid
astroid.brain.brain_crypt: astroid
astroid.brain.brain_ctypes: astroid
astroid.brain.brain_curses: astroid
astroid.brain.brain_dataclasses: astroid
astroid.brain.brain_dateutil: astroid
astroid.brain.brain_fstrings: astroid
astroid.brain.brain_functools: astroid
astroid.brain.brain_gi: astroid
astroid.brain.brain_hashlib: astroid
astroid.brain.brain_http: astroid
astroid.brain.brain_hypothesis: astroid
astroid.brain.brain_io: astroid
astroid.brain.brain_mechanize: astroid
astroid.brain.brain_multiprocessing: astroid
astroid.brain.brain_namedtuple_enum: astroid
astroid.brain.brain_nose: astroid
astroid.brain.brain_numpy_core_einsumfunc: astroid
astroid.brain.brain_numpy_core_fromnumeric: astroid
astroid.brain.brain_numpy_core_function_base: astroid
astroid.brain.brain_numpy_core_multiarray: astroid
astroid.brain.brain_numpy_core_numeric: astroid
astroid.brain.brain_numpy_core_numerictypes: astroid
astroid.brain.brain_numpy_core_umath: astroid
astroid.brain.brain_numpy_ma: astroid
astroid.brain.brain_numpy_ndarray: astroid
astroid.brain.brain_numpy_random_mtrand: astroid
astroid.brain.brain_numpy_utils: astroid
astroid.brain.brain_pathlib: astroid
astroid.brain.brain_pkg_resources: astroid
astroid.brain.brain_pytest: astroid
astroid.brain.brain_qt: astroid
astroid.brain.brain_random: astroid
astroid.brain.brain_re: astroid
astroid.brain.brain_responses: astroid
astroid.brain.brain_scipy_signal: astroid
astroid.brain.brain_signal: astroid
astroid.brain.brain_six: astroid
astroid.brain.brain_sqlalchemy: astroid
astroid.brain.brain_ssl: astroid
astroid.brain.brain_subprocess: astroid
astroid.brain.brain_threading: astroid
astroid.brain.brain_type: astroid
astroid.brain.brain_typing: astroid
astroid.brain.brain_unittest: astroid
astroid.brain.brain_uuid: astroid
astroid.brain.helpers: astroid
astroid.builder: astroid
astroid.const: astroid
astroid.context: astroid
astroid.decorators: astroid
astroid.exceptions: astroid
astroid.filter_statements: astroid
astroid.helpers: astroid
astroid.inference: astroid
astroid.inference_tip: astroid
astroid.interpreter: astroid
astroid.interpreter.dunder_lookup: astroid
astroid.interpreter.objectmodel: astroid
astroid.manager: astroid
astroid.mixins: astroid
astroid.modutils: astroid
astroid.node_classes: astroid
astroid.nodes: astroid
astroid.nodes.as_string: astroid
astroid.nodes.const: astroid
astroid.nodes.node_classes: astroid
astroid.nodes.node_ng: astroid
astroid.nodes.scoped_nodes: astroid
astroid.nodes.scoped_nodes.mixin: astroid
astroid.nodes.scoped_nodes.scoped_nodes: astroid
astroid.nodes.scoped_nodes.utils: astroid
astroid.nodes.utils: astroid
astroid.objects: astroid
astroid.protocols: astroid
astroid.raw_building: astroid
astroid.rebuilder: astroid
astroid.scoped_nodes: astroid
astroid.test_utils: astroid
astroid.transforms: astroid
astroid.typing: astroid
astroid.util: astroid
certifi: certifi
certifi.core: certifi
chardet: chardet
chardet.big5freq: chardet
chardet.big5prober: chardet
chardet.chardistribution: chardet
chardet.charsetgroupprober: chardet
chardet.charsetprober: chardet
chardet.cli: chardet
chardet.cli.chardetect: chardet
chardet.codingstatemachine: chardet
chardet.compat: chardet
chardet.cp949prober: chardet
chardet.enums: chardet
chardet.escprober: chardet
chardet.escsm: chardet
chardet.eucjpprober: chardet
chardet.euckrfreq: chardet
chardet.euckrprober: chardet
chardet.euctwfreq: chardet
chardet.euctwprober: chardet
chardet.gb2312freq: chardet
chardet.gb2312prober: chardet
chardet.hebrewprober: chardet
chardet.jisfreq: chardet
chardet.jpcntx: chardet
chardet.langbulgarianmodel: chardet
chardet.langgreekmodel: chardet
chardet.langhebrewmodel: chardet
chardet.langhungarianmodel: chardet
chardet.langrussianmodel: chardet
chardet.langthaimodel: chardet
chardet.langturkishmodel: chardet
chardet.latin1prober: chardet
chardet.mbcharsetprober: chardet
chardet.mbcsgroupprober: chardet
chardet.mbcssm: chardet
chardet.metadata: chardet
chardet.metadata.languages: chardet
chardet.sbcharsetprober: chardet
chardet.sbcsgroupprober: chardet
chardet.sjisprober: chardet
chardet.universaldetector: chardet
chardet.utf8prober: chardet
chardet.version: chardet
dateutil: python_dateutil
dateutil.easter: python_dateutil
dateutil.parser: python_dateutil
dateutil.parser.isoparser: python_dateutil
dateutil.relativedelta: python_dateutil
dateutil.rrule: python_dateutil
dateutil.tz: python_dateutil
dateutil.tz.tz: python_dateutil
dateutil.tz.win: python_dateutil
dateutil.tzwin: python_dateutil
dateutil.utils: python_dateutil
dateutil.zoneinfo: python_dateutil
dateutil.zoneinfo.rebuild: python_dateutil
dill: dill
dill.detect: dill
dill.logger: dill
dill.objtypes: dill
dill.pointers: dill
dill.session: dill
dill.settings: dill
dill.source: dill
dill.temp: dill
idna: idna
idna.codec: idna
idna.compat: idna
idna.core: idna
idna.idnadata: idna
idna.intranges: idna
idna.package_data: idna
idna.uts46data: idna
isort: isort
isort.api: isort
isort.comments: isort
isort.core: isort
isort.deprecated: isort
isort.deprecated.finders: isort
isort.exceptions: isort
isort.files: isort
isort.format: isort
isort.hooks: isort
isort.identify: isort
isort.io: isort
isort.literal: isort
isort.logo: isort
isort.main: isort
isort.output: isort
isort.parse: isort
isort.place: isort
isort.profiles: isort
isort.pylama_isort: isort
isort.sections: isort
isort.settings: isort
isort.setuptools_commands: isort
isort.sorting: isort
isort.stdlibs: isort
isort.stdlibs.all: isort
isort.stdlibs.py2: isort
isort.stdlibs.py27: isort
isort.stdlibs.py3: isort
isort.stdlibs.py310: isort
isort.stdlibs.py311: isort
isort.stdlibs.py36: isort
isort.stdlibs.py37: isort
isort.stdlibs.py38: isort
isort.stdlibs.py39: isort
isort.utils: isort
isort.wrap: isort
isort.wrap_modes: isort
lazy_object_proxy: lazy_object_proxy
lazy_object_proxy.compat: lazy_object_proxy
lazy_object_proxy.simple: lazy_object_proxy
lazy_object_proxy.slots: lazy_object_proxy
lazy_object_proxy.utils: lazy_object_proxy
magic: python_magic
magic.compat: python_magic
magic.loader: python_magic
mccabe: mccabe
pathspec: pathspec
pathspec.gitignore: pathspec
pathspec.pathspec: pathspec
pathspec.pattern: pathspec
pathspec.patterns: pathspec
pathspec.patterns.gitwildmatch: pathspec
pathspec.util: pathspec
pkg_resources: setuptools
pkg_resources.extern: setuptools
platformdirs: platformdirs
platformdirs.android: platformdirs
platformdirs.api: platformdirs
platformdirs.macos: platformdirs
platformdirs.unix: platformdirs
platformdirs.version: platformdirs
platformdirs.windows: platformdirs
pylint: pylint
pylint.checkers: pylint
pylint.checkers.async: pylint
pylint.checkers.base: pylint
pylint.checkers.base.basic_checker: pylint
pylint.checkers.base.basic_error_checker: pylint
pylint.checkers.base.comparison_checker: pylint
pylint.checkers.base.docstring_checker: pylint
pylint.checkers.base.name_checker: pylint
pylint.checkers.base.name_checker.checker: pylint
pylint.checkers.base.name_checker.naming_style: pylint
pylint.checkers.base.pass_checker: pylint
pylint.checkers.base_checker: pylint
pylint.checkers.classes: pylint
pylint.checkers.classes.class_checker: pylint
pylint.checkers.classes.special_methods_checker: pylint
pylint.checkers.deprecated: pylint
pylint.checkers.design_analysis: pylint
pylint.checkers.dunder_methods: pylint
pylint.checkers.ellipsis_checker: pylint
pylint.checkers.exceptions: pylint
pylint.checkers.format: pylint
pylint.checkers.imports: pylint
pylint.checkers.lambda_expressions: pylint
pylint.checkers.logging: pylint
pylint.checkers.mapreduce_checker: pylint
pylint.checkers.method_args: pylint
pylint.checkers.misc: pylint
pylint.checkers.modified_iterating_checker: pylint
pylint.checkers.newstyle: pylint
pylint.checkers.non_ascii_names: pylint
pylint.checkers.raw_metrics: pylint
pylint.checkers.refactoring: pylint
pylint.checkers.refactoring.implicit_booleaness_checker: pylint
pylint.checkers.refactoring.not_checker: pylint
pylint.checkers.refactoring.recommendation_checker: pylint
pylint.checkers.refactoring.refactoring_checker: pylint
pylint.checkers.similar: pylint
pylint.checkers.spelling: pylint
pylint.checkers.stdlib: pylint
pylint.checkers.strings: pylint
pylint.checkers.threading_checker: pylint
pylint.checkers.typecheck: pylint
pylint.checkers.unicode: pylint
pylint.checkers.unsupported_version: pylint
pylint.checkers.utils: pylint
pylint.checkers.variables: pylint
pylint.config: pylint
pylint.config.argument: pylint
pylint.config.arguments_manager: pylint
pylint.config.arguments_provider: pylint
pylint.config.callback_actions: pylint
pylint.config.config_file_parser: pylint
pylint.config.config_initialization: pylint
pylint.config.configuration_mixin: pylint
pylint.config.deprecation_actions: pylint
pylint.config.environment_variable: pylint
pylint.config.exceptions: pylint
pylint.config.find_default_config_files: pylint
pylint.config.help_formatter: pylint
pylint.config.option: pylint
pylint.config.option_manager_mixin: pylint
pylint.config.option_parser: pylint
pylint.config.options_provider_mixin: pylint
pylint.config.utils: pylint
pylint.constants: pylint
pylint.epylint: pylint
pylint.exceptions: pylint
pylint.extensions: pylint
pylint.extensions.bad_builtin: pylint
pylint.extensions.broad_try_clause: pylint
pylint.extensions.check_elif: pylint
pylint.extensions.code_style: pylint
pylint.extensions.comparetozero: pylint
pylint.extensions.comparison_placement: pylint
pylint.extensions.confusing_elif: pylint
pylint.extensions.consider_ternary_expression: pylint
pylint.extensions.docparams: pylint
pylint.extensions.docstyle: pylint
pylint.extensions.empty_comment: pylint
pylint.extensions.emptystring: pylint
pylint.extensions.eq_without_hash: pylint
pylint.extensions.for_any_all: pylint
pylint.extensions.mccabe: pylint
pylint.extensions.no_self_use: pylint
pylint.extensions.overlapping_exceptions: pylint
pylint.extensions.private_import: pylint
pylint.extensions.redefined_loop_name: pylint
pylint.extensions.redefined_variable_type: pylint
pylint.extensions.set_membership: pylint
pylint.extensions.typing: pylint
pylint.extensions.while_used: pylint
pylint.graph: pylint
pylint.interfaces: pylint
pylint.lint: pylint
pylint.lint.base_options: pylint
pylint.lint.caching: pylint
pylint.lint.expand_modules: pylint
pylint.lint.message_state_handler: pylint
pylint.lint.parallel: pylint
pylint.lint.pylinter: pylint
pylint.lint.report_functions: pylint
pylint.lint.run: pylint
pylint.lint.utils: pylint
pylint.message: pylint
pylint.message.message: pylint
pylint.message.message_definition: pylint
pylint.message.message_definition_store: pylint
pylint.message.message_id_store: pylint
pylint.pyreverse: pylint
pylint.pyreverse.diadefslib: pylint
pylint.pyreverse.diagrams: pylint
pylint.pyreverse.dot_printer: pylint
pylint.pyreverse.inspector: pylint
pylint.pyreverse.main: pylint
pylint.pyreverse.mermaidjs_printer: pylint
pylint.pyreverse.plantuml_printer: pylint
pylint.pyreverse.printer: pylint
pylint.pyreverse.printer_factory: pylint
pylint.pyreverse.utils: pylint
pylint.pyreverse.vcg_printer: pylint
pylint.pyreverse.writer: pylint
pylint.reporters: pylint
pylint.reporters.base_reporter: pylint
pylint.reporters.collecting_reporter: pylint
pylint.reporters.json_reporter: pylint
pylint.reporters.multi_reporter: pylint
pylint.reporters.reports_handler_mix_in: pylint
pylint.reporters.text: pylint
pylint.reporters.ureports: pylint
pylint.reporters.ureports.base_writer: pylint
pylint.reporters.ureports.nodes: pylint
pylint.reporters.ureports.text_writer: pylint
pylint.testutils: pylint
pylint.testutils.checker_test_case: pylint
pylint.testutils.configuration_test: pylint
pylint.testutils.constants: pylint
pylint.testutils.decorator: pylint
pylint.testutils.functional: pylint
pylint.testutils.functional.find_functional_tests: pylint
pylint.testutils.functional.lint_module_output_update: pylint
pylint.testutils.functional.test_file: pylint
pylint.testutils.functional_test_file: pylint
pylint.testutils.get_test_info: pylint
pylint.testutils.global_test_linter: pylint
pylint.testutils.lint_module_test: pylint
pylint.testutils.output_line: pylint
pylint.testutils.pyreverse: pylint
pylint.testutils.reporter_for_tests: pylint
pylint.testutils.tokenize_str: pylint
pylint.testutils.unittest_linter: pylint
pylint.testutils.utils: pylint
pylint.typing: pylint
pylint.utils: pylint
pylint.utils.ast_walker: pylint
pylint.utils.docs: pylint
pylint.utils.file_state: pylint
pylint.utils.linterstats: pylint
pylint.utils.pragma_parser: pylint
pylint.utils.utils: pylint
requests: requests
requests.adapters: requests
requests.api: requests
requests.auth: requests
requests.certs: requests
requests.compat: requests
requests.cookies: requests
requests.exceptions: requests
requests.help: requests
requests.hooks: requests
requests.models: requests
requests.packages: requests
requests.sessions: requests
requests.status_codes: requests
requests.structures: requests
requests.utils: requests
setuptools: setuptools
setuptools.archive_util: setuptools
setuptools.build_meta: setuptools
setuptools.command: setuptools
setuptools.command.alias: setuptools
setuptools.command.bdist_egg: setuptools
setuptools.command.bdist_rpm: setuptools
setuptools.command.build: setuptools
setuptools.command.build_clib: setuptools
setuptools.command.build_ext: setuptools
setuptools.command.build_py: setuptools
setuptools.command.develop: setuptools
setuptools.command.dist_info: setuptools
setuptools.command.easy_install: setuptools
setuptools.command.editable_wheel: setuptools
setuptools.command.egg_info: setuptools
setuptools.command.install: setuptools
setuptools.command.install_egg_info: setuptools
setuptools.command.install_lib: setuptools
setuptools.command.install_scripts: setuptools
setuptools.command.py36compat: setuptools
setuptools.command.register: setuptools
setuptools.command.rotate: setuptools
setuptools.command.saveopts: setuptools
setuptools.command.sdist: setuptools
setuptools.command.setopt: setuptools
setuptools.command.test: setuptools
setuptools.command.upload: setuptools
setuptools.command.upload_docs: setuptools
setuptools.config: setuptools
setuptools.config.expand: setuptools
setuptools.config.pyprojecttoml: setuptools
setuptools.config.setupcfg: setuptools
setuptools.dep_util: setuptools
setuptools.depends: setuptools
setuptools.discovery: setuptools
setuptools.dist: setuptools
setuptools.errors: setuptools
setuptools.extension: setuptools
setuptools.extern: setuptools
setuptools.glob: setuptools
setuptools.installer: setuptools
setuptools.launch: setuptools
setuptools.logging: setuptools
setuptools.monkey: setuptools
setuptools.msvc: setuptools
setuptools.namespaces: setuptools
setuptools.package_index: setuptools
setuptools.py34compat: setuptools
setuptools.sandbox: setuptools
setuptools.unicode_utils: setuptools
setuptools.version: setuptools
setuptools.wheel: setuptools
setuptools.windows_support: setuptools
six: six
tabulate: tabulate
tabulate.version: tabulate
tomli: tomli
tomlkit: tomlkit
tomlkit.api: tomlkit
tomlkit.container: tomlkit
tomlkit.exceptions: tomlkit
tomlkit.items: tomlkit
tomlkit.parser: tomlkit
tomlkit.source: tomlkit
tomlkit.toml_char: tomlkit
tomlkit.toml_document: tomlkit
tomlkit.toml_file: tomlkit
typing_extensions: typing_extensions
urllib3: urllib3
urllib3.connection: urllib3
urllib3.connectionpool: urllib3
urllib3.contrib: urllib3
urllib3.contrib.appengine: urllib3
urllib3.contrib.ntlmpool: urllib3
urllib3.contrib.pyopenssl: urllib3
urllib3.contrib.securetransport: urllib3
urllib3.contrib.socks: urllib3
urllib3.exceptions: urllib3
urllib3.fields: urllib3
urllib3.filepost: urllib3
urllib3.packages: urllib3
urllib3.packages.backports: urllib3
urllib3.packages.backports.makefile: urllib3
urllib3.packages.six: urllib3
urllib3.poolmanager: urllib3
urllib3.request: urllib3
urllib3.response: urllib3
urllib3.util: urllib3
urllib3.util.connection: urllib3
urllib3.util.proxy: urllib3
urllib3.util.queue: urllib3
urllib3.util.request: urllib3
urllib3.util.response: urllib3
urllib3.util.retry: urllib3
urllib3.util.ssl_: urllib3
urllib3.util.ssl_match_hostname: urllib3
urllib3.util.ssltransport: urllib3
urllib3.util.timeout: urllib3
urllib3.util.url: urllib3
urllib3.util.wait: urllib3
wrapt: wrapt
wrapt.arguments: wrapt
wrapt.decorators: wrapt
wrapt.importer: wrapt
wrapt.wrappers: wrapt
yaml: PyYAML
yaml.composer: PyYAML
yaml.constructor: PyYAML
yaml.cyaml: PyYAML
yaml.dumper: PyYAML
yaml.emitter: PyYAML
yaml.error: PyYAML
yaml.events: PyYAML
yaml.loader: PyYAML
yaml.nodes: PyYAML
yaml.parser: PyYAML
yaml.reader: PyYAML
yaml.representer: PyYAML
yaml.resolver: PyYAML
yaml.scanner: PyYAML
yaml.serializer: PyYAML
yaml.tokens: PyYAML
yamllint: yamllint
yamllint.cli: yamllint
yamllint.config: yamllint
yamllint.linter: yamllint
yamllint.parser: yamllint
yamllint.rules: yamllint
yamllint.rules.braces: yamllint
yamllint.rules.brackets: yamllint
yamllint.rules.colons: yamllint
yamllint.rules.commas: yamllint
yamllint.rules.comments: yamllint
yamllint.rules.comments_indentation: yamllint
yamllint.rules.common: yamllint
yamllint.rules.document_end: yamllint
yamllint.rules.document_start: yamllint
yamllint.rules.empty_lines: yamllint
yamllint.rules.empty_values: yamllint
yamllint.rules.float_values: yamllint
yamllint.rules.hyphens: yamllint
yamllint.rules.indentation: yamllint
yamllint.rules.key_duplicates: yamllint
yamllint.rules.key_ordering: yamllint
yamllint.rules.line_length: yamllint
yamllint.rules.new_line_at_end_of_file: yamllint
yamllint.rules.new_lines: yamllint
yamllint.rules.octal_values: yamllint
yamllint.rules.quoted_strings: yamllint
yamllint.rules.trailing_spaces: yamllint
yamllint.rules.truthy: yamllint
pip_repository:
name: pip
use_pip_repository_aliases: true
integrity: d979738b10adbbaff0884837e4414688990491c6c40f6a25d58b9bb564411477
rules_python-0.22.1/examples/bzlmod_build_file_generation/lib.py 0000664 0000000 0000000 00000001250 14540404546 0025151 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from tabulate import tabulate
def main(table):
return tabulate(table)
rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/ 0000775 0000000 0000000 00000000000 14540404546 0026521 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/MODULE.bazel 0000664 0000000 0000000 00000000125 14540404546 0030523 0 ustar 00root root 0000000 0000000 module(
name = "other_module",
)
bazel_dep(name = "rules_python", version = "")
rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/WORKSPACE 0000664 0000000 0000000 00000000000 14540404546 0027770 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/other_module/ 0000775 0000000 0000000 00000000000 14540404546 0031207 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/other_module/pkg/ 0000775 0000000 0000000 00000000000 14540404546 0031770 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/other_module/pkg/BUILD.bazel 0000664 0000000 0000000 00000000406 14540404546 0033646 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "lib",
srcs = ["lib.py"],
data = ["data/data.txt"],
visibility = ["//visibility:public"],
deps = ["@rules_python//python/runfiles"],
)
exports_files(["data/data.txt"])
rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/other_module/pkg/data/ 0000775 0000000 0000000 00000000000 14540404546 0032701 5 ustar 00root root 0000000 0000000 data.txt 0000664 0000000 0000000 00000000025 14540404546 0034271 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/other_module/pkg/data Hello, other_module!
rules_python-0.22.1/examples/bzlmod_build_file_generation/other_module/other_module/pkg/lib.py 0000664 0000000 0000000 00000002044 14540404546 0033110 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from python.runfiles import runfiles
def GetRunfilePathWithCurrentRepository():
r = runfiles.Create()
own_repo = r.CurrentRepository()
# For a non-main repository, the name of the runfiles directory is equal to
# the canonical repository name.
return r.Rlocation(own_repo + "/other_module/pkg/data/data.txt")
def GetRunfilePathWithRepoMapping():
return runfiles.Create().Rlocation("other_module/other_module/pkg/data/data.txt")
rules_python-0.22.1/examples/bzlmod_build_file_generation/requirements.in 0000664 0000000 0000000 00000000145 14540404546 0027106 0 ustar 00root root 0000000 0000000 requests~=2.25.1
s3cmd~=2.1.0
yamllint>=1.28.0
tabulate~=0.9.0
pylint~=2.15.5
python-dateutil>=2.8.2
rules_python-0.22.1/examples/bzlmod_build_file_generation/requirements_lock.txt 0000664 0000000 0000000 00000035714 14540404546 0030341 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
astroid==2.12.13 \
--hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \
--hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7
# via pylint
certifi==2022.12.7 \
--hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \
--hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18
# via requests
chardet==4.0.0 \
--hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \
--hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5
# via requests
dill==0.3.6 \
--hash=sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0 \
--hash=sha256:e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373
# via pylint
idna==2.10 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
# via requests
isort==5.11.4 \
--hash=sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6 \
--hash=sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b
# via pylint
lazy-object-proxy==1.8.0 \
--hash=sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada \
--hash=sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d \
--hash=sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7 \
--hash=sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe \
--hash=sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd \
--hash=sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c \
--hash=sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858 \
--hash=sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288 \
--hash=sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec \
--hash=sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f \
--hash=sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891 \
--hash=sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c \
--hash=sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25 \
--hash=sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156 \
--hash=sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8 \
--hash=sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f \
--hash=sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e \
--hash=sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0 \
--hash=sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b
# via astroid
mccabe==0.7.0 \
--hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \
--hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e
# via pylint
pathspec==0.10.3 \
--hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \
--hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6
# via yamllint
platformdirs==2.6.0 \
--hash=sha256:1a89a12377800c81983db6be069ec068eee989748799b946cce2a6e80dcc54ca \
--hash=sha256:b46ffafa316e6b83b47489d240ce17173f123a9b9c83282141c3daf26ad9ac2e
# via pylint
pylint==2.15.9 \
--hash=sha256:18783cca3cfee5b83c6c5d10b3cdb66c6594520ffae61890858fe8d932e1c6b4 \
--hash=sha256:349c8cd36aede4d50a0754a8c0218b43323d13d5d88f4b2952ddfe3e169681eb
# via -r requirements.in
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via
# -r requirements.in
# s3cmd
python-magic==0.4.27 \
--hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \
--hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3
# via s3cmd
pyyaml==6.0 \
--hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
requests==2.25.1 \
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e
# via -r requirements.in
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via yamllint
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
tabulate==0.9.0 \
--hash=sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c \
--hash=sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f
# via -r requirements.in
tomli==2.0.1 \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
# via pylint
tomlkit==0.11.6 \
--hash=sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b \
--hash=sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73
# via pylint
typing-extensions==4.4.0 \
--hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \
--hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e
# via
# astroid
# pylint
urllib3==1.26.13 \
--hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \
--hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8
# via requests
wrapt==1.14.1 \
--hash=sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3 \
--hash=sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b \
--hash=sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4 \
--hash=sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2 \
--hash=sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656 \
--hash=sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3 \
--hash=sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff \
--hash=sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310 \
--hash=sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a \
--hash=sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57 \
--hash=sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069 \
--hash=sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383 \
--hash=sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe \
--hash=sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87 \
--hash=sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d \
--hash=sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b \
--hash=sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907 \
--hash=sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f \
--hash=sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0 \
--hash=sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28 \
--hash=sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1 \
--hash=sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853 \
--hash=sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc \
--hash=sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3 \
--hash=sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3 \
--hash=sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164 \
--hash=sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1 \
--hash=sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c \
--hash=sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1 \
--hash=sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7 \
--hash=sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1 \
--hash=sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320 \
--hash=sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed \
--hash=sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1 \
--hash=sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248 \
--hash=sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c \
--hash=sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456 \
--hash=sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77 \
--hash=sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef \
--hash=sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1 \
--hash=sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7 \
--hash=sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86 \
--hash=sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4 \
--hash=sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d \
--hash=sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d \
--hash=sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8 \
--hash=sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5 \
--hash=sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471 \
--hash=sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00 \
--hash=sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68 \
--hash=sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3 \
--hash=sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d \
--hash=sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735 \
--hash=sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d \
--hash=sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569 \
--hash=sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7 \
--hash=sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59 \
--hash=sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5 \
--hash=sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb \
--hash=sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b \
--hash=sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f \
--hash=sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462 \
--hash=sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015 \
--hash=sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af
# via astroid
yamllint==1.28.0 \
--hash=sha256:89bb5b5ac33b1ade059743cf227de73daa34d5e5a474b06a5e17fc16583b0cf2 \
--hash=sha256:9e3d8ddd16d0583214c5fdffe806c9344086721f107435f68bad990e5a88826b
# via -r requirements.in
rules_python-0.22.1/examples/bzlmod_build_file_generation/requirements_windows.txt 0000664 0000000 0000000 00000036227 14540404546 0031103 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
astroid==2.12.13 \
--hash=sha256:10e0ad5f7b79c435179d0d0f0df69998c4eef4597534aae44910db060baeb907 \
--hash=sha256:1493fe8bd3dfd73dc35bd53c9d5b6e49ead98497c47b2307662556a5692d29d7
# via pylint
certifi==2022.12.7 \
--hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \
--hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18
# via requests
chardet==4.0.0 \
--hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \
--hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5
# via requests
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via pylint
dill==0.3.6 \
--hash=sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0 \
--hash=sha256:e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373
# via pylint
idna==2.10 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
# via requests
isort==5.11.4 \
--hash=sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6 \
--hash=sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b
# via pylint
lazy-object-proxy==1.8.0 \
--hash=sha256:0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada \
--hash=sha256:14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d \
--hash=sha256:4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7 \
--hash=sha256:4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe \
--hash=sha256:5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd \
--hash=sha256:6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c \
--hash=sha256:6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858 \
--hash=sha256:71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288 \
--hash=sha256:7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec \
--hash=sha256:8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f \
--hash=sha256:ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891 \
--hash=sha256:afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c \
--hash=sha256:b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25 \
--hash=sha256:c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156 \
--hash=sha256:ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8 \
--hash=sha256:d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f \
--hash=sha256:e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e \
--hash=sha256:eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0 \
--hash=sha256:eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b
# via astroid
mccabe==0.7.0 \
--hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \
--hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e
# via pylint
pathspec==0.10.3 \
--hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \
--hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6
# via yamllint
platformdirs==2.6.0 \
--hash=sha256:1a89a12377800c81983db6be069ec068eee989748799b946cce2a6e80dcc54ca \
--hash=sha256:b46ffafa316e6b83b47489d240ce17173f123a9b9c83282141c3daf26ad9ac2e
# via pylint
pylint==2.15.9 \
--hash=sha256:18783cca3cfee5b83c6c5d10b3cdb66c6594520ffae61890858fe8d932e1c6b4 \
--hash=sha256:349c8cd36aede4d50a0754a8c0218b43323d13d5d88f4b2952ddfe3e169681eb
# via -r requirements.in
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via
# -r requirements.in
# s3cmd
python-magic==0.4.27 \
--hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \
--hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3
# via s3cmd
pyyaml==6.0 \
--hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
requests==2.25.1 \
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e
# via -r requirements.in
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via yamllint
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
tabulate==0.9.0 \
--hash=sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c \
--hash=sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f
# via -r requirements.in
tomli==2.0.1 \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
# via pylint
tomlkit==0.11.6 \
--hash=sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b \
--hash=sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73
# via pylint
typing-extensions==4.4.0 \
--hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \
--hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e
# via
# astroid
# pylint
urllib3==1.26.13 \
--hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \
--hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8
# via requests
wrapt==1.14.1 \
--hash=sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3 \
--hash=sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b \
--hash=sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4 \
--hash=sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2 \
--hash=sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656 \
--hash=sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3 \
--hash=sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff \
--hash=sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310 \
--hash=sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a \
--hash=sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57 \
--hash=sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069 \
--hash=sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383 \
--hash=sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe \
--hash=sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87 \
--hash=sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d \
--hash=sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b \
--hash=sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907 \
--hash=sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f \
--hash=sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0 \
--hash=sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28 \
--hash=sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1 \
--hash=sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853 \
--hash=sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc \
--hash=sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3 \
--hash=sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3 \
--hash=sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164 \
--hash=sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1 \
--hash=sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c \
--hash=sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1 \
--hash=sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7 \
--hash=sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1 \
--hash=sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320 \
--hash=sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed \
--hash=sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1 \
--hash=sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248 \
--hash=sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c \
--hash=sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456 \
--hash=sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77 \
--hash=sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef \
--hash=sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1 \
--hash=sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7 \
--hash=sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86 \
--hash=sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4 \
--hash=sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d \
--hash=sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d \
--hash=sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8 \
--hash=sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5 \
--hash=sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471 \
--hash=sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00 \
--hash=sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68 \
--hash=sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3 \
--hash=sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d \
--hash=sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735 \
--hash=sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d \
--hash=sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569 \
--hash=sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7 \
--hash=sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59 \
--hash=sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5 \
--hash=sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb \
--hash=sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b \
--hash=sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f \
--hash=sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462 \
--hash=sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015 \
--hash=sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af
# via astroid
yamllint==1.28.0 \
--hash=sha256:89bb5b5ac33b1ade059743cf227de73daa34d5e5a474b06a5e17fc16583b0cf2 \
--hash=sha256:9e3d8ddd16d0583214c5fdffe806c9344086721f107435f68bad990e5a88826b
# via -r requirements.in
rules_python-0.22.1/examples/bzlmod_build_file_generation/runfiles/ 0000775 0000000 0000000 00000000000 14540404546 0025662 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/runfiles/BUILD.bazel 0000664 0000000 0000000 00000001053 14540404546 0027537 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_test")
# gazelle:ignore
py_test(
name = "runfiles_test",
srcs = ["runfiles_test.py"],
data = [
"data/data.txt",
"@our_other_module//other_module/pkg:data/data.txt",
],
env = {
"DATA_RLOCATIONPATH": "$(rlocationpath data/data.txt)",
"OTHER_MODULE_DATA_RLOCATIONPATH": "$(rlocationpath @our_other_module//other_module/pkg:data/data.txt)",
},
deps = [
"@our_other_module//other_module/pkg:lib",
"@rules_python//python/runfiles",
],
)
rules_python-0.22.1/examples/bzlmod_build_file_generation/runfiles/data/ 0000775 0000000 0000000 00000000000 14540404546 0026573 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/bzlmod_build_file_generation/runfiles/data/data.txt 0000664 0000000 0000000 00000000027 14540404546 0030244 0 ustar 00root root 0000000 0000000 Hello, example_bzlmod!
rules_python-0.22.1/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py 0000664 0000000 0000000 00000004745 14540404546 0031134 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import unittest
from other_module.pkg import lib
from python.runfiles import runfiles
class RunfilesTest(unittest.TestCase):
# """Unit tests for `runfiles.Runfiles`."""
def testCurrentRepository(self):
self.assertEqual(runfiles.Create().CurrentRepository(), "")
def testRunfilesWithRepoMapping(self):
data_path = runfiles.Create().Rlocation("example_bzlmod_build_file_generation/runfiles/data/data.txt")
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, example_bzlmod!")
def testRunfileWithRlocationpath(self):
data_rlocationpath = os.getenv("DATA_RLOCATIONPATH")
data_path = runfiles.Create().Rlocation(data_rlocationpath)
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, example_bzlmod!")
def testRunfileInOtherModuleWithOurRepoMapping(self):
data_path = runfiles.Create().Rlocation(
"our_other_module/other_module/pkg/data/data.txt"
)
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
def testRunfileInOtherModuleWithItsRepoMapping(self):
data_path = lib.GetRunfilePathWithRepoMapping()
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
def testRunfileInOtherModuleWithCurrentRepository(self):
data_path = lib.GetRunfilePathWithCurrentRepository()
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
def testRunfileInOtherModuleWithRlocationpath(self):
data_rlocationpath = os.getenv("OTHER_MODULE_DATA_RLOCATIONPATH")
data_path = runfiles.Create().Rlocation(data_rlocationpath)
with open(data_path) as f:
self.assertEqual(f.read().strip(), "Hello, other_module!")
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/multi_python_versions/ 0000775 0000000 0000000 00000000000 14540404546 0022636 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/multi_python_versions/.bazelrc 0000664 0000000 0000000 00000000266 14540404546 0024265 0 ustar 00root root 0000000 0000000 test --test_output=errors
# Windows requires these for multi-python support:
build --enable_runfiles
startup --windows_enable_symlinks
coverage --java_runtime_version=remotejdk_11
rules_python-0.22.1/examples/multi_python_versions/.gitignore 0000664 0000000 0000000 00000000010 14540404546 0024615 0 ustar 00root root 0000000 0000000 bazel-*
rules_python-0.22.1/examples/multi_python_versions/WORKSPACE 0000664 0000000 0000000 00000002764 14540404546 0024130 0 ustar 00root root 0000000 0000000 workspace(name = "rules_python_multi_python_versions")
local_repository(
name = "rules_python",
path = "../..",
)
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains")
py_repositories()
load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies")
pip_install_dependencies()
default_python_version = "3.9"
python_register_multi_toolchains(
name = "python",
default_version = default_python_version,
python_versions = [
"3.8",
"3.9",
"3.10",
"3.11",
],
register_coverage_tool = True,
)
load("@python//:pip.bzl", "multi_pip_parse")
load("@python//3.10:defs.bzl", interpreter_3_10 = "interpreter")
load("@python//3.11:defs.bzl", interpreter_3_11 = "interpreter")
load("@python//3.8:defs.bzl", interpreter_3_8 = "interpreter")
load("@python//3.9:defs.bzl", interpreter_3_9 = "interpreter")
multi_pip_parse(
name = "pypi",
default_version = default_python_version,
python_interpreter_target = {
"3.10": interpreter_3_10,
"3.11": interpreter_3_11,
"3.8": interpreter_3_8,
"3.9": interpreter_3_9,
},
requirements_lock = {
"3.10": "//requirements:requirements_lock_3_10.txt",
"3.11": "//requirements:requirements_lock_3_11.txt",
"3.8": "//requirements:requirements_lock_3_8.txt",
"3.9": "//requirements:requirements_lock_3_9.txt",
},
)
load("@pypi//:requirements.bzl", "install_deps")
install_deps()
rules_python-0.22.1/examples/multi_python_versions/libs/ 0000775 0000000 0000000 00000000000 14540404546 0023567 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/multi_python_versions/libs/my_lib/ 0000775 0000000 0000000 00000000000 14540404546 0025042 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/multi_python_versions/libs/my_lib/BUILD.bazel 0000664 0000000 0000000 00000000364 14540404546 0026723 0 ustar 00root root 0000000 0000000 load("@pypi//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "my_lib",
srcs = ["__init__.py"],
visibility = ["@//tests:__pkg__"],
deps = [requirement("websockets")],
)
rules_python-0.22.1/examples/multi_python_versions/libs/my_lib/__init__.py 0000664 0000000 0000000 00000001376 14540404546 0027162 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import websockets
def websockets_is_for_python_version(sanitized_version_check):
return f"pypi_{sanitized_version_check}_websockets" in websockets.__file__
rules_python-0.22.1/examples/multi_python_versions/requirements/ 0000775 0000000 0000000 00000000000 14540404546 0025361 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/multi_python_versions/requirements/BUILD.bazel 0000664 0000000 0000000 00000002166 14540404546 0027244 0 ustar 00root root 0000000 0000000 load("@python//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
load("@python//3.11:defs.bzl", compile_pip_requirements_3_11 = "compile_pip_requirements")
load("@python//3.8:defs.bzl", compile_pip_requirements_3_8 = "compile_pip_requirements")
load("@python//3.9:defs.bzl", compile_pip_requirements_3_9 = "compile_pip_requirements")
compile_pip_requirements_3_8(
name = "requirements_3_8",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock_3_8.txt",
)
compile_pip_requirements_3_9(
name = "requirements_3_9",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock_3_9.txt",
)
compile_pip_requirements_3_10(
name = "requirements_3_10",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock_3_10.txt",
)
compile_pip_requirements_3_11(
name = "requirements_3_11",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock_3_11.txt",
)
rules_python-0.22.1/examples/multi_python_versions/requirements/requirements.in 0000664 0000000 0000000 00000000013 14540404546 0030426 0 ustar 00root root 0000000 0000000 websockets
rules_python-0.22.1/examples/multi_python_versions/requirements/requirements_lock_3_10.txt 0000664 0000000 0000000 00000010301 14540404546 0032372 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# bazel run //requirements:requirements_3_10.update
#
websockets==10.3 \
--hash=sha256:07cdc0a5b2549bcfbadb585ad8471ebdc7bdf91e32e34ae3889001c1c106a6af \
--hash=sha256:210aad7fdd381c52e58777560860c7e6110b6174488ef1d4b681c08b68bf7f8c \
--hash=sha256:28dd20b938a57c3124028680dc1600c197294da5db4292c76a0b48efb3ed7f76 \
--hash=sha256:2f94fa3ae454a63ea3a19f73b95deeebc9f02ba2d5617ca16f0bbdae375cda47 \
--hash=sha256:31564a67c3e4005f27815634343df688b25705cccb22bc1db621c781ddc64c69 \
--hash=sha256:347974105bbd4ea068106ec65e8e8ebd86f28c19e529d115d89bd8cc5cda3079 \
--hash=sha256:379e03422178436af4f3abe0aa8f401aa77ae2487843738542a75faf44a31f0c \
--hash=sha256:3eda1cb7e9da1b22588cefff09f0951771d6ee9fa8dbe66f5ae04cc5f26b2b55 \
--hash=sha256:51695d3b199cd03098ae5b42833006a0f43dc5418d3102972addc593a783bc02 \
--hash=sha256:54c000abeaff6d8771a4e2cef40900919908ea7b6b6a30eae72752607c6db559 \
--hash=sha256:5b936bf552e4f6357f5727579072ff1e1324717902127ffe60c92d29b67b7be3 \
--hash=sha256:6075fd24df23133c1b078e08a9b04a3bc40b31a8def4ee0b9f2c8865acce913e \
--hash=sha256:661f641b44ed315556a2fa630239adfd77bd1b11cb0b9d96ed8ad90b0b1e4978 \
--hash=sha256:6ea6b300a6bdd782e49922d690e11c3669828fe36fc2471408c58b93b5535a98 \
--hash=sha256:6ed1d6f791eabfd9808afea1e068f5e59418e55721db8b7f3bfc39dc831c42ae \
--hash=sha256:7934e055fd5cd9dee60f11d16c8d79c4567315824bacb1246d0208a47eca9755 \
--hash=sha256:7ab36e17af592eec5747c68ef2722a74c1a4a70f3772bc661079baf4ae30e40d \
--hash=sha256:7f6d96fdb0975044fdd7953b35d003b03f9e2bcf85f2d2cf86285ece53e9f991 \
--hash=sha256:83e5ca0d5b743cde3d29fda74ccab37bdd0911f25bd4cdf09ff8b51b7b4f2fa1 \
--hash=sha256:85506b3328a9e083cc0a0fb3ba27e33c8db78341b3eb12eb72e8afd166c36680 \
--hash=sha256:8af75085b4bc0b5c40c4a3c0e113fa95e84c60f4ed6786cbb675aeb1ee128247 \
--hash=sha256:8b1359aba0ff810d5830d5ab8e2c4a02bebf98a60aa0124fb29aa78cfdb8031f \
--hash=sha256:8fbd7d77f8aba46d43245e86dd91a8970eac4fb74c473f8e30e9c07581f852b2 \
--hash=sha256:907e8247480f287aa9bbc9391bd6de23c906d48af54c8c421df84655eef66af7 \
--hash=sha256:93d5ea0b5da8d66d868b32c614d2b52d14304444e39e13a59566d4acb8d6e2e4 \
--hash=sha256:97bc9d41e69a7521a358f9b8e44871f6cdeb42af31815c17aed36372d4eec667 \
--hash=sha256:994cdb1942a7a4c2e10098d9162948c9e7b235df755de91ca33f6e0481366fdb \
--hash=sha256:a141de3d5a92188234afa61653ed0bbd2dde46ad47b15c3042ffb89548e77094 \
--hash=sha256:a1e15b230c3613e8ea82c9fc6941b2093e8eb939dd794c02754d33980ba81e36 \
--hash=sha256:aad5e300ab32036eb3fdc350ad30877210e2f51bceaca83fb7fef4d2b6c72b79 \
--hash=sha256:b529fdfa881b69fe563dbd98acce84f3e5a67df13de415e143ef053ff006d500 \
--hash=sha256:b9c77f0d1436ea4b4dc089ed8335fa141e6a251a92f75f675056dac4ab47a71e \
--hash=sha256:bb621ec2dbbbe8df78a27dbd9dd7919f9b7d32a73fafcb4d9252fc4637343582 \
--hash=sha256:c7250848ce69559756ad0086a37b82c986cd33c2d344ab87fea596c5ac6d9442 \
--hash=sha256:c8d1d14aa0f600b5be363077b621b1b4d1eb3fbf90af83f9281cda668e6ff7fd \
--hash=sha256:d1655a6fc7aecd333b079d00fb3c8132d18988e47f19740c69303bf02e9883c6 \
--hash=sha256:d6353ba89cfc657a3f5beabb3b69be226adbb5c6c7a66398e17809b0ce3c4731 \
--hash=sha256:da4377904a3379f0c1b75a965fff23b28315bcd516d27f99a803720dfebd94d4 \
--hash=sha256:e49ea4c1a9543d2bd8a747ff24411509c29e4bdcde05b5b0895e2120cb1a761d \
--hash=sha256:e4e08305bfd76ba8edab08dcc6496f40674f44eb9d5e23153efa0a35750337e8 \
--hash=sha256:e6fa05a680e35d0fcc1470cb070b10e6fe247af54768f488ed93542e71339d6f \
--hash=sha256:e7e6f2d6fd48422071cc8a6f8542016f350b79cc782752de531577d35e9bd677 \
--hash=sha256:e904c0381c014b914136c492c8fa711ca4cced4e9b3d110e5e7d436d0fc289e8 \
--hash=sha256:ec2b0ab7edc8cd4b0eb428b38ed89079bdc20c6bdb5f889d353011038caac2f9 \
--hash=sha256:ef5ce841e102278c1c2e98f043db99d6755b1c58bde475516aef3a008ed7f28e \
--hash=sha256:f351c7d7d92f67c0609329ab2735eee0426a03022771b00102816a72715bb00b \
--hash=sha256:fab7c640815812ed5f10fbee7abbf58788d602046b7bb3af9b1ac753a6d5e916 \
--hash=sha256:fc06cc8073c8e87072138ba1e431300e2d408f054b27047d047b549455066ff4
# via -r requirements/requirements.in
rules_python-0.22.1/examples/multi_python_versions/requirements/requirements_lock_3_11.txt 0000664 0000000 0000000 00000010301 14540404546 0032373 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# bazel run //requirements:requirements_3_11.update
#
websockets==10.3 \
--hash=sha256:07cdc0a5b2549bcfbadb585ad8471ebdc7bdf91e32e34ae3889001c1c106a6af \
--hash=sha256:210aad7fdd381c52e58777560860c7e6110b6174488ef1d4b681c08b68bf7f8c \
--hash=sha256:28dd20b938a57c3124028680dc1600c197294da5db4292c76a0b48efb3ed7f76 \
--hash=sha256:2f94fa3ae454a63ea3a19f73b95deeebc9f02ba2d5617ca16f0bbdae375cda47 \
--hash=sha256:31564a67c3e4005f27815634343df688b25705cccb22bc1db621c781ddc64c69 \
--hash=sha256:347974105bbd4ea068106ec65e8e8ebd86f28c19e529d115d89bd8cc5cda3079 \
--hash=sha256:379e03422178436af4f3abe0aa8f401aa77ae2487843738542a75faf44a31f0c \
--hash=sha256:3eda1cb7e9da1b22588cefff09f0951771d6ee9fa8dbe66f5ae04cc5f26b2b55 \
--hash=sha256:51695d3b199cd03098ae5b42833006a0f43dc5418d3102972addc593a783bc02 \
--hash=sha256:54c000abeaff6d8771a4e2cef40900919908ea7b6b6a30eae72752607c6db559 \
--hash=sha256:5b936bf552e4f6357f5727579072ff1e1324717902127ffe60c92d29b67b7be3 \
--hash=sha256:6075fd24df23133c1b078e08a9b04a3bc40b31a8def4ee0b9f2c8865acce913e \
--hash=sha256:661f641b44ed315556a2fa630239adfd77bd1b11cb0b9d96ed8ad90b0b1e4978 \
--hash=sha256:6ea6b300a6bdd782e49922d690e11c3669828fe36fc2471408c58b93b5535a98 \
--hash=sha256:6ed1d6f791eabfd9808afea1e068f5e59418e55721db8b7f3bfc39dc831c42ae \
--hash=sha256:7934e055fd5cd9dee60f11d16c8d79c4567315824bacb1246d0208a47eca9755 \
--hash=sha256:7ab36e17af592eec5747c68ef2722a74c1a4a70f3772bc661079baf4ae30e40d \
--hash=sha256:7f6d96fdb0975044fdd7953b35d003b03f9e2bcf85f2d2cf86285ece53e9f991 \
--hash=sha256:83e5ca0d5b743cde3d29fda74ccab37bdd0911f25bd4cdf09ff8b51b7b4f2fa1 \
--hash=sha256:85506b3328a9e083cc0a0fb3ba27e33c8db78341b3eb12eb72e8afd166c36680 \
--hash=sha256:8af75085b4bc0b5c40c4a3c0e113fa95e84c60f4ed6786cbb675aeb1ee128247 \
--hash=sha256:8b1359aba0ff810d5830d5ab8e2c4a02bebf98a60aa0124fb29aa78cfdb8031f \
--hash=sha256:8fbd7d77f8aba46d43245e86dd91a8970eac4fb74c473f8e30e9c07581f852b2 \
--hash=sha256:907e8247480f287aa9bbc9391bd6de23c906d48af54c8c421df84655eef66af7 \
--hash=sha256:93d5ea0b5da8d66d868b32c614d2b52d14304444e39e13a59566d4acb8d6e2e4 \
--hash=sha256:97bc9d41e69a7521a358f9b8e44871f6cdeb42af31815c17aed36372d4eec667 \
--hash=sha256:994cdb1942a7a4c2e10098d9162948c9e7b235df755de91ca33f6e0481366fdb \
--hash=sha256:a141de3d5a92188234afa61653ed0bbd2dde46ad47b15c3042ffb89548e77094 \
--hash=sha256:a1e15b230c3613e8ea82c9fc6941b2093e8eb939dd794c02754d33980ba81e36 \
--hash=sha256:aad5e300ab32036eb3fdc350ad30877210e2f51bceaca83fb7fef4d2b6c72b79 \
--hash=sha256:b529fdfa881b69fe563dbd98acce84f3e5a67df13de415e143ef053ff006d500 \
--hash=sha256:b9c77f0d1436ea4b4dc089ed8335fa141e6a251a92f75f675056dac4ab47a71e \
--hash=sha256:bb621ec2dbbbe8df78a27dbd9dd7919f9b7d32a73fafcb4d9252fc4637343582 \
--hash=sha256:c7250848ce69559756ad0086a37b82c986cd33c2d344ab87fea596c5ac6d9442 \
--hash=sha256:c8d1d14aa0f600b5be363077b621b1b4d1eb3fbf90af83f9281cda668e6ff7fd \
--hash=sha256:d1655a6fc7aecd333b079d00fb3c8132d18988e47f19740c69303bf02e9883c6 \
--hash=sha256:d6353ba89cfc657a3f5beabb3b69be226adbb5c6c7a66398e17809b0ce3c4731 \
--hash=sha256:da4377904a3379f0c1b75a965fff23b28315bcd516d27f99a803720dfebd94d4 \
--hash=sha256:e49ea4c1a9543d2bd8a747ff24411509c29e4bdcde05b5b0895e2120cb1a761d \
--hash=sha256:e4e08305bfd76ba8edab08dcc6496f40674f44eb9d5e23153efa0a35750337e8 \
--hash=sha256:e6fa05a680e35d0fcc1470cb070b10e6fe247af54768f488ed93542e71339d6f \
--hash=sha256:e7e6f2d6fd48422071cc8a6f8542016f350b79cc782752de531577d35e9bd677 \
--hash=sha256:e904c0381c014b914136c492c8fa711ca4cced4e9b3d110e5e7d436d0fc289e8 \
--hash=sha256:ec2b0ab7edc8cd4b0eb428b38ed89079bdc20c6bdb5f889d353011038caac2f9 \
--hash=sha256:ef5ce841e102278c1c2e98f043db99d6755b1c58bde475516aef3a008ed7f28e \
--hash=sha256:f351c7d7d92f67c0609329ab2735eee0426a03022771b00102816a72715bb00b \
--hash=sha256:fab7c640815812ed5f10fbee7abbf58788d602046b7bb3af9b1ac753a6d5e916 \
--hash=sha256:fc06cc8073c8e87072138ba1e431300e2d408f054b27047d047b549455066ff4
# via -r requirements/requirements.in
rules_python-0.22.1/examples/multi_python_versions/requirements/requirements_lock_3_8.txt 0000664 0000000 0000000 00000010277 14540404546 0032335 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# bazel run //requirements:requirements_3_8.update
#
websockets==10.3 \
--hash=sha256:07cdc0a5b2549bcfbadb585ad8471ebdc7bdf91e32e34ae3889001c1c106a6af \
--hash=sha256:210aad7fdd381c52e58777560860c7e6110b6174488ef1d4b681c08b68bf7f8c \
--hash=sha256:28dd20b938a57c3124028680dc1600c197294da5db4292c76a0b48efb3ed7f76 \
--hash=sha256:2f94fa3ae454a63ea3a19f73b95deeebc9f02ba2d5617ca16f0bbdae375cda47 \
--hash=sha256:31564a67c3e4005f27815634343df688b25705cccb22bc1db621c781ddc64c69 \
--hash=sha256:347974105bbd4ea068106ec65e8e8ebd86f28c19e529d115d89bd8cc5cda3079 \
--hash=sha256:379e03422178436af4f3abe0aa8f401aa77ae2487843738542a75faf44a31f0c \
--hash=sha256:3eda1cb7e9da1b22588cefff09f0951771d6ee9fa8dbe66f5ae04cc5f26b2b55 \
--hash=sha256:51695d3b199cd03098ae5b42833006a0f43dc5418d3102972addc593a783bc02 \
--hash=sha256:54c000abeaff6d8771a4e2cef40900919908ea7b6b6a30eae72752607c6db559 \
--hash=sha256:5b936bf552e4f6357f5727579072ff1e1324717902127ffe60c92d29b67b7be3 \
--hash=sha256:6075fd24df23133c1b078e08a9b04a3bc40b31a8def4ee0b9f2c8865acce913e \
--hash=sha256:661f641b44ed315556a2fa630239adfd77bd1b11cb0b9d96ed8ad90b0b1e4978 \
--hash=sha256:6ea6b300a6bdd782e49922d690e11c3669828fe36fc2471408c58b93b5535a98 \
--hash=sha256:6ed1d6f791eabfd9808afea1e068f5e59418e55721db8b7f3bfc39dc831c42ae \
--hash=sha256:7934e055fd5cd9dee60f11d16c8d79c4567315824bacb1246d0208a47eca9755 \
--hash=sha256:7ab36e17af592eec5747c68ef2722a74c1a4a70f3772bc661079baf4ae30e40d \
--hash=sha256:7f6d96fdb0975044fdd7953b35d003b03f9e2bcf85f2d2cf86285ece53e9f991 \
--hash=sha256:83e5ca0d5b743cde3d29fda74ccab37bdd0911f25bd4cdf09ff8b51b7b4f2fa1 \
--hash=sha256:85506b3328a9e083cc0a0fb3ba27e33c8db78341b3eb12eb72e8afd166c36680 \
--hash=sha256:8af75085b4bc0b5c40c4a3c0e113fa95e84c60f4ed6786cbb675aeb1ee128247 \
--hash=sha256:8b1359aba0ff810d5830d5ab8e2c4a02bebf98a60aa0124fb29aa78cfdb8031f \
--hash=sha256:8fbd7d77f8aba46d43245e86dd91a8970eac4fb74c473f8e30e9c07581f852b2 \
--hash=sha256:907e8247480f287aa9bbc9391bd6de23c906d48af54c8c421df84655eef66af7 \
--hash=sha256:93d5ea0b5da8d66d868b32c614d2b52d14304444e39e13a59566d4acb8d6e2e4 \
--hash=sha256:97bc9d41e69a7521a358f9b8e44871f6cdeb42af31815c17aed36372d4eec667 \
--hash=sha256:994cdb1942a7a4c2e10098d9162948c9e7b235df755de91ca33f6e0481366fdb \
--hash=sha256:a141de3d5a92188234afa61653ed0bbd2dde46ad47b15c3042ffb89548e77094 \
--hash=sha256:a1e15b230c3613e8ea82c9fc6941b2093e8eb939dd794c02754d33980ba81e36 \
--hash=sha256:aad5e300ab32036eb3fdc350ad30877210e2f51bceaca83fb7fef4d2b6c72b79 \
--hash=sha256:b529fdfa881b69fe563dbd98acce84f3e5a67df13de415e143ef053ff006d500 \
--hash=sha256:b9c77f0d1436ea4b4dc089ed8335fa141e6a251a92f75f675056dac4ab47a71e \
--hash=sha256:bb621ec2dbbbe8df78a27dbd9dd7919f9b7d32a73fafcb4d9252fc4637343582 \
--hash=sha256:c7250848ce69559756ad0086a37b82c986cd33c2d344ab87fea596c5ac6d9442 \
--hash=sha256:c8d1d14aa0f600b5be363077b621b1b4d1eb3fbf90af83f9281cda668e6ff7fd \
--hash=sha256:d1655a6fc7aecd333b079d00fb3c8132d18988e47f19740c69303bf02e9883c6 \
--hash=sha256:d6353ba89cfc657a3f5beabb3b69be226adbb5c6c7a66398e17809b0ce3c4731 \
--hash=sha256:da4377904a3379f0c1b75a965fff23b28315bcd516d27f99a803720dfebd94d4 \
--hash=sha256:e49ea4c1a9543d2bd8a747ff24411509c29e4bdcde05b5b0895e2120cb1a761d \
--hash=sha256:e4e08305bfd76ba8edab08dcc6496f40674f44eb9d5e23153efa0a35750337e8 \
--hash=sha256:e6fa05a680e35d0fcc1470cb070b10e6fe247af54768f488ed93542e71339d6f \
--hash=sha256:e7e6f2d6fd48422071cc8a6f8542016f350b79cc782752de531577d35e9bd677 \
--hash=sha256:e904c0381c014b914136c492c8fa711ca4cced4e9b3d110e5e7d436d0fc289e8 \
--hash=sha256:ec2b0ab7edc8cd4b0eb428b38ed89079bdc20c6bdb5f889d353011038caac2f9 \
--hash=sha256:ef5ce841e102278c1c2e98f043db99d6755b1c58bde475516aef3a008ed7f28e \
--hash=sha256:f351c7d7d92f67c0609329ab2735eee0426a03022771b00102816a72715bb00b \
--hash=sha256:fab7c640815812ed5f10fbee7abbf58788d602046b7bb3af9b1ac753a6d5e916 \
--hash=sha256:fc06cc8073c8e87072138ba1e431300e2d408f054b27047d047b549455066ff4
# via -r requirements/requirements.in
rules_python-0.22.1/examples/multi_python_versions/requirements/requirements_lock_3_9.txt 0000664 0000000 0000000 00000010277 14540404546 0032336 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //requirements:requirements_3_9.update
#
websockets==10.3 \
--hash=sha256:07cdc0a5b2549bcfbadb585ad8471ebdc7bdf91e32e34ae3889001c1c106a6af \
--hash=sha256:210aad7fdd381c52e58777560860c7e6110b6174488ef1d4b681c08b68bf7f8c \
--hash=sha256:28dd20b938a57c3124028680dc1600c197294da5db4292c76a0b48efb3ed7f76 \
--hash=sha256:2f94fa3ae454a63ea3a19f73b95deeebc9f02ba2d5617ca16f0bbdae375cda47 \
--hash=sha256:31564a67c3e4005f27815634343df688b25705cccb22bc1db621c781ddc64c69 \
--hash=sha256:347974105bbd4ea068106ec65e8e8ebd86f28c19e529d115d89bd8cc5cda3079 \
--hash=sha256:379e03422178436af4f3abe0aa8f401aa77ae2487843738542a75faf44a31f0c \
--hash=sha256:3eda1cb7e9da1b22588cefff09f0951771d6ee9fa8dbe66f5ae04cc5f26b2b55 \
--hash=sha256:51695d3b199cd03098ae5b42833006a0f43dc5418d3102972addc593a783bc02 \
--hash=sha256:54c000abeaff6d8771a4e2cef40900919908ea7b6b6a30eae72752607c6db559 \
--hash=sha256:5b936bf552e4f6357f5727579072ff1e1324717902127ffe60c92d29b67b7be3 \
--hash=sha256:6075fd24df23133c1b078e08a9b04a3bc40b31a8def4ee0b9f2c8865acce913e \
--hash=sha256:661f641b44ed315556a2fa630239adfd77bd1b11cb0b9d96ed8ad90b0b1e4978 \
--hash=sha256:6ea6b300a6bdd782e49922d690e11c3669828fe36fc2471408c58b93b5535a98 \
--hash=sha256:6ed1d6f791eabfd9808afea1e068f5e59418e55721db8b7f3bfc39dc831c42ae \
--hash=sha256:7934e055fd5cd9dee60f11d16c8d79c4567315824bacb1246d0208a47eca9755 \
--hash=sha256:7ab36e17af592eec5747c68ef2722a74c1a4a70f3772bc661079baf4ae30e40d \
--hash=sha256:7f6d96fdb0975044fdd7953b35d003b03f9e2bcf85f2d2cf86285ece53e9f991 \
--hash=sha256:83e5ca0d5b743cde3d29fda74ccab37bdd0911f25bd4cdf09ff8b51b7b4f2fa1 \
--hash=sha256:85506b3328a9e083cc0a0fb3ba27e33c8db78341b3eb12eb72e8afd166c36680 \
--hash=sha256:8af75085b4bc0b5c40c4a3c0e113fa95e84c60f4ed6786cbb675aeb1ee128247 \
--hash=sha256:8b1359aba0ff810d5830d5ab8e2c4a02bebf98a60aa0124fb29aa78cfdb8031f \
--hash=sha256:8fbd7d77f8aba46d43245e86dd91a8970eac4fb74c473f8e30e9c07581f852b2 \
--hash=sha256:907e8247480f287aa9bbc9391bd6de23c906d48af54c8c421df84655eef66af7 \
--hash=sha256:93d5ea0b5da8d66d868b32c614d2b52d14304444e39e13a59566d4acb8d6e2e4 \
--hash=sha256:97bc9d41e69a7521a358f9b8e44871f6cdeb42af31815c17aed36372d4eec667 \
--hash=sha256:994cdb1942a7a4c2e10098d9162948c9e7b235df755de91ca33f6e0481366fdb \
--hash=sha256:a141de3d5a92188234afa61653ed0bbd2dde46ad47b15c3042ffb89548e77094 \
--hash=sha256:a1e15b230c3613e8ea82c9fc6941b2093e8eb939dd794c02754d33980ba81e36 \
--hash=sha256:aad5e300ab32036eb3fdc350ad30877210e2f51bceaca83fb7fef4d2b6c72b79 \
--hash=sha256:b529fdfa881b69fe563dbd98acce84f3e5a67df13de415e143ef053ff006d500 \
--hash=sha256:b9c77f0d1436ea4b4dc089ed8335fa141e6a251a92f75f675056dac4ab47a71e \
--hash=sha256:bb621ec2dbbbe8df78a27dbd9dd7919f9b7d32a73fafcb4d9252fc4637343582 \
--hash=sha256:c7250848ce69559756ad0086a37b82c986cd33c2d344ab87fea596c5ac6d9442 \
--hash=sha256:c8d1d14aa0f600b5be363077b621b1b4d1eb3fbf90af83f9281cda668e6ff7fd \
--hash=sha256:d1655a6fc7aecd333b079d00fb3c8132d18988e47f19740c69303bf02e9883c6 \
--hash=sha256:d6353ba89cfc657a3f5beabb3b69be226adbb5c6c7a66398e17809b0ce3c4731 \
--hash=sha256:da4377904a3379f0c1b75a965fff23b28315bcd516d27f99a803720dfebd94d4 \
--hash=sha256:e49ea4c1a9543d2bd8a747ff24411509c29e4bdcde05b5b0895e2120cb1a761d \
--hash=sha256:e4e08305bfd76ba8edab08dcc6496f40674f44eb9d5e23153efa0a35750337e8 \
--hash=sha256:e6fa05a680e35d0fcc1470cb070b10e6fe247af54768f488ed93542e71339d6f \
--hash=sha256:e7e6f2d6fd48422071cc8a6f8542016f350b79cc782752de531577d35e9bd677 \
--hash=sha256:e904c0381c014b914136c492c8fa711ca4cced4e9b3d110e5e7d436d0fc289e8 \
--hash=sha256:ec2b0ab7edc8cd4b0eb428b38ed89079bdc20c6bdb5f889d353011038caac2f9 \
--hash=sha256:ef5ce841e102278c1c2e98f043db99d6755b1c58bde475516aef3a008ed7f28e \
--hash=sha256:f351c7d7d92f67c0609329ab2735eee0426a03022771b00102816a72715bb00b \
--hash=sha256:fab7c640815812ed5f10fbee7abbf58788d602046b7bb3af9b1ac753a6d5e916 \
--hash=sha256:fc06cc8073c8e87072138ba1e431300e2d408f054b27047d047b549455066ff4
# via -r requirements/requirements.in
rules_python-0.22.1/examples/multi_python_versions/tests/ 0000775 0000000 0000000 00000000000 14540404546 0024000 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/multi_python_versions/tests/BUILD.bazel 0000664 0000000 0000000 00000007557 14540404546 0025674 0 ustar 00root root 0000000 0000000 load("@python//3.10:defs.bzl", py_binary_3_10 = "py_binary", py_test_3_10 = "py_test")
load("@python//3.11:defs.bzl", py_binary_3_11 = "py_binary", py_test_3_11 = "py_test")
load("@python//3.8:defs.bzl", py_binary_3_8 = "py_binary", py_test_3_8 = "py_test")
load("@python//3.9:defs.bzl", py_binary_3_9 = "py_binary", py_test_3_9 = "py_test")
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
py_binary(
name = "version_default",
srcs = ["version.py"],
main = "version.py",
)
py_binary_3_8(
name = "version_3_8",
srcs = ["version.py"],
main = "version.py",
)
py_binary_3_9(
name = "version_3_9",
srcs = ["version.py"],
main = "version.py",
)
py_binary_3_10(
name = "version_3_10",
srcs = ["version.py"],
main = "version.py",
)
py_binary_3_11(
name = "version_3_11",
srcs = ["version.py"],
main = "version.py",
)
py_test(
name = "my_lib_default_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
deps = ["//libs/my_lib"],
)
py_test_3_8(
name = "my_lib_3_8_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
deps = ["//libs/my_lib"],
)
py_test_3_9(
name = "my_lib_3_9_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
deps = ["//libs/my_lib"],
)
py_test_3_10(
name = "my_lib_3_10_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
deps = ["//libs/my_lib"],
)
py_test_3_11(
name = "my_lib_3_11_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
deps = ["//libs/my_lib"],
)
py_test(
name = "version_default_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.9"}, # The default defined in the WORKSPACE.
main = "version_test.py",
)
py_test_3_8(
name = "version_3_8_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.8"},
main = "version_test.py",
)
py_test_3_9(
name = "version_3_9_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.9"},
main = "version_test.py",
)
py_test_3_10(
name = "version_3_10_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.10"},
main = "version_test.py",
)
py_test_3_11(
name = "version_3_11_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.11"},
main = "version_test.py",
)
py_test(
name = "version_default_takes_3_10_subprocess_test",
srcs = ["cross_version_test.py"],
data = [":version_3_10"],
env = {
"SUBPROCESS_VERSION_CHECK": "3.10",
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_10)",
"VERSION_CHECK": "3.9",
},
main = "cross_version_test.py",
)
py_test_3_10(
name = "version_3_10_takes_3_9_subprocess_test",
srcs = ["cross_version_test.py"],
data = [":version_3_9"],
env = {
"SUBPROCESS_VERSION_CHECK": "3.9",
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_9)",
"VERSION_CHECK": "3.10",
},
main = "cross_version_test.py",
)
sh_test(
name = "version_test_binary_default",
srcs = ["version_test.sh"],
data = [":version_default"],
env = {
"VERSION_CHECK": "3.9", # The default defined in the WORKSPACE.
"VERSION_PY_BINARY": "$(rootpath :version_default)",
},
)
sh_test(
name = "version_test_binary_3_8",
srcs = ["version_test.sh"],
data = [":version_3_8"],
env = {
"VERSION_CHECK": "3.8",
"VERSION_PY_BINARY": "$(rootpath :version_3_8)",
},
)
sh_test(
name = "version_test_binary_3_9",
srcs = ["version_test.sh"],
data = [":version_3_9"],
env = {
"VERSION_CHECK": "3.9",
"VERSION_PY_BINARY": "$(rootpath :version_3_9)",
},
)
sh_test(
name = "version_test_binary_3_10",
srcs = ["version_test.sh"],
data = [":version_3_10"],
env = {
"VERSION_CHECK": "3.10",
"VERSION_PY_BINARY": "$(rootpath :version_3_10)",
},
)
rules_python-0.22.1/examples/multi_python_versions/tests/cross_version_test.py 0000664 0000000 0000000 00000002426 14540404546 0030313 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import subprocess
import sys
process = subprocess.run(
[os.getenv("SUBPROCESS_VERSION_PY_BINARY")],
stdout=subprocess.PIPE,
universal_newlines=True,
)
subprocess_current = process.stdout.strip()
subprocess_expected = os.getenv("SUBPROCESS_VERSION_CHECK")
if subprocess_current != subprocess_expected:
print(
f"expected subprocess version '{subprocess_expected}' is different than returned '{subprocess_current}'"
)
sys.exit(1)
expected = os.getenv("VERSION_CHECK")
current = f"{sys.version_info.major}.{sys.version_info.minor}"
if current != expected:
print(f"expected version '{expected}' is different than returned '{current}'")
sys.exit(1)
rules_python-0.22.1/examples/multi_python_versions/tests/my_lib_test.py 0000664 0000000 0000000 00000001605 14540404546 0026666 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
import libs.my_lib as my_lib
sanitized_version_check = f"{sys.version_info.major}_{sys.version_info.minor}"
if not my_lib.websockets_is_for_python_version(sanitized_version_check):
print("expected package for Python version is different than returned")
sys.exit(1)
rules_python-0.22.1/examples/multi_python_versions/tests/version.py 0000664 0000000 0000000 00000001244 14540404546 0026040 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
print(f"{sys.version_info.major}.{sys.version_info.minor}")
rules_python-0.22.1/examples/multi_python_versions/tests/version_test.py 0000664 0000000 0000000 00000001523 14540404546 0027077 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
expected = os.getenv("VERSION_CHECK")
current = f"{sys.version_info.major}.{sys.version_info.minor}"
if current != expected:
print(f"expected version '{expected}' is different than returned '{current}'")
sys.exit(1)
rules_python-0.22.1/examples/multi_python_versions/tests/version_test.sh 0000775 0000000 0000000 00000001564 14540404546 0027071 0 ustar 00root root 0000000 0000000 #!/usr/bin/env bash
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit -o nounset -o pipefail
version_py_binary=$("${VERSION_PY_BINARY}")
if [[ "${version_py_binary}" != "${VERSION_CHECK}" ]]; then
echo >&2 "expected version '${VERSION_CHECK}' is different than returned '${version_py_binary}'"
exit 1
fi
rules_python-0.22.1/examples/pip_install/ 0000775 0000000 0000000 00000000000 14540404546 0020471 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/pip_install/.bazelrc 0000664 0000000 0000000 00000000170 14540404546 0022112 0 ustar 00root root 0000000 0000000 # https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
rules_python-0.22.1/examples/pip_install/.gitignore 0000664 0000000 0000000 00000000055 14540404546 0022461 0 ustar 00root root 0000000 0000000 # git ignore patterns
/bazel-*
user.bazelrc
rules_python-0.22.1/examples/pip_install/BUILD.bazel 0000664 0000000 0000000 00000005650 14540404546 0022355 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load(
"@pip//:requirements.bzl",
"data_requirement",
"dist_info_requirement",
"entry_point",
"requirement",
)
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
# Toolchain setup, this is optional.
# Demonstrate that we can use the same python interpreter for the toolchain and executing pip in pip install (see WORKSPACE).
#
#load("@rules_python//python:defs.bzl", "py_runtime_pair")
#
#py_runtime(
# name = "python3_runtime",
# files = ["@python_interpreter//:files"],
# interpreter = "@python_interpreter//:python_bin",
# python_version = "PY3",
# visibility = ["//visibility:public"],
#)
#
#py_runtime_pair(
# name = "my_py_runtime_pair",
# py2_runtime = None,
# py3_runtime = ":python3_runtime",
#)
#
#toolchain(
# name = "my_py_toolchain",
# toolchain = ":my_py_runtime_pair",
# toolchain_type = "@bazel_tools//tools/python:toolchain_type",
#)
# End of toolchain setup.
py_binary(
name = "main",
srcs = ["main.py"],
deps = [
requirement("boto3"),
],
)
py_test(
name = "test",
srcs = ["test.py"],
deps = [":main"],
)
# For pip dependencies which have entry points, the `entry_point` macro can be
# used from the generated `pip_install` repository to access a runnable binary.
alias(
name = "yamllint",
actual = entry_point("yamllint"),
)
# Check that our compiled requirements are up-to-date
compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_windows = ":requirements_windows.txt",
)
# Test the use of all pip_install utilities in a single py_test
py_test(
name = "pip_install_test",
srcs = ["pip_install_test.py"],
data = [
":yamllint",
data_requirement("s3cmd"),
dist_info_requirement("boto3"),
],
env = {
"WHEEL_DATA_CONTENTS": "$(rootpaths {})".format(data_requirement("s3cmd")),
"WHEEL_DIST_INFO_CONTENTS": "$(rootpaths {})".format(dist_info_requirement("boto3")),
"YAMLLINT_ENTRY_POINT": "$(rootpath :yamllint)",
},
deps = ["@rules_python//python/runfiles"],
)
# Assert that tags are present on resulting py_library,
# which is useful for tooling that needs to reflect on the dep graph
# to determine the packages it was built from.
genquery(
name = "yamllint_lib_by_version",
expression = """
attr("tags", "\\bpypi_version=1.26.3\\b", "@pip_yamllint//:pkg")
intersect
attr("tags", "\\bpypi_name=yamllint\\b", "@pip_yamllint//:pkg")
""",
scope = [requirement("yamllint")],
)
write_file(
name = "write_expected",
out = "expected",
content = [
"@pip_yamllint//:pkg",
"",
],
)
diff_test(
name = "test_query_result",
file1 = "expected",
file2 = "yamllint_lib_by_version",
)
rules_python-0.22.1/examples/pip_install/README.md 0000664 0000000 0000000 00000000265 14540404546 0021753 0 ustar 00root root 0000000 0000000 # pip_install example
This example shows how to use pip to fetch external dependencies from a requirements.txt file,
then use them in BUILD files as dependencies of Bazel targets.
rules_python-0.22.1/examples/pip_install/WORKSPACE 0000664 0000000 0000000 00000006763 14540404546 0021766 0 ustar 00root root 0000000 0000000 workspace(name = "rules_python_pip_install_example")
local_repository(
name = "rules_python",
path = "../..",
)
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
py_repositories()
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
# (Optional) You can provide extra parameters to pip.
# Here, make pip output verbose (this is usable with `quiet = False`).
#extra_pip_args = ["-v"],
# (Optional) You can exclude custom elements in the data section of the generated BUILD files for pip packages.
# Exclude directories with spaces in their names in this example (avoids build errors if there are such directories).
#pip_data_exclude = ["**/* */**"],
# (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
# acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
# 1. Python interpreter that you compile in the build file (as above in @python_interpreter).
# 2. Pre-compiled python interpreter included with http_archive
# 3. Wrapper script, like in the autodetecting python toolchain.
#
# Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain.
python_interpreter_target = interpreter,
# (Optional) You can set quiet to False if you want to see pip output.
#quiet = False,
# (Optional) You can set an environment in the pip process to control its
# behavior. Note that pip is run in "isolated" mode so no PIP__
# style env vars are read, but env vars that control requests and urllib3
# can be passed.
#environment = {"HTTP_PROXY": "http://my.proxy.fun/"},
# Uses the default repository name "pip"
requirements = "//:requirements.txt",
)
load("@pip//:requirements.bzl", "install_deps")
# Initialize repositories for all packages in requirements.txt.
install_deps()
# You could optionally use an in-build, compiled python interpreter as a toolchain,
# and also use it to execute pip.
#
# Special logic for building python interpreter with OpenSSL from homebrew.
# See https://devguide.python.org/setup/#macos-and-os-x
#_py_configure = """
#if [[ "$OSTYPE" == "darwin"* ]]; then
# ./configure --prefix=$(pwd)/bazel_install --with-openssl=$(brew --prefix openssl)
#else
# ./configure --prefix=$(pwd)/bazel_install
#fi
#"""
#
# NOTE: you need to have the SSL headers installed to build with openssl support (and use HTTPS).
# E.g. on Ubuntu: `sudo apt install libssl-dev`
#http_archive(
# name = "python_interpreter",
# build_file_content = """
#exports_files(["python_bin"])
#filegroup(
# name = "files",
# srcs = glob(["bazel_install/**"], exclude = ["**/* *"]),
# visibility = ["//visibility:public"],
#)
#""",
# patch_cmds = [
# "mkdir $(pwd)/bazel_install",
# _py_configure,
# "make",
# "make install",
# "ln -s bazel_install/bin/python3 python_bin",
# ],
# sha256 = "dfab5ec723c218082fe3d5d7ae17ecbdebffa9a1aea4d64aa3a2ecdd2e795864",
# strip_prefix = "Python-3.8.3",
# urls = ["https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz"],
#)
# Optional:
# Register the toolchain with the same python interpreter we used for pip in pip_install().
#register_toolchains("//:my_py_toolchain")
# End of in-build Python interpreter setup.
rules_python-0.22.1/examples/pip_install/main.py 0000664 0000000 0000000 00000001302 14540404546 0021763 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import boto3
def the_dir():
return dir(boto3)
if __name__ == "__main__":
print(the_dir())
rules_python-0.22.1/examples/pip_install/pip_install_test.py 0000664 0000000 0000000 00000005605 14540404546 0024426 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python3
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import subprocess
import unittest
from pathlib import Path
from rules_python.python.runfiles import runfiles
class PipInstallTest(unittest.TestCase):
maxDiff = None
def test_entry_point(self):
env = os.environ.get("YAMLLINT_ENTRY_POINT")
self.assertIsNotNone(env)
r = runfiles.Create()
# To find an external target, this must use `{workspace_name}/$(rootpath @external_repo//:target)`
entry_point = Path(
r.Rlocation("rules_python_pip_install_example/{}".format(env))
)
self.assertTrue(entry_point.exists())
proc = subprocess.run(
[str(entry_point), "--version"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
def test_data(self):
env = os.environ.get("WHEEL_DATA_CONTENTS")
self.assertIsNotNone(env)
self.assertListEqual(
env.split(" "),
[
"external/pip_s3cmd/data/share/doc/packages/s3cmd/INSTALL.md",
"external/pip_s3cmd/data/share/doc/packages/s3cmd/LICENSE",
"external/pip_s3cmd/data/share/doc/packages/s3cmd/NEWS",
"external/pip_s3cmd/data/share/doc/packages/s3cmd/README.md",
"external/pip_s3cmd/data/share/man/man1/s3cmd.1",
],
)
def test_dist_info(self):
env = os.environ.get("WHEEL_DIST_INFO_CONTENTS")
self.assertIsNotNone(env)
self.assertListEqual(
env.split(" "),
[
"external/pip_boto3/site-packages/boto3-1.14.63.dist-info/DESCRIPTION.rst",
"external/pip_boto3/site-packages/boto3-1.14.63.dist-info/INSTALLER",
"external/pip_boto3/site-packages/boto3-1.14.63.dist-info/METADATA",
"external/pip_boto3/site-packages/boto3-1.14.63.dist-info/RECORD",
"external/pip_boto3/site-packages/boto3-1.14.63.dist-info/WHEEL",
"external/pip_boto3/site-packages/boto3-1.14.63.dist-info/metadata.json",
"external/pip_boto3/site-packages/boto3-1.14.63.dist-info/top_level.txt",
],
)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/pip_install/requirements.in 0000664 0000000 0000000 00000000133 14540404546 0023541 0 ustar 00root root 0000000 0000000 boto3~=1.14.51
s3cmd~=2.1.0
yamllint~=1.26.3
tree-sitter==0.20.0 ; sys_platform != "win32"
rules_python-0.22.1/examples/pip_install/requirements.txt 0000664 0000000 0000000 00000014674 14540404546 0023771 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
boto3==1.14.63 \
--hash=sha256:25c716b7c01d4664027afc6a6418a06459e311a610c7fd39a030a1ced1b72ce4 \
--hash=sha256:37158c37a151eab5b9080968305621a40168171fda9584d50a309ceb4e5e6964
# via -r requirements.in
botocore==1.17.63 \
--hash=sha256:40f13f6c9c29c307a9dc5982739e537ddce55b29787b90c3447b507e3283bcd6 \
--hash=sha256:aa88eafc6295132f4bc606f1df32b3248e0fa611724c0a216aceda767948ac75
# via
# boto3
# s3transfer
docutils==0.15.2 \
--hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 \
--hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 \
--hash=sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99
# via botocore
jmespath==0.10.0 \
--hash=sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9 \
--hash=sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f
# via
# boto3
# botocore
pathspec==0.10.3 \
--hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \
--hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6
# via yamllint
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via
# botocore
# s3cmd
python-magic==0.4.27 \
--hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \
--hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3
# via s3cmd
pyyaml==6.0 \
--hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
s3transfer==0.3.7 \
--hash=sha256:35627b86af8ff97e7ac27975fe0a98a312814b46c6333d8a6b889627bcd80994 \
--hash=sha256:efa5bd92a897b6a8d5c1383828dca3d52d0790e0756d49740563a3fb6ed03246
# via boto3
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via yamllint
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
tree-sitter==0.20.0 ; sys_platform != "win32" \
--hash=sha256:1940f64be1e8c9c3c0e34a2258f1e4c324207534d5b1eefc5ab2960a9d98f668 \
--hash=sha256:51a609a7c1bd9d9e75d92ee128c12c7852ae70a482900fbbccf3d13a79e0378c
# via -r requirements.in
urllib3==1.25.11 \
--hash=sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2 \
--hash=sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e
# via botocore
yamllint==1.26.3 \
--hash=sha256:3934dcde484374596d6b52d8db412929a169f6d9e52e20f9ade5bf3523d9b96e
# via -r requirements.in
rules_python-0.22.1/examples/pip_install/requirements_windows.txt 0000664 0000000 0000000 00000014307 14540404546 0025534 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
boto3==1.14.63 \
--hash=sha256:25c716b7c01d4664027afc6a6418a06459e311a610c7fd39a030a1ced1b72ce4 \
--hash=sha256:37158c37a151eab5b9080968305621a40168171fda9584d50a309ceb4e5e6964
# via -r requirements.in
botocore==1.17.63 \
--hash=sha256:40f13f6c9c29c307a9dc5982739e537ddce55b29787b90c3447b507e3283bcd6 \
--hash=sha256:aa88eafc6295132f4bc606f1df32b3248e0fa611724c0a216aceda767948ac75
# via
# boto3
# s3transfer
docutils==0.15.2 \
--hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 \
--hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 \
--hash=sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99
# via botocore
jmespath==0.10.0 \
--hash=sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9 \
--hash=sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f
# via
# boto3
# botocore
pathspec==0.10.3 \
--hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \
--hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6
# via yamllint
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via
# botocore
# s3cmd
python-magic==0.4.27 \
--hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \
--hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3
# via s3cmd
pyyaml==6.0 \
--hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
s3transfer==0.3.7 \
--hash=sha256:35627b86af8ff97e7ac27975fe0a98a312814b46c6333d8a6b889627bcd80994 \
--hash=sha256:efa5bd92a897b6a8d5c1383828dca3d52d0790e0756d49740563a3fb6ed03246
# via boto3
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via yamllint
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
urllib3==1.25.11 \
--hash=sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2 \
--hash=sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e
# via botocore
yamllint==1.26.3 \
--hash=sha256:3934dcde484374596d6b52d8db412929a169f6d9e52e20f9ade5bf3523d9b96e
# via -r requirements.in
rules_python-0.22.1/examples/pip_install/test.py 0000664 0000000 0000000 00000001446 14540404546 0022027 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import main
class ExampleTest(unittest.TestCase):
def test_main(self):
self.assertIn("set_stream_logger", main.the_dir())
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/pip_parse/ 0000775 0000000 0000000 00000000000 14540404546 0020135 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/pip_parse/.bazelrc 0000664 0000000 0000000 00000000170 14540404546 0021556 0 ustar 00root root 0000000 0000000 # https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
rules_python-0.22.1/examples/pip_parse/.gitignore 0000664 0000000 0000000 00000000055 14540404546 0022125 0 ustar 00root root 0000000 0000000 # git ignore patterns
/bazel-*
user.bazelrc
rules_python-0.22.1/examples/pip_parse/BUILD.bazel 0000664 0000000 0000000 00000004246 14540404546 0022021 0 ustar 00root root 0000000 0000000 load(
"@pypi//:requirements.bzl",
"data_requirement",
"dist_info_requirement",
"entry_point",
)
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
# Toolchain setup, this is optional.
# Demonstrate that we can use the same python interpreter for the toolchain and executing pip in pip install (see WORKSPACE).
#
#load("@rules_python//python:defs.bzl", "py_runtime_pair")
#
#py_runtime(
# name = "python3_runtime",
# files = ["@python_interpreter//:files"],
# interpreter = "@python_interpreter//:python_bin",
# python_version = "PY3",
# visibility = ["//visibility:public"],
#)
#
#py_runtime_pair(
# name = "my_py_runtime_pair",
# py2_runtime = None,
# py3_runtime = ":python3_runtime",
#)
#
#toolchain(
# name = "my_py_toolchain",
# toolchain = ":my_py_runtime_pair",
# toolchain_type = "@bazel_tools//tools/python:toolchain_type",
#)
# End of toolchain setup.
py_binary(
name = "main",
srcs = ["main.py"],
deps = [
"@pypi_requests//:pkg",
],
)
py_test(
name = "test",
srcs = ["test.py"],
deps = [":main"],
)
# For pip dependencies which have entry points, the `entry_point` macro can be
# used from the generated `pip_parse` repository to access a runnable binary.
alias(
name = "yamllint",
actual = entry_point("yamllint"),
)
# This rule adds a convenient way to update the requirements file.
compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements_lock.txt",
)
# Test the use of all pip_parse utilities in a single py_test
py_test(
name = "pip_parse_test",
srcs = ["pip_parse_test.py"],
data = [
":yamllint",
data_requirement("s3cmd"),
dist_info_requirement("requests"),
],
env = {
"WHEEL_DATA_CONTENTS": "$(rootpaths {})".format(data_requirement("s3cmd")),
"WHEEL_DIST_INFO_CONTENTS": "$(rootpaths {})".format(dist_info_requirement("requests")),
"YAMLLINT_ENTRY_POINT": "$(rootpath :yamllint)",
},
deps = ["@rules_python//python/runfiles"],
)
rules_python-0.22.1/examples/pip_parse/WORKSPACE 0000664 0000000 0000000 00000004076 14540404546 0021425 0 ustar 00root root 0000000 0000000 workspace(name = "rules_python_pip_parse_example")
local_repository(
name = "rules_python",
path = "../..",
)
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
py_repositories()
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")
pip_parse(
# (Optional) You can set an environment in the pip process to control its
# behavior. Note that pip is run in "isolated" mode so no PIP__
# style env vars are read, but env vars that control requests and urllib3
# can be passed
# environment = {"HTTPS_PROXY": "http://my.proxy.fun/"},
name = "pypi",
# (Optional) You can provide extra parameters to pip.
# Here, make pip output verbose (this is usable with `quiet = False`).
# extra_pip_args = ["-v"],
# (Optional) You can exclude custom elements in the data section of the generated BUILD files for pip packages.
# Exclude directories with spaces in their names in this example (avoids build errors if there are such directories).
#pip_data_exclude = ["**/* */**"],
# (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
# acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
# 1. Python interpreter that you compile in the build file (as above in @python_interpreter).
# 2. Pre-compiled python interpreter included with http_archive
# 3. Wrapper script, like in the autodetecting python toolchain.
#
# Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain.
python_interpreter_target = interpreter,
# (Optional) You can set quiet to False if you want to see pip output.
#quiet = False,
requirements_lock = "//:requirements_lock.txt",
)
load("@pypi//:requirements.bzl", "install_deps")
# Initialize repositories for all packages in requirements_lock.txt.
install_deps()
rules_python-0.22.1/examples/pip_parse/main.py 0000664 0000000 0000000 00000001235 14540404546 0021434 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import requests
def version():
return requests.__version__
rules_python-0.22.1/examples/pip_parse/pip_parse_test.py 0000664 0000000 0000000 00000005464 14540404546 0023541 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python3
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import subprocess
import unittest
from pathlib import Path
from rules_python.python.runfiles import runfiles
class PipInstallTest(unittest.TestCase):
maxDiff = None
def test_entry_point(self):
env = os.environ.get("YAMLLINT_ENTRY_POINT")
self.assertIsNotNone(env)
r = runfiles.Create()
# To find an external target, this must use `{workspace_name}/$(rootpath @external_repo//:target)`
entry_point = Path(r.Rlocation("rules_python_pip_parse_example/{}".format(env)))
self.assertTrue(entry_point.exists())
proc = subprocess.run(
[str(entry_point), "--version"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.26.3")
def test_data(self):
env = os.environ.get("WHEEL_DATA_CONTENTS")
self.assertIsNotNone(env)
self.assertListEqual(
env.split(" "),
[
"external/pypi_s3cmd/data/share/doc/packages/s3cmd/INSTALL.md",
"external/pypi_s3cmd/data/share/doc/packages/s3cmd/LICENSE",
"external/pypi_s3cmd/data/share/doc/packages/s3cmd/NEWS",
"external/pypi_s3cmd/data/share/doc/packages/s3cmd/README.md",
"external/pypi_s3cmd/data/share/man/man1/s3cmd.1",
],
)
def test_dist_info(self):
env = os.environ.get("WHEEL_DIST_INFO_CONTENTS")
self.assertIsNotNone(env)
self.assertListEqual(
env.split(" "),
[
"external/pypi_requests/site-packages/requests-2.25.1.dist-info/INSTALLER",
"external/pypi_requests/site-packages/requests-2.25.1.dist-info/LICENSE",
"external/pypi_requests/site-packages/requests-2.25.1.dist-info/METADATA",
"external/pypi_requests/site-packages/requests-2.25.1.dist-info/RECORD",
"external/pypi_requests/site-packages/requests-2.25.1.dist-info/WHEEL",
"external/pypi_requests/site-packages/requests-2.25.1.dist-info/top_level.txt",
],
)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/pip_parse/requirements.in 0000664 0000000 0000000 00000000057 14540404546 0023212 0 ustar 00root root 0000000 0000000 requests~=2.25.1
s3cmd~=2.1.0
yamllint~=1.26.3
rules_python-0.22.1/examples/pip_parse/requirements_lock.txt 0000664 0000000 0000000 00000013532 14540404546 0024435 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
certifi==2022.12.7 \
--hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \
--hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18
# via requests
chardet==4.0.0 \
--hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \
--hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5
# via requests
idna==2.10 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
# via requests
pathspec==0.10.3 \
--hash=sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6 \
--hash=sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6
# via yamllint
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via s3cmd
python-magic==0.4.27 \
--hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \
--hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3
# via s3cmd
pyyaml==6.0 \
--hash=sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1 \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7 \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358 \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
requests==2.25.1 \
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e
# via -r requirements.in
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
setuptools==65.6.3 \
--hash=sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54 \
--hash=sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75
# via yamllint
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
urllib3==1.26.13 \
--hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \
--hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8
# via requests
yamllint==1.26.3 \
--hash=sha256:3934dcde484374596d6b52d8db412929a169f6d9e52e20f9ade5bf3523d9b96e
# via -r requirements.in
rules_python-0.22.1/examples/pip_parse/test.py 0000664 0000000 0000000 00000001436 14540404546 0021472 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import main
class ExampleTest(unittest.TestCase):
def test_main(self):
self.assertEqual("2.25.1", main.version())
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/pip_parse_vendored/ 0000775 0000000 0000000 00000000000 14540404546 0022023 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/pip_parse_vendored/.bazelrc 0000664 0000000 0000000 00000000210 14540404546 0023437 0 ustar 00root root 0000000 0000000 test --test_output=errors
# Windows requires these for multi-python support:
build --enable_runfiles
startup --windows_enable_symlinks
rules_python-0.22.1/examples/pip_parse_vendored/.gitignore 0000664 0000000 0000000 00000000010 14540404546 0024002 0 ustar 00root root 0000000 0000000 bazel-*
rules_python-0.22.1/examples/pip_parse_vendored/BUILD.bazel 0000664 0000000 0000000 00000003665 14540404546 0023713 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
# This rule adds a convenient way to update the requirements.txt
# lockfile based on the requirements.in.
compile_pip_requirements(name = "requirements")
# The requirements.bzl file is generated with a reference to the interpreter for the host platform.
# In order to check in a platform-agnostic file, we have to replace that reference with the symbol
# loaded from our python toolchain.
genrule(
name = "make_platform_agnostic",
srcs = ["@pip//:requirements.bzl"],
outs = ["requirements.clean.bzl"],
cmd = " | ".join([
"cat $<",
# Insert our load statement after the existing one so we don't produce a file with buildifier warnings
"""sed -e '/^load.*/i\\'$$'\\n''load("@python39//:defs.bzl", "interpreter")'""",
# Replace the bazel 6.0.0 specific comment with something that bazel 5.4.0 would produce.
# This enables this example to be run as a test under bazel 5.4.0.
"""sed -e 's#@//#//#'""",
"""sed 's#"@python39_.*//:bin/python3"#interpreter#' >$@""",
]),
)
write_file(
name = "gen_update",
out = "update.sh",
content = [
# This depends on bash, would need tweaks for Windows
"#!/usr/bin/env bash",
# Bazel gives us a way to access the source folder!
"cd $BUILD_WORKSPACE_DIRECTORY",
"cp -fv bazel-bin/requirements.clean.bzl requirements.bzl",
],
)
sh_binary(
name = "vendor_requirements",
srcs = ["update.sh"],
data = [":make_platform_agnostic"],
)
# Similarly ensures that the requirements.bzl file is updated
# based on the requirements.txt lockfile.
diff_test(
name = "test_vendored",
failure_message = "Please run: bazel run //:vendor_requirements",
file1 = "requirements.bzl",
file2 = ":make_platform_agnostic",
)
rules_python-0.22.1/examples/pip_parse_vendored/README.md 0000664 0000000 0000000 00000002225 14540404546 0023303 0 ustar 00root root 0000000 0000000 # pip_parse vendored
This example is like pip_parse, however we avoid loading from the generated file.
See https://github.com/bazelbuild/rules_python/issues/608
and https://blog.aspect.dev/avoid-eager-fetches.
The requirements now form a triple:
- requirements.in - human editable, expresses only direct dependencies and load-bearing version constraints
- requirements.txt - lockfile produced by pip-compile or other means
- requirements.bzl - the "parsed" version of the lockfile readable by Bazel downloader
The `requirements.bzl` file contains baked-in attributes such as `python_interpreter_target` as they were specified in the original `pip_parse` rule. These can be overridden at install time by passing arguments to `install_deps`. For example:
```python
# Register a hermetic toolchain
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@python39//:defs.bzl", "interpreter")
# Load dependencies vendored by some other ruleset.
load("@some_rules//:py_deps.bzl", "install_deps")
install_deps(
python_interpreter_target = interpreter,
)
```
rules_python-0.22.1/examples/pip_parse_vendored/WORKSPACE 0000664 0000000 0000000 00000002062 14540404546 0023304 0 ustar 00root root 0000000 0000000 workspace(name = "pip_repository_annotations_example")
local_repository(
name = "rules_python",
path = "../..",
)
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
py_repositories()
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")
# This repository isn't referenced, except by our test that asserts the requirements.bzl is updated.
# It also wouldn't be needed by users of this ruleset.
pip_parse(
name = "pip",
python_interpreter_target = interpreter,
requirements_lock = "//:requirements.txt",
)
# This example vendors the file produced by `pip_parse` above into the repo.
# This way our Bazel doesn't eagerly fetch and install the pip_parse'd
# repository for builds that don't need it.
# See discussion of the trade-offs in the pip_parse documentation
# and the "vendor_requirements" target in the BUILD file.
load("//:requirements.bzl", "install_deps")
install_deps()
rules_python-0.22.1/examples/pip_parse_vendored/requirements.bzl 0000664 0000000 0000000 00000006027 14540404546 0025264 0 ustar 00root root 0000000 0000000 """Starlark representation of locked requirements.
@generated by rules_python pip_parse repository rule
from //:requirements.txt
"""
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python/pip_install:pip_repository.bzl", "whl_library")
all_requirements = ["@pip_certifi//:pkg", "@pip_charset_normalizer//:pkg", "@pip_idna//:pkg", "@pip_requests//:pkg", "@pip_urllib3//:pkg"]
all_whl_requirements = ["@pip_certifi//:whl", "@pip_charset_normalizer//:whl", "@pip_idna//:whl", "@pip_requests//:whl", "@pip_urllib3//:whl"]
_packages = [("pip_certifi", "certifi==2022.12.7 --hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 --hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"), ("pip_charset_normalizer", "charset-normalizer==2.1.1 --hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 --hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"), ("pip_idna", "idna==3.4 --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"), ("pip_requests", "requests==2.28.1 --hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 --hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"), ("pip_urllib3", "urllib3==1.26.13 --hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc --hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8")]
_config = {"download_only": False, "enable_implicit_namespace_pkgs": False, "environment": {}, "extra_pip_args": [], "isolated": True, "pip_data_exclude": [], "python_interpreter": "python3", "python_interpreter_target": interpreter, "quiet": True, "repo": "pip", "repo_prefix": "pip_", "timeout": 600}
_annotations = {}
def _clean_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def requirement(name):
return "@pip_" + _clean_name(name) + "//:pkg"
def whl_requirement(name):
return "@pip_" + _clean_name(name) + "//:whl"
def data_requirement(name):
return "@pip_" + _clean_name(name) + "//:data"
def dist_info_requirement(name):
return "@pip_" + _clean_name(name) + "//:dist_info"
def entry_point(pkg, script = None):
if not script:
script = pkg
return "@pip_" + _clean_name(pkg) + "//:rules_python_wheel_entry_point_" + script
def _get_annotation(requirement):
# This expects to parse `setuptools==58.2.0 --hash=sha256:2551203ae6955b9876741a26ab3e767bb3242dafe86a32a749ea0d78b6792f11`
# down to `setuptools`.
name = requirement.split(" ")[0].split("=")[0].split("[")[0]
return _annotations.get(name)
def install_deps(**whl_library_kwargs):
whl_config = dict(_config)
whl_config.update(whl_library_kwargs)
for name, requirement in _packages:
whl_library(
name = name,
requirement = requirement,
annotation = _get_annotation(requirement),
**whl_config
)
rules_python-0.22.1/examples/pip_parse_vendored/requirements.in 0000664 0000000 0000000 00000000011 14540404546 0025066 0 ustar 00root root 0000000 0000000 requests
rules_python-0.22.1/examples/pip_parse_vendored/requirements.txt 0000664 0000000 0000000 00000002230 14540404546 0025304 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
certifi==2022.12.7 \
--hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \
--hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18
# via requests
charset-normalizer==2.1.1 \
--hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 \
--hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f
# via requests
idna==3.4 \
--hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \
--hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2
# via requests
requests==2.28.1 \
--hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 \
--hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349
# via -r requirements.in
urllib3==1.26.13 \
--hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \
--hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8
# via requests
rules_python-0.22.1/examples/pip_repository_annotations/ 0000775 0000000 0000000 00000000000 14540404546 0023657 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/pip_repository_annotations/.bazelrc 0000664 0000000 0000000 00000000170 14540404546 0025300 0 ustar 00root root 0000000 0000000 # https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
rules_python-0.22.1/examples/pip_repository_annotations/.gitignore 0000664 0000000 0000000 00000000011 14540404546 0025637 0 ustar 00root root 0000000 0000000 /bazel-*
rules_python-0.22.1/examples/pip_repository_annotations/BUILD.bazel 0000664 0000000 0000000 00000002304 14540404546 0025534 0 ustar 00root root 0000000 0000000 load("@pip_installed//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
exports_files(
glob(["data/**"]),
visibility = ["//visibility:public"],
)
# This rule adds a convenient way to update the requirements file.
compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
)
py_test(
name = "pip_parse_annotations_test",
srcs = ["pip_repository_annotations_test.py"],
env = {
"REQUESTS_PKG_DIR": "pip_parsed_requests",
"WHEEL_PKG_DIR": "pip_parsed_wheel",
},
main = "pip_repository_annotations_test.py",
deps = [
"@pip_parsed_requests//:pkg",
"@pip_parsed_wheel//:pkg",
"@rules_python//python/runfiles",
],
)
py_test(
name = "pip_install_annotations_test",
srcs = ["pip_repository_annotations_test.py"],
env = {
"REQUESTS_PKG_DIR": "pip_installed_requests",
"WHEEL_PKG_DIR": "pip_installed_wheel",
},
main = "pip_repository_annotations_test.py",
deps = [
requirement("wheel"),
requirement("requests"),
"@rules_python//python/runfiles",
],
)
rules_python-0.22.1/examples/pip_repository_annotations/WORKSPACE 0000664 0000000 0000000 00000004573 14540404546 0025151 0 ustar 00root root 0000000 0000000 workspace(name = "pip_repository_annotations_example")
local_repository(
name = "rules_python",
path = "../..",
)
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
py_repositories()
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "package_annotation", "pip_install", "pip_parse")
# Here we can see an example of annotations being applied to an arbitrary
# package. For details on `package_annotation` and it's uses, see the
# docs at @rules_python//docs:pip.md`.
ANNOTATIONS = {
# This annotation verifies that annotations work correctly for pip packages with extras
# specified, in this case requests[security].
"requests": package_annotation(
additive_build_content = """\
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
name = "generated_file",
out = "generated_file.txt",
content = ["Hello world from requests"],
)
""",
data = [":generated_file"],
),
"wheel": package_annotation(
additive_build_content = """\
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
name = "generated_file",
out = "generated_file.txt",
content = ["Hello world from build content file"],
)
""",
copy_executables = {"@pip_repository_annotations_example//:data/copy_executable.py": "copied_content/executable.py"},
copy_files = {"@pip_repository_annotations_example//:data/copy_file.txt": "copied_content/file.txt"},
data = [":generated_file"],
data_exclude_glob = ["site-packages/*.dist-info/WHEEL"],
),
}
# For a more thorough example of `pip_parse`. See `@rules_python//examples/pip_parse`
pip_parse(
name = "pip_parsed",
annotations = ANNOTATIONS,
python_interpreter_target = interpreter,
requirements_lock = "//:requirements.txt",
)
load("@pip_parsed//:requirements.bzl", install_pip_parse_deps = "install_deps")
install_pip_parse_deps()
# For a more thorough example of `pip_install`. See `@rules_python//examples/pip_install`
pip_install(
name = "pip_installed",
annotations = ANNOTATIONS,
python_interpreter_target = interpreter,
requirements = "//:requirements.txt",
)
load("@pip_installed//:requirements.bzl", install_pip_install_deps = "install_deps")
install_pip_install_deps()
rules_python-0.22.1/examples/pip_repository_annotations/data/ 0000775 0000000 0000000 00000000000 14540404546 0024570 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/pip_repository_annotations/data/copy_executable.py 0000775 0000000 0000000 00000001276 14540404546 0030326 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if __name__ == "__main__":
print("Hello world from copied executable")
rules_python-0.22.1/examples/pip_repository_annotations/data/copy_file.txt 0000664 0000000 0000000 00000000035 14540404546 0027300 0 ustar 00root root 0000000 0000000 Hello world from copied file
rules_python-0.22.1/examples/pip_repository_annotations/pip_repository_annotations_test.py 0000664 0000000 0000000 00000011017 14540404546 0032774 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python3
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import platform
import subprocess
import sys
import unittest
from pathlib import Path
from rules_python.python.runfiles import runfiles
class PipRepositoryAnnotationsTest(unittest.TestCase):
maxDiff = None
def wheel_pkg_dir(self) -> str:
env = os.environ.get("WHEEL_PKG_DIR")
self.assertIsNotNone(env)
return env
def test_build_content_and_data(self):
r = runfiles.Create()
rpath = r.Rlocation(
"pip_repository_annotations_example/external/{}/generated_file.txt".format(
self.wheel_pkg_dir()
)
)
generated_file = Path(rpath)
self.assertTrue(generated_file.exists())
content = generated_file.read_text().rstrip()
self.assertEqual(content, "Hello world from build content file")
def test_copy_files(self):
r = runfiles.Create()
rpath = r.Rlocation(
"pip_repository_annotations_example/external/{}/copied_content/file.txt".format(
self.wheel_pkg_dir()
)
)
copied_file = Path(rpath)
self.assertTrue(copied_file.exists())
content = copied_file.read_text().rstrip()
self.assertEqual(content, "Hello world from copied file")
def test_copy_executables(self):
r = runfiles.Create()
rpath = r.Rlocation(
"pip_repository_annotations_example/external/{}/copied_content/executable{}".format(
self.wheel_pkg_dir(),
".exe" if platform.system() == "windows" else ".py",
)
)
executable = Path(rpath)
self.assertTrue(executable.exists())
proc = subprocess.run(
[sys.executable, str(executable)],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdout = proc.stdout.decode("utf-8").strip()
self.assertEqual(stdout, "Hello world from copied executable")
def test_data_exclude_glob(self):
current_wheel_version = "0.38.4"
r = runfiles.Create()
dist_info_dir = "pip_repository_annotations_example/external/{}/site-packages/wheel-{}.dist-info".format(
self.wheel_pkg_dir(),
current_wheel_version,
)
# Note: `METADATA` is important as it's consumed by https://docs.python.org/3/library/importlib.metadata.html
# `METADATA` is expected to be there to show dist-info files are included in the runfiles.
metadata_path = r.Rlocation("{}/METADATA".format(dist_info_dir))
# However, `WHEEL` was explicitly excluded, so it should be missing
wheel_path = r.Rlocation("{}/WHEEL".format(dist_info_dir))
# Because windows does not have `--enable_runfiles` on by default, the
# `runfiles.Rlocation` results will be different on this platform vs
# unix platforms. See `@rules_python//python/runfiles` for more details.
if platform.system() == "Windows":
self.assertIsNotNone(metadata_path)
self.assertIsNone(wheel_path)
else:
self.assertTrue(Path(metadata_path).exists())
self.assertFalse(Path(wheel_path).exists())
def requests_pkg_dir(self) -> str:
env = os.environ.get("REQUESTS_PKG_DIR")
self.assertIsNotNone(env)
return env
def test_extra(self):
# This test verifies that annotations work correctly for pip packages with extras
# specified, in this case requests[security].
r = runfiles.Create()
rpath = r.Rlocation(
"pip_repository_annotations_example/external/{}/generated_file.txt".format(
self.requests_pkg_dir()
)
)
generated_file = Path(rpath)
self.assertTrue(generated_file.exists())
content = generated_file.read_text().rstrip()
self.assertEqual(content, "Hello world from requests")
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/pip_repository_annotations/requirements.in 0000664 0000000 0000000 00000000262 14540404546 0026732 0 ustar 00root root 0000000 0000000 # This flag allows for regression testing requirements arguments in
# `pip_repository` rules.
--extra-index-url https://pypi.python.org/simple/
wheel
requests[security]>=2.8.1
rules_python-0.22.1/examples/pip_repository_annotations/requirements.txt 0000664 0000000 0000000 00000002652 14540404546 0027150 0 ustar 00root root 0000000 0000000 #
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# bazel run //:requirements.update
#
--extra-index-url https://pypi.python.org/simple/
certifi==2022.12.7 \
--hash=sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3 \
--hash=sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18
# via requests
charset-normalizer==2.1.1 \
--hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 \
--hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f
# via requests
idna==3.4 \
--hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \
--hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2
# via requests
requests[security]==2.28.1 \
--hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 \
--hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349
# via -r requirements.in
urllib3==1.26.13 \
--hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc \
--hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8
# via requests
wheel==0.38.4 \
--hash=sha256:965f5259b566725405b05e7cf774052044b1ed30119b5d586b2703aafe8719ac \
--hash=sha256:b60533f3f5d530e971d6737ca6d58681ee434818fab630c83a734bb10c083ce8
# via -r requirements.in
rules_python-0.22.1/examples/py_proto_library/ 0000775 0000000 0000000 00000000000 14540404546 0021552 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/py_proto_library/.bazelrc 0000664 0000000 0000000 00000000000 14540404546 0023163 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/py_proto_library/.gitignore 0000664 0000000 0000000 00000000055 14540404546 0023542 0 ustar 00root root 0000000 0000000 # git ignore patterns
/bazel-*
user.bazelrc
rules_python-0.22.1/examples/py_proto_library/BUILD.bazel 0000664 0000000 0000000 00000000727 14540404546 0023436 0 ustar 00root root 0000000 0000000 load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_python//python:proto.bzl", "py_proto_library")
py_proto_library(
name = "pricetag_proto_py_pb2",
deps = [":pricetag_proto"],
)
proto_library(
name = "pricetag_proto",
srcs = ["pricetag.proto"],
)
py_test(
name = "pricetag_test",
srcs = ["test.py"],
main = "test.py",
deps = [
":pricetag_proto_py_pb2",
],
)
rules_python-0.22.1/examples/py_proto_library/MODULE.bazel 0000664 0000000 0000000 00000001407 14540404546 0023560 0 ustar 00root root 0000000 0000000 module(
name = "rules_python_py_proto_library_example",
version = "0.0.0",
compatibility_level = 1,
)
bazel_dep(name = "rules_python", version = "0.17.3")
# The following local_path_override is only needed to run this example as part of our CI.
local_path_override(
module_name = "rules_python",
path = "../..",
)
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
name = "python3_9",
configure_coverage_tool = True,
python_version = "3.9",
)
use_repo(python, "python3_9_toolchains")
register_toolchains(
"@python3_9_toolchains//:all",
)
# We are using rules_proto to define rules_proto targets to be consumed by py_proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
rules_python-0.22.1/examples/py_proto_library/WORKSPACE 0000664 0000000 0000000 00000003036 14540404546 0023035 0 ustar 00root root 0000000 0000000 workspace(name = "rules_python_py_proto_library_example")
# The following local_path_override is only needed to run this example as part of our CI.
local_repository(
name = "rules_python",
path = "../..",
)
# When not using this example in the rules_python git repo you would load the python
# rules using http_archive(), as documented in the release notes.
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
# We install the rules_python dependencies using the function below.
py_repositories()
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
# Then we need to setup dependencies in order to use py_proto_library
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)
http_archive(
name = "com_google_protobuf",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
rules_python-0.22.1/examples/py_proto_library/WORKSPACE.bzlmod 0000664 0000000 0000000 00000000000 14540404546 0024307 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/py_proto_library/pricetag.proto 0000664 0000000 0000000 00000000146 14540404546 0024436 0 ustar 00root root 0000000 0000000 syntax = "proto3";
package rules_python;
message PriceTag {
string name = 2;
double cost = 1;
}
rules_python-0.22.1/examples/py_proto_library/test.py 0000664 0000000 0000000 00000000446 14540404546 0023107 0 ustar 00root root 0000000 0000000 import sys
import unittest
import pricetag_pb2
class TestCase(unittest.TestCase):
def test_pricetag(self):
got = pricetag_pb2.PriceTag(
name="dollar",
cost=5.00,
)
self.assertIsNotNone(got)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/examples/wheel/ 0000775 0000000 0000000 00000000000 14540404546 0017257 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/wheel/BUILD.bazel 0000664 0000000 0000000 00000020721 14540404546 0021137 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//examples/wheel/private:wheel_utils.bzl", "directory_writer", "make_variable_tags")
load("//python:defs.bzl", "py_library", "py_test")
load("//python:packaging.bzl", "py_package", "py_wheel")
load("//python:versions.bzl", "gen_python_config_settings")
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
py_library(
name = "main",
srcs = ["main.py"],
deps = [
"//examples/wheel/lib:simple_module",
"//examples/wheel/lib:module_with_data",
# Example dependency which is not packaged in the wheel
# due to "packages" filter on py_package rule.
"//tests/load_from_macro:foo",
],
)
py_library(
name = "main_with_gen_data",
srcs = ["main.py"],
data = [
":gen_dir",
],
)
directory_writer(
name = "gen_dir",
out = "someDir",
files = {"foo.py": ""},
)
# Package just a specific py_libraries, without their dependencies
py_wheel(
name = "minimal_with_py_library",
testonly = True, # Set this to verify the generated .dist target doesn't break things
# Package data. We're building "example_minimal_library-0.0.1-py3-none-any.whl"
distribution = "example_minimal_library",
python_tag = "py3",
version = "0.0.1",
deps = [
"//examples/wheel/lib:module_with_data",
"//examples/wheel/lib:simple_module",
],
)
# Populate a rule with "Make Variable" arguments for
# abi, python_tag and version. You might want to do this
# for the following use cases:
# - abi, python_tag: introspect a toolchain to map to appropriate cpython tags
# - version: populate given this or a dependent module's version
make_variable_tags(
name = "make_variable_tags",
)
py_wheel(
name = "minimal_with_py_library_with_make_variables",
testonly = True,
abi = "$(ABI)",
distribution = "example_minimal_library",
python_tag = "$(PYTHON_TAG)",
toolchains = ["//examples/wheel:make_variable_tags"],
version = "$(VERSION)",
deps = [
"//examples/wheel/lib:module_with_data",
"//examples/wheel/lib:simple_module",
],
)
build_test(
name = "dist_build_tests",
targets = [":minimal_with_py_library.dist"],
)
# Package just a specific py_libraries, without their dependencies
py_wheel(
name = "minimal_with_py_library_with_stamp",
# Package data. We're building "example_minimal_library-0.0.1-py3-none-any.whl"
distribution = "example_minimal_library",
python_tag = "py3",
stamp = 1,
version = "0.1.{BUILD_TIMESTAMP}",
deps = [
"//examples/wheel/lib:module_with_data",
"//examples/wheel/lib:simple_module",
],
)
# Use py_package to collect all transitive dependencies of a target,
# selecting just the files within a specific python package.
py_package(
name = "example_pkg",
# Only include these Python packages.
packages = ["examples.wheel"],
deps = [":main"],
)
py_package(
name = "example_pkg_with_data",
packages = ["examples.wheel"],
deps = [":main_with_gen_data"],
)
py_wheel(
name = "minimal_with_py_package",
# Package data. We're building "example_minimal_package-0.0.1-py3-none-any.whl"
distribution = "example_minimal_package",
python_tag = "py3",
version = "0.0.1",
deps = [":example_pkg"],
)
# An example that uses all features provided by py_wheel.
py_wheel(
name = "customized",
author = "Example Author with non-ascii characters: ΕΌΓ³Εw",
author_email = "example@example.com",
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
],
console_scripts = {
"customized_wheel": "examples.wheel.main:main",
},
description_file = "README.md",
# Package data. We're building "example_customized-0.0.1-py3-none-any.whl"
distribution = "example_customized",
entry_points = {
"console_scripts": ["another = foo.bar:baz"],
"group2": [
"second = second.main:s",
"first = first.main:f",
],
},
extra_distinfo_files = {
"//examples/wheel:NOTICE": "NOTICE",
# Rename the file when packaging to show we can.
"//examples/wheel:README.md": "README",
},
homepage = "www.example.com",
license = "Apache 2.0",
python_tag = "py3",
# Requirements embedded into the wheel metadata.
requires = ["pytest"],
version = "0.0.1",
deps = [":example_pkg"],
)
# An example of how to change the wheel package root directory using 'strip_path_prefixes'.
py_wheel(
name = "custom_package_root",
# Package data. We're building "examples_custom_package_root-0.0.1-py3-none-any.whl"
distribution = "examples_custom_package_root",
entry_points = {
"console_scripts": ["main = foo.bar:baz"],
},
python_tag = "py3",
strip_path_prefixes = [
"examples",
],
version = "0.0.1",
deps = [
":example_pkg",
],
)
py_wheel(
name = "custom_package_root_multi_prefix",
# Package data. We're building "custom_custom_package_root_multi_prefix-0.0.1-py3-none-any.whl"
distribution = "example_custom_package_root_multi_prefix",
python_tag = "py3",
strip_path_prefixes = [
"examples/wheel/lib",
"examples/wheel",
],
version = "0.0.1",
deps = [
":example_pkg",
],
)
py_wheel(
name = "custom_package_root_multi_prefix_reverse_order",
# Package data. We're building "custom_custom_package_root_multi_prefix_reverse_order-0.0.1-py3-none-any.whl"
distribution = "example_custom_package_root_multi_prefix_reverse_order",
python_tag = "py3",
strip_path_prefixes = [
"examples/wheel",
"examples/wheel/lib", # this is not effective, because the first prefix takes priority
],
version = "0.0.1",
deps = [
":example_pkg",
],
)
py_wheel(
name = "python_requires_in_a_package",
distribution = "example_python_requires_in_a_package",
python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
python_tag = "py3",
version = "0.0.1",
deps = [
":example_pkg",
],
)
py_wheel(
name = "use_rule_with_dir_in_outs",
distribution = "use_rule_with_dir_in_outs",
python_tag = "py3",
version = "0.0.1",
deps = [
":example_pkg_with_data",
],
)
gen_python_config_settings()
py_wheel(
name = "python_abi3_binary_wheel",
abi = "abi3",
distribution = "example_python_abi3_binary_wheel",
# these platform strings must line up with test_python_abi3_binary_wheel() in wheel_test.py
platform = select({
":aarch64-apple-darwin": "macosx_11_0_arm64",
":aarch64-unknown-linux-gnu": "manylinux2014_aarch64",
":x86_64-apple-darwin": "macosx_11_0_x86_64", # this is typically macosx_10_9_x86_64?
":x86_64-pc-windows-msvc": "win_amd64",
":x86_64-unknown-linux-gnu": "manylinux2014_x86_64",
}),
python_requires = ">=3.8",
python_tag = "cp38",
version = "0.0.1",
)
py_wheel(
name = "filename_escaping",
# Per https://www.python.org/dev/peps/pep-0427/#escaping-and-unicode
# runs of non-alphanumeric, non-digit symbols should be replaced with a single underscore.
# Unicode non-ascii letters should *not* be replaced with underscore.
distribution = "file~~name-escaping",
python_tag = "py3",
version = "0.0.1-r7",
deps = [":example_pkg"],
)
py_test(
name = "wheel_test",
srcs = ["wheel_test.py"],
data = [
":custom_package_root",
":custom_package_root_multi_prefix",
":custom_package_root_multi_prefix_reverse_order",
":customized",
":filename_escaping",
":minimal_with_py_library",
":minimal_with_py_library_with_stamp",
":minimal_with_py_package",
":python_abi3_binary_wheel",
":python_requires_in_a_package",
":use_rule_with_dir_in_outs",
],
)
rules_python-0.22.1/examples/wheel/NOTICE 0000664 0000000 0000000 00000000114 14540404546 0020157 0 ustar 00root root 0000000 0000000 This is a test "NOTICE" file to be packaged into distribtion dist-info dir.
rules_python-0.22.1/examples/wheel/README.md 0000664 0000000 0000000 00000000050 14540404546 0020531 0 ustar 00root root 0000000 0000000 This is a sample description of a wheel. rules_python-0.22.1/examples/wheel/lib/ 0000775 0000000 0000000 00000000000 14540404546 0020025 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/wheel/lib/BUILD.bazel 0000664 0000000 0000000 00000001766 14540404546 0021715 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("//python:defs.bzl", "py_library")
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
py_library(
name = "simple_module",
srcs = ["simple_module.py"],
)
py_library(
name = "module_with_data",
srcs = ["module_with_data.py"],
data = [":data.txt"],
)
genrule(
name = "make_data",
outs = ["data.txt"],
cmd = "echo foo bar baz > $@",
)
rules_python-0.22.1/examples/wheel/lib/module_with_data.py 0000664 0000000 0000000 00000001175 14540404546 0023714 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def function():
return "foo"
rules_python-0.22.1/examples/wheel/lib/simple_module.py 0000664 0000000 0000000 00000001175 14540404546 0023241 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def function():
return "bar"
rules_python-0.22.1/examples/wheel/main.py 0000664 0000000 0000000 00000001615 14540404546 0020560 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import examples.wheel.lib.module_with_data as module_with_data
import examples.wheel.lib.simple_module as simple_module
def function():
return "baz"
def main():
print(function())
print(module_with_data.function())
print(simple_module.function())
if __name__ == "__main__":
main()
rules_python-0.22.1/examples/wheel/private/ 0000775 0000000 0000000 00000000000 14540404546 0020731 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/examples/wheel/private/BUILD.bazel 0000664 0000000 0000000 00000000256 14540404546 0022612 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "directory_writer",
srcs = ["directory_writer.py"],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/examples/wheel/private/directory_writer.py 0000664 0000000 0000000 00000003227 14540404546 0024707 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python3
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The action executable of the `@rules_python//examples/wheel/private:wheel_utils.bzl%directory_writer` rule."""
import argparse
import json
from pathlib import Path
from typing import Tuple
def _file_input(value) -> Tuple[Path, str]:
path, content = value.split("=", maxsplit=1)
return (Path(path), json.loads(content))
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument(
"--output", type=Path, required=True, help="The output directory to create."
)
parser.add_argument(
"--file",
dest="files",
type=_file_input,
action="append",
help="Files to create within the `output` directory.",
)
return parser.parse_args()
def main() -> None:
args = parse_args()
args.output.mkdir(parents=True, exist_ok=True)
for (path, content) in args.files:
new_file = args.output / path
new_file.parent.mkdir(parents=True, exist_ok=True)
new_file.write_text(content)
if __name__ == "__main__":
main()
rules_python-0.22.1/examples/wheel/private/wheel_utils.bzl 0000664 0000000 0000000 00000004623 14540404546 0023773 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Helper rules for demonstrating `py_wheel` examples"""
def _directory_writer_impl(ctx):
output = ctx.actions.declare_directory(ctx.attr.out)
args = ctx.actions.args()
args.add("--output", output.path)
for path, content in ctx.attr.files.items():
args.add("--file={}={}".format(
path,
json.encode(content),
))
ctx.actions.run(
outputs = [output],
arguments = [args],
executable = ctx.executable._writer,
)
return [DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles(files = [output]),
)]
directory_writer = rule(
implementation = _directory_writer_impl,
doc = "A rule for generating a directory with the requested content.",
attrs = {
"files": attr.string_dict(
doc = "A mapping of file name to content to create relative to the generated `out` directory.",
),
"out": attr.string(
doc = "The name of the directory to create",
),
"_writer": attr.label(
executable = True,
cfg = "exec",
default = Label("//examples/wheel/private:directory_writer"),
),
},
)
def _make_variable_tags_impl(ctx): # buildifier: disable=unused-variable
# This example is contrived. In a real usage, this rule would
# look at flags or dependencies to determine what values to use.
# If all you're doing is setting constant values, then you can simply
# set them in the py_wheel() call.
vars = {}
vars["ABI"] = "cp38"
vars["PYTHON_TAG"] = "cp38"
vars["VERSION"] = "0.99.0"
return [platform_common.TemplateVariableInfo(vars)]
make_variable_tags = rule(
attrs = {},
doc = """Make variable tags to pass to a py_wheel rule.""",
implementation = _make_variable_tags_impl,
)
rules_python-0.22.1/examples/wheel/wheel_test.py 0000664 0000000 0000000 00000034661 14540404546 0022006 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import platform
import subprocess
import unittest
import zipfile
class WheelTest(unittest.TestCase):
maxDiff = None
def test_py_library_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"example_minimal_library-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"examples/wheel/lib/module_with_data.py",
"examples/wheel/lib/simple_module.py",
"example_minimal_library-0.0.1.dist-info/WHEEL",
"example_minimal_library-0.0.1.dist-info/METADATA",
"example_minimal_library-0.0.1.dist-info/RECORD",
],
)
def test_py_package_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"example_minimal_package-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"examples/wheel/lib/data.txt",
"examples/wheel/lib/module_with_data.py",
"examples/wheel/lib/simple_module.py",
"examples/wheel/main.py",
"example_minimal_package-0.0.1.dist-info/WHEEL",
"example_minimal_package-0.0.1.dist-info/METADATA",
"example_minimal_package-0.0.1.dist-info/RECORD",
],
)
def test_customized_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"example_customized-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"examples/wheel/lib/data.txt",
"examples/wheel/lib/module_with_data.py",
"examples/wheel/lib/simple_module.py",
"examples/wheel/main.py",
"example_customized-0.0.1.dist-info/WHEEL",
"example_customized-0.0.1.dist-info/METADATA",
"example_customized-0.0.1.dist-info/entry_points.txt",
"example_customized-0.0.1.dist-info/NOTICE",
"example_customized-0.0.1.dist-info/README",
"example_customized-0.0.1.dist-info/RECORD",
],
)
record_contents = zf.read("example_customized-0.0.1.dist-info/RECORD")
wheel_contents = zf.read("example_customized-0.0.1.dist-info/WHEEL")
metadata_contents = zf.read("example_customized-0.0.1.dist-info/METADATA")
entry_point_contents = zf.read(
"example_customized-0.0.1.dist-info/entry_points.txt"
)
self.assertEqual(
record_contents,
# The entries are guaranteed to be sorted.
b"""\
example_customized-0.0.1.dist-info/METADATA,sha256=YUnzQ9gTMXspIBURe90Ct3aL_CCn8fwC3SiZe6MMTs8,372
example_customized-0.0.1.dist-info/NOTICE,sha256=Xpdw-FXET1IRgZ_wTkx1YQfo1-alET0FVf6V1LXO4js,76
example_customized-0.0.1.dist-info/README,sha256=WmOFwZ3Jga1bHG3JiGRsUheb4UbLffUxyTdHczS27-o,40
example_customized-0.0.1.dist-info/RECORD,,
example_customized-0.0.1.dist-info/WHEEL,sha256=sobxWSyDDkdg_rinUth-jxhXHqoNqlmNMJY3aTZn2Us,91
example_customized-0.0.1.dist-info/entry_points.txt,sha256=pqzpbQ8MMorrJ3Jp0ntmpZcuvfByyqzMXXi2UujuXD0,137
examples/wheel/lib/data.txt,sha256=9vJKEdfLu8bZRArKLroPZJh1XKkK3qFMXiM79MBL2Sg,12
examples/wheel/lib/module_with_data.py,sha256=8s0Khhcqz3yVsBKv2IB5u4l4TMKh7-c_V6p65WVHPms,637
examples/wheel/lib/simple_module.py,sha256=z2hwciab_XPNIBNH8B1Q5fYgnJvQTeYf0ZQJpY8yLLY,637
examples/wheel/main.py,sha256=sgg5iWN_9inYBjm6_Zw27hYdmo-l24fA-2rfphT-IlY,909
""",
)
self.assertEqual(
wheel_contents,
b"""\
Wheel-Version: 1.0
Generator: bazel-wheelmaker 1.0
Root-Is-Purelib: true
Tag: py3-none-any
""",
)
self.assertEqual(
metadata_contents,
b"""\
Metadata-Version: 2.1
Name: example_customized
Author: Example Author with non-ascii characters: \xc5\xbc\xc3\xb3\xc5\x82w
Author-email: example@example.com
Home-page: www.example.com
License: Apache 2.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: Developers
Requires-Dist: pytest
Version: 0.0.1
This is a sample description of a wheel.
""",
)
self.assertEqual(
entry_point_contents,
b"""\
[console_scripts]
another = foo.bar:baz
customized_wheel = examples.wheel.main:main
[group2]
first = first.main:f
second = second.main:s""",
)
def test_filename_escaping(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"file_name_escaping-0.0.1_r7-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"examples/wheel/lib/data.txt",
"examples/wheel/lib/module_with_data.py",
"examples/wheel/lib/simple_module.py",
"examples/wheel/main.py",
# PEP calls for replacing only in the archive filename.
# Alas setuptools also escapes in the dist-info directory
# name, so let's be compatible.
"file_name_escaping-0.0.1_r7.dist-info/WHEEL",
"file_name_escaping-0.0.1_r7.dist-info/METADATA",
"file_name_escaping-0.0.1_r7.dist-info/RECORD",
],
)
metadata_contents = zf.read(
"file_name_escaping-0.0.1_r7.dist-info/METADATA"
)
self.assertEqual(
metadata_contents,
b"""\
Metadata-Version: 2.1
Name: file~~name-escaping
Version: 0.0.1-r7
UNKNOWN
""",
)
def test_custom_package_root_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"examples_custom_package_root-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"wheel/lib/data.txt",
"wheel/lib/module_with_data.py",
"wheel/lib/simple_module.py",
"wheel/main.py",
"examples_custom_package_root-0.0.1.dist-info/WHEEL",
"examples_custom_package_root-0.0.1.dist-info/METADATA",
"examples_custom_package_root-0.0.1.dist-info/entry_points.txt",
"examples_custom_package_root-0.0.1.dist-info/RECORD",
],
)
record_contents = zf.read(
"examples_custom_package_root-0.0.1.dist-info/RECORD"
).decode("utf-8")
# Ensure RECORD files do not have leading forward slashes
for line in record_contents.splitlines():
self.assertFalse(line.startswith("/"))
def test_custom_package_root_multi_prefix_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"example_custom_package_root_multi_prefix-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"data.txt",
"module_with_data.py",
"simple_module.py",
"main.py",
"example_custom_package_root_multi_prefix-0.0.1.dist-info/WHEEL",
"example_custom_package_root_multi_prefix-0.0.1.dist-info/METADATA",
"example_custom_package_root_multi_prefix-0.0.1.dist-info/RECORD",
],
)
record_contents = zf.read(
"example_custom_package_root_multi_prefix-0.0.1.dist-info/RECORD"
).decode("utf-8")
# Ensure RECORD files do not have leading forward slashes
for line in record_contents.splitlines():
self.assertFalse(line.startswith("/"))
def test_custom_package_root_multi_prefix_reverse_order_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"example_custom_package_root_multi_prefix_reverse_order-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"lib/data.txt",
"lib/module_with_data.py",
"lib/simple_module.py",
"main.py",
"example_custom_package_root_multi_prefix_reverse_order-0.0.1.dist-info/WHEEL",
"example_custom_package_root_multi_prefix_reverse_order-0.0.1.dist-info/METADATA",
"example_custom_package_root_multi_prefix_reverse_order-0.0.1.dist-info/RECORD",
],
)
record_contents = zf.read(
"example_custom_package_root_multi_prefix_reverse_order-0.0.1.dist-info/RECORD"
).decode("utf-8")
# Ensure RECORD files do not have leading forward slashes
for line in record_contents.splitlines():
self.assertFalse(line.startswith("/"))
def test_python_requires_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"example_python_requires_in_a_package-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
metadata_contents = zf.read(
"example_python_requires_in_a_package-0.0.1.dist-info/METADATA"
)
# The entries are guaranteed to be sorted.
self.assertEqual(
metadata_contents,
b"""\
Metadata-Version: 2.1
Name: example_python_requires_in_a_package
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
Version: 0.0.1
UNKNOWN
""",
)
def test_python_abi3_binary_wheel(self):
arch = "amd64"
if platform.system() != "Windows":
arch = subprocess.check_output(["uname", "-m"]).strip().decode()
# These strings match the strings from py_wheel() in BUILD
os_strings = {
"Linux": "manylinux2014",
"Darwin": "macosx_11_0",
"Windows": "win",
}
os_string = os_strings[platform.system()]
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
f"example_python_abi3_binary_wheel-0.0.1-cp38-abi3-{os_string}_{arch}.whl",
)
with zipfile.ZipFile(filename) as zf:
metadata_contents = zf.read(
"example_python_abi3_binary_wheel-0.0.1.dist-info/METADATA"
)
# The entries are guaranteed to be sorted.
self.assertEqual(
metadata_contents,
b"""\
Metadata-Version: 2.1
Name: example_python_abi3_binary_wheel
Requires-Python: >=3.8
Version: 0.0.1
UNKNOWN
""",
)
wheel_contents = zf.read(
"example_python_abi3_binary_wheel-0.0.1.dist-info/WHEEL"
)
self.assertEqual(
wheel_contents.decode(),
f"""\
Wheel-Version: 1.0
Generator: bazel-wheelmaker 1.0
Root-Is-Purelib: false
Tag: cp38-abi3-{os_string}_{arch}
""",
)
def test_rule_creates_directory_and_is_included_in_wheel(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"use_rule_with_dir_in_outs-0.0.1-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
self.assertEqual(
zf.namelist(),
[
"examples/wheel/main.py",
"examples/wheel/someDir/foo.py",
"use_rule_with_dir_in_outs-0.0.1.dist-info/WHEEL",
"use_rule_with_dir_in_outs-0.0.1.dist-info/METADATA",
"use_rule_with_dir_in_outs-0.0.1.dist-info/RECORD",
],
)
def test_rule_sets_stamped_version_in_wheel_metadata(self):
filename = os.path.join(
os.environ["TEST_SRCDIR"],
"rules_python",
"examples",
"wheel",
"example_minimal_library-0.1._BUILD_TIMESTAMP_-py3-none-any.whl",
)
with zipfile.ZipFile(filename) as zf:
metadata_file = None
for f in zf.namelist():
self.assertNotIn("_BUILD_TIMESTAMP_", f)
if os.path.basename(f) == "METADATA":
metadata_file = f
self.assertIsNotNone(metadata_file)
version = None
with zf.open(metadata_file) as fp:
for line in fp:
if line.startswith(b'Version:'):
version = line.decode().split()[-1]
self.assertIsNotNone(version)
self.assertNotIn("{BUILD_TIMESTAMP}", version)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/gazelle/ 0000775 0000000 0000000 00000000000 14540404546 0015760 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/.bazelrc 0000664 0000000 0000000 00000001123 14540404546 0017400 0 ustar 00root root 0000000 0000000 test --test_output=errors
# Do NOT implicitly create empty __init__.py files in the runfiles tree.
# By default, these are created in every directory containing Python source code
# or shared libraries, and every parent directory of those directories,
# excluding the repo root directory. With this flag set, we are responsible for
# creating (possibly empty) __init__.py files and adding them to the srcs of
# Python targets as required.
build --incompatible_default_to_explicit_init_py
# Windows makes use of runfiles for some rules
build --enable_runfiles
startup --windows_enable_symlinks
rules_python-0.22.1/gazelle/.gitignore 0000664 0000000 0000000 00000000256 14540404546 0017753 0 ustar 00root root 0000000 0000000 # Bazel directories
/bazel-*
/bazel-bin
/bazel-genfiles
/bazel-out
/bazel-testlogs
user.bazelrc
# Go/Gazelle files
# These otherwise match patterns above
!go.mod
!BUILD.out
rules_python-0.22.1/gazelle/BUILD.bazel 0000664 0000000 0000000 00000001533 14540404546 0017640 0 ustar 00root root 0000000 0000000 load("@bazel_gazelle//:def.bzl", "gazelle")
# Gazelle configuration options.
# See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
# gazelle:prefix github.com/bazelbuild/rules_python/gazelle
# gazelle:exclude bazel-out
gazelle(name = "gazelle")
gazelle(
name = "gazelle_update_repos",
args = [
"-from_file=go.mod",
"-to_macro=deps.bzl%gazelle_deps",
"-prune",
],
command = "update-repos",
)
filegroup(
name = "distribution",
srcs = [
":BUILD.bazel",
":README.md",
":WORKSPACE",
":def.bzl",
":deps.bzl",
":go.mod",
":go.sum",
"//manifest:distribution",
"//modules_mapping:distribution",
"//python:distribution",
"//pythonconfig:distribution",
],
visibility = ["@rules_python//:__pkg__"],
)
rules_python-0.22.1/gazelle/MODULE.bazel 0000664 0000000 0000000 00000001151 14540404546 0017762 0 ustar 00root root 0000000 0000000 module(
name = "rules_python_gazelle_plugin",
version = "0.0.0",
compatibility_level = 1,
)
bazel_dep(name = "rules_python", version = "0.18.0")
bazel_dep(name = "rules_go", version = "0.38.1", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.29.0", repo_name = "bazel_gazelle")
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_bazelbuild_buildtools",
"com_github_bmatcuk_doublestar",
"com_github_emirpasic_gods",
"com_github_ghodss_yaml",
"in_gopkg_yaml_v2",
)
rules_python-0.22.1/gazelle/README.md 0000664 0000000 0000000 00000030164 14540404546 0017243 0 ustar 00root root 0000000 0000000 # Python Gazelle plugin
[Gazelle](https://github.com/bazelbuild/bazel-gazelle)
is a build file generator for Bazel projects. It can create new BUILD.bazel files for a project that follows language conventions, and it can update existing build files to include new sources, dependencies, and options.
Gazelle may be run by Bazel using the gazelle rule, or it may be installed and run as a command line tool.
This directory contains a plugin for
[Gazelle](https://github.com/bazelbuild/bazel-gazelle)
that generates BUILD files content for Python code.
The following instructions are for when you use [bzlmod](https://docs.bazel.build/versions/5.0.0/bzlmod.html).
Please refer to older documentation that includes instructions on how to use Gazelle
without using bzlmod as your dependency manager.
## Example
We have an example of using Gazelle with Python located [here](https://github.com/bazelbuild/rules_python/tree/main/examples/bzlmod).
A fully-working example without using bzlmod is in [`examples/build_file_generation`](../examples/build_file_generation).
The following documentation covers using bzlmod.
## Adding Gazelle to your project
First, you'll need to add Gazelle to your `MODULES.bazel` file.
Get the current version of Gazelle from there releases here: https://github.com/bazelbuild/bazel-gazelle/releases/.
See the installation `MODULE.bazel` snippet on the Releases page:
https://github.com/bazelbuild/rules_python/releases in order to configure rules_python.
You will also need to add the `bazel_dep` for configuration for `rules_python_gazelle_plugin`.
Here is a snippet of a `MODULE.bazel` file.
```starlark
# The following stanza defines the dependency rules_python.
bazel_dep(name = "rules_python", version = "0.20.0")
# The following stanza defines the dependency rules_python.
# For typical setups you set the version.
bazel_dep(name = "rules_python_gazelle_plugin", version = "0.20.0")
# The following stanza defines the dependency rules_python.
bazel_dep(name = "gazelle", version = "0.30.0", repo_name = "bazel_gazelle")
# Import the python repositories generated by the given module extension into the scope of the current module.
use_repo(python, "python3_9")
use_repo(python, "python3_9_toolchains")
# Register an already-defined toolchain so that Bazel can use it during toolchain resolution.
register_toolchains(
"@python3_9_toolchains//:all",
)
# Use the pip extension
pip = use_extension("@rules_python//python:extensions.bzl", "pip")
# Use the extension to call the `pip_repository` rule that invokes `pip`, with `incremental` set.
# Accepts a locked/compiled requirements file and installs the dependencies listed within.
# Those dependencies become available in a generated `requirements.bzl` file.
# You can instead check this `requirements.bzl` file into your repo.
# Because this project has different requirements for windows vs other
# operating systems, we have requirements for each.
pip.parse(
name = "pip",
# When using gazelle you must use set the following flag
# in order for the generation of gazelle dependency resolution.
incompatible_generate_aliases = True,
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
)
# Imports the pip toolchain generated by the given module extension into the scope of the current module.
use_repo(pip, "pip")
```
Next, we'll fetch metadata about your Python dependencies, so that gazelle can
determine which package a given import statement comes from. This is provided
by the `modules_mapping` rule. We'll make a target for consuming this
`modules_mapping`, and writing it as a manifest file for Gazelle to read.
This is checked into the repo for speed, as it takes some time to calculate
in a large monorepo.
Gazelle will walk up the filesystem from a Python file to find this metadata,
looking for a file called `gazelle_python.yaml` in an ancestor folder of the Python code.
Create an empty file with this name. It might be next to your `requirements.txt` file.
(You can just use `touch` at this point, it just needs to exist.)
To keep the metadata updated, put this in your `BUILD.bazel` file next to `gazelle_python.yaml`:
```starlark
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
# This rule fetches the metadata for python packages we depend on. That data is
# required for the gazelle_python_manifest rule to update our manifest file.
modules_mapping(
name = "modules_map",
wheels = all_whl_requirements,
)
# Gazelle python extension needs a manifest file mapping from
# an import to the installed package that provides it.
# This macro produces two targets:
# - //:gazelle_python_manifest.update can be used with `bazel run`
# to recalculate the manifest
# - //:gazelle_python_manifest.test is a test target ensuring that
# the manifest doesn't need to be updated
gazelle_python_manifest(
name = "gazelle_python_manifest",
modules_mapping = ":modules_map",
# This is what we called our `pip_install` rule, where third-party
# python libraries are loaded in BUILD files.
pip_repository_name = "pip",
# This should point to wherever we declare our python dependencies
# (the same as what we passed to the modules_mapping rule in WORKSPACE)
requirements = "//:requirements_lock.txt",
# NOTE: we can use this flag in order to make our setup compatible with
# bzlmod.
use_pip_repository_aliases = True,
)
```
Finally, you create a target that you'll invoke to run the Gazelle tool
with the rules_python extension included. This typically goes in your root
`/BUILD.bazel` file:
```starlark
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS")
# Our gazelle target points to the python gazelle binary.
# This is the simple case where we only need one language supported.
# If you also had proto, go, or other gazelle-supported languages,
# you would also need a gazelle_binary rule.
# See https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.rst#example
gazelle(
name = "gazelle",
data = GAZELLE_PYTHON_RUNTIME_DEPS,
gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)
```
That's it, now you can finally run `bazel run //:gazelle` anytime
you edit Python code, and it should update your `BUILD` files correctly.
## Usage
Gazelle is non-destructive.
It will try to leave your edits to BUILD files alone, only making updates to `py_*` targets.
However it will remove dependencies that appear to be unused, so it's a
good idea to check in your work before running Gazelle so you can easily
revert any changes it made.
The rules_python extension assumes some conventions about your Python code.
These are noted below, and might require changes to your existing code.
Note that the `gazelle` program has multiple commands. At present, only the `update` command (the default) does anything for Python code.
### Directives
You can configure the extension using directives, just like for other
languages. These are just comments in the `BUILD.bazel` file which
govern behavior of the extension when processing files under that
folder.
See https://github.com/bazelbuild/bazel-gazelle#directives
for some general directives that may be useful.
In particular, the `resolve` directive is language-specific
and can be used with Python.
Examples of these directives in use can be found in the
/gazelle/testdata folder in the rules_python repo.
Python-specific directives are as follows:
| **Directive** | **Default value** |
|--------------------------------------|-------------------|
| `# gazelle:python_extension` | `enabled` |
| Controls whether the Python extension is enabled or not. Sub-packages inherit this value. Can be either "enabled" or "disabled". | |
| `# gazelle:python_root` | n/a |
| Sets a Bazel package as a Python root. This is used on monorepos with multiple Python projects that don't share the top-level of the workspace as the root. | |
| `# gazelle:python_manifest_file_name`| `gazelle_python.yaml` |
| Overrides the default manifest file name. | |
| `# gazelle:python_ignore_files` | n/a |
| Controls the files which are ignored from the generated targets. | |
| `# gazelle:python_ignore_dependencies`| n/a |
| Controls the ignored dependencies from the generated targets. | |
| `# gazelle:python_validate_import_statements`| `true` |
| Controls whether the Python import statements should be validated. Can be "true" or "false" | |
| `# gazelle:python_generation_mode`| `package` |
| Controls the target generation mode. Can be "package" or "project" | |
| `# gazelle:python_library_naming_convention`| `$package_name$` |
| Controls the `py_library` naming convention. It interpolates $package_name$ with the Bazel package name. E.g. if the Bazel package name is `foo`, setting this to `$package_name$_my_lib` would result in a generated target named `foo_my_lib`. | |
| `# gazelle:python_binary_naming_convention` | `$package_name$_bin` |
| Controls the `py_binary` naming convention. Follows the same interpolation rules as `python_library_naming_convention`. | |
| `# gazelle:python_test_naming_convention` | `$package_name$_test` |
| Controls the `py_test` naming convention. Follows the same interpolation rules as `python_library_naming_convention`. | |
| `# gazelle:resolve py ...` | n/a |
| Instructs the plugin what target to add as a dependency to satisfy a given import statement. The syntax is `# gazelle:resolve py import-string label` where `import-string` is the symbol in the python `import` statement, and `label` is the Bazel label that Gazelle should write in `deps`. | |
### Libraries
Python source files are those ending in `.py` but not ending in `_test.py`.
First, we look for the nearest ancestor BUILD file starting from the folder
containing the Python source file.
If there is no `py_library` in this BUILD file, one is created, using the
package name as the target's name. This makes it the default target in the
package.
Next, all source files are collected into the `srcs` of the `py_library`.
Finally, the `import` statements in the source files are parsed, and
dependencies are added to the `deps` attribute.
### Unit Tests
A `py_test` target is added to the BUILD file when gazelle encounters
a file named `__test__.py`.
Often, Python unit test files are named with the suffix `_test`.
For example, if we had a folder that is a package named "foo" we could have a Python file named `foo_test.py`
and gazelle would create a `py_test` block for the file.
The following is an example of a `py_test` target that gazelle would add when
it encounters a file named `__test__.py`.
```starlark
py_test(
name = "build_file_generation_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":build_file_generation"],
)
```
You can control the naming convention for test targets by adding a gazelle directive named
`# gazelle:python_test_naming_convention`. See the instructions in the section above that
covers directives.
### Binaries
When a `__main__.py` file is encountered, this indicates the entry point
of a Python program.
A `py_binary` target will be created, named `[package]_bin`.
## Developer Notes
Gazelle extensions are written in Go. This gazelle plugin is a hybrid, as it uses Go to execute a
Python interpreter as a subprocess to parse Python source files.
See the gazelle documentation https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.md
for more information on extending Gazelle.
If you add new Go dependencies to the plugin source code, you need to "tidy" the go.mod file.
After changing that file, run `go mod tidy` or `bazel run @go_sdk//:bin/go -- mod tidy`
to update the go.mod and go.sum files. Then run `bazel run //:update_go_deps` to have gazelle
add the new dependenies to the deps.bzl file. The deps.bzl file is used as defined in our /WORKSPACE
to include the external repos Bazel loads Go dependencies from.
Then after editing Go code, run `bazel run //:gazelle` to generate/update the rules in the
BUILD.bazel files in our repo.
rules_python-0.22.1/gazelle/WORKSPACE 0000664 0000000 0000000 00000002663 14540404546 0017250 0 ustar 00root root 0000000 0000000 workspace(name = "rules_python_gazelle_plugin")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
],
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.19.4")
gazelle_dependencies()
local_repository(
name = "rules_python",
path = "..",
)
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
# gazelle:repository_macro deps.bzl%gazelle_deps
_py_gazelle_deps()
rules_python-0.22.1/gazelle/def.bzl 0000664 0000000 0000000 00000001500 14540404546 0017223 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module contains the Gazelle runtime dependencies for the Python extension.
"""
GAZELLE_PYTHON_RUNTIME_DEPS = [
"@rules_python_gazelle_plugin//python:parse",
"@rules_python_gazelle_plugin//python:std_modules",
]
rules_python-0.22.1/gazelle/deps.bzl 0000664 0000000 0000000 00000022503 14540404546 0017426 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"This file managed by `bazel run //:gazelle_update_repos`"
load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository")
def go_repository(name, **kwargs):
if name not in native.existing_rules():
_go_repository(name = name, **kwargs)
def gazelle_deps():
"Fetch go dependencies"
go_repository(
name = "co_honnef_go_tools",
importpath = "honnef.co/go/tools",
sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=",
version = "v0.0.0-20190523083050-ea95bdfd59fc",
)
go_repository(
name = "com_github_bazelbuild_buildtools",
build_naming_convention = "go_default_library",
importpath = "github.com/bazelbuild/buildtools",
sum = "h1:jhiMzJ+8unnLRtV8rpbWBFE9pFNzIqgUTyZU5aA++w8=",
version = "v0.0.0-20221004120235-7186f635531b",
)
go_repository(
name = "com_github_bmatcuk_doublestar",
importpath = "github.com/bmatcuk/doublestar",
sum = "h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=",
version = "v1.3.4",
)
go_repository(
name = "com_github_burntsushi_toml",
importpath = "github.com/BurntSushi/toml",
sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=",
version = "v0.3.1",
)
go_repository(
name = "com_github_census_instrumentation_opencensus_proto",
importpath = "github.com/census-instrumentation/opencensus-proto",
sum = "h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=",
version = "v0.2.1",
)
go_repository(
name = "com_github_chzyer_logex",
importpath = "github.com/chzyer/logex",
sum = "h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=",
version = "v1.1.10",
)
go_repository(
name = "com_github_chzyer_readline",
importpath = "github.com/chzyer/readline",
sum = "h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=",
version = "v0.0.0-20180603132655-2972be24d48e",
)
go_repository(
name = "com_github_chzyer_test",
importpath = "github.com/chzyer/test",
sum = "h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=",
version = "v0.0.0-20180213035817-a1ea475d72b1",
)
go_repository(
name = "com_github_client9_misspell",
importpath = "github.com/client9/misspell",
sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=",
version = "v0.3.4",
)
go_repository(
name = "com_github_emirpasic_gods",
importpath = "github.com/emirpasic/gods",
sum = "h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=",
version = "v1.18.1",
)
go_repository(
name = "com_github_envoyproxy_go_control_plane",
importpath = "github.com/envoyproxy/go-control-plane",
sum = "h1:4cmBvAEBNJaGARUEs3/suWRyfyBfhf7I60WBZq+bv2w=",
version = "v0.9.1-0.20191026205805-5f8ba28d4473",
)
go_repository(
name = "com_github_envoyproxy_protoc_gen_validate",
importpath = "github.com/envoyproxy/protoc-gen-validate",
sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=",
version = "v0.1.0",
)
go_repository(
name = "com_github_ghodss_yaml",
importpath = "github.com/ghodss/yaml",
sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=",
version = "v1.0.0",
)
go_repository(
name = "com_github_golang_glog",
importpath = "github.com/golang/glog",
sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=",
version = "v0.0.0-20160126235308-23def4e6c14b",
)
go_repository(
name = "com_github_golang_mock",
importpath = "github.com/golang/mock",
sum = "h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=",
version = "v1.1.1",
)
go_repository(
name = "com_github_golang_protobuf",
importpath = "github.com/golang/protobuf",
sum = "h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=",
version = "v1.4.3",
)
go_repository(
name = "com_github_google_go_cmp",
importpath = "github.com/google/go-cmp",
sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=",
version = "v0.5.9",
)
go_repository(
name = "com_github_prometheus_client_model",
importpath = "github.com/prometheus/client_model",
sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=",
version = "v0.0.0-20190812154241-14fe0d1b01d4",
)
go_repository(
name = "com_github_yuin_goldmark",
importpath = "github.com/yuin/goldmark",
sum = "h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=",
version = "v1.4.13",
)
go_repository(
name = "com_google_cloud_go",
importpath = "cloud.google.com/go",
sum = "h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ=",
version = "v0.26.0",
)
go_repository(
name = "in_gopkg_check_v1",
importpath = "gopkg.in/check.v1",
sum = "h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=",
version = "v0.0.0-20161208181325-20d25e280405",
)
go_repository(
name = "in_gopkg_yaml_v2",
importpath = "gopkg.in/yaml.v2",
sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=",
version = "v2.4.0",
)
go_repository(
name = "net_starlark_go",
importpath = "go.starlark.net",
sum = "h1:xwwDQW5We85NaTk2APgoN9202w/l0DVGp+GZMfsrh7s=",
version = "v0.0.0-20210223155950-e043a3d3c984",
)
go_repository(
name = "org_golang_google_appengine",
importpath = "google.golang.org/appengine",
sum = "h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=",
version = "v1.4.0",
)
go_repository(
name = "org_golang_google_genproto",
importpath = "google.golang.org/genproto",
sum = "h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=",
version = "v0.0.0-20200526211855-cb27e3aa2013",
)
go_repository(
name = "org_golang_google_grpc",
importpath = "google.golang.org/grpc",
sum = "h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=",
version = "v1.27.0",
)
go_repository(
name = "org_golang_google_protobuf",
importpath = "google.golang.org/protobuf",
sum = "h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=",
version = "v1.25.0",
)
go_repository(
name = "org_golang_x_crypto",
importpath = "golang.org/x/crypto",
sum = "h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=",
version = "v0.0.0-20190308221718-c2843e01d9a2",
)
go_repository(
name = "org_golang_x_exp",
importpath = "golang.org/x/exp",
sum = "h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA=",
version = "v0.0.0-20190121172915-509febef88a4",
)
go_repository(
name = "org_golang_x_lint",
importpath = "golang.org/x/lint",
sum = "h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=",
version = "v0.0.0-20190313153728-d0100b6bd8b3",
)
go_repository(
name = "org_golang_x_mod",
importpath = "golang.org/x/mod",
sum = "h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=",
version = "v0.6.0-dev.0.20220419223038-86c51ed26bb4",
)
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=",
version = "v0.0.0-20220722155237-a158d28d115b",
)
go_repository(
name = "org_golang_x_oauth2",
importpath = "golang.org/x/oauth2",
sum = "h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=",
version = "v0.0.0-20180821212333-d2e6202438be",
)
go_repository(
name = "org_golang_x_sync",
importpath = "golang.org/x/sync",
sum = "h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=",
version = "v0.0.0-20220722155255-886fb9371eb4",
)
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc=",
version = "v0.0.0-20221010170243-090e33056c14",
)
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=",
version = "v0.3.7",
)
go_repository(
name = "org_golang_x_tools",
build_directives = [
"gazelle:exclude **/testdata/**/*",
],
importpath = "golang.org/x/tools",
sum = "h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=",
version = "v0.1.12",
)
go_repository(
name = "org_golang_x_xerrors",
importpath = "golang.org/x/xerrors",
sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=",
version = "v0.0.0-20200804184101-5ec99f83aff1",
)
rules_python-0.22.1/gazelle/go.mod 0000664 0000000 0000000 00000000661 14540404546 0017071 0 ustar 00root root 0000000 0000000 module github.com/bazelbuild/rules_python/gazelle
go 1.19
require (
github.com/bazelbuild/buildtools v0.0.0-20221004120235-7186f635531b
github.com/bmatcuk/doublestar v1.3.4
github.com/emirpasic/gods v1.18.1
github.com/ghodss/yaml v1.0.0
gopkg.in/yaml.v2 v2.4.0
)
require (
github.com/google/go-cmp v0.5.9 // indirect
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
golang.org/x/tools v0.1.12 // indirect
)
rules_python-0.22.1/gazelle/go.sum 0000664 0000000 0000000 00000021750 14540404546 0017120 0 ustar 00root root 0000000 0000000 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/bazelbuild/bazel-gazelle v0.27.0 h1:+/ZhUxlDy4XnyMIGeKkbRZoIGssy1eO51GijwIvvuwE=
github.com/bazelbuild/bazel-gazelle v0.27.0/go.mod h1:2K6B42/loq8ext4JObmam4gTYx4En1MUSzHFKQF8hPM=
github.com/bazelbuild/buildtools v0.0.0-20221004120235-7186f635531b h1:jhiMzJ+8unnLRtV8rpbWBFE9pFNzIqgUTyZU5aA++w8=
github.com/bazelbuild/buildtools v0.0.0-20221004120235-7186f635531b/go.mod h1:689QdV3hBP7Vo9dJMmzhoYIyo/9iMhEmHkJcnaPRCbo=
github.com/bazelbuild/rules_go v0.35.0 h1:ViPR65vOrg74JKntAUFY6qZkheBKGB6to7wFd8gCRU4=
github.com/bazelbuild/rules_go v0.35.0/go.mod h1:ahciH68Viyxtm/gvCQplaAiu8buhf/b+gWswcPjFixI=
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
go.starlark.net v0.0.0-20210223155950-e043a3d3c984/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
rules_python-0.22.1/gazelle/manifest/ 0000775 0000000 0000000 00000000000 14540404546 0017566 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/manifest/BUILD.bazel 0000664 0000000 0000000 00000001323 14540404546 0021443 0 ustar 00root root 0000000 0000000 load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "manifest",
srcs = ["manifest.go"],
importpath = "github.com/bazelbuild/rules_python/gazelle/manifest",
visibility = ["//visibility:public"],
deps = [
"@com_github_emirpasic_gods//sets/treeset",
"@in_gopkg_yaml_v2//:yaml_v2",
],
)
go_test(
name = "manifest_test",
srcs = ["manifest_test.go"],
data = glob(["testdata/**"]),
deps = [":manifest"],
)
filegroup(
name = "distribution",
srcs = glob(["**"]) + [
"//manifest/generate:distribution",
"//manifest/hasher:distribution",
"//manifest/test:distribution",
],
visibility = ["//:__pkg__"],
)
rules_python-0.22.1/gazelle/manifest/defs.bzl 0000664 0000000 0000000 00000013204 14540404546 0021220 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module provides the gazelle_python_manifest macro that contains targets
for updating and testing the Gazelle manifest file.
"""
load("@io_bazel_rules_go//go:def.bzl", "GoSource", "go_binary", "go_test")
def gazelle_python_manifest(
name,
requirements,
modules_mapping,
pip_repository_name = "",
pip_deps_repository_name = "",
manifest = ":gazelle_python.yaml",
use_pip_repository_aliases = False):
"""A macro for defining the updating and testing targets for the Gazelle manifest file.
Args:
name: the name used as a base for the targets.
requirements: the target for the requirements.txt file.
pip_repository_name: the name of the pip_install or pip_repository target.
use_pip_repository_aliases: boolean flag to enable using user-friendly
python package aliases.
pip_deps_repository_name: deprecated - the old pip_install target name.
modules_mapping: the target for the generated modules_mapping.json file.
manifest: the target for the Gazelle manifest file.
"""
if pip_deps_repository_name != "":
# buildifier: disable=print
print("DEPRECATED pip_deps_repository_name in //{}:{}. Please use pip_repository_name instead.".format(
native.package_name(),
name,
))
pip_repository_name = pip_deps_repository_name
if pip_repository_name == "":
# This is a temporary check while pip_deps_repository_name exists as deprecated.
fail("pip_repository_name must be set in //{}:{}".format(native.package_name(), name))
update_target = "{}.update".format(name)
update_target_label = "//{}:{}".format(native.package_name(), update_target)
manifest_generator_hash = Label("//manifest/generate:generate_lib_sources_hash")
update_args = [
"--manifest-generator-hash",
"$(rootpath {})".format(manifest_generator_hash),
"--requirements",
"$(rootpath {})".format(requirements),
"--pip-repository-name",
pip_repository_name,
"--modules-mapping",
"$(rootpath {})".format(modules_mapping),
"--output",
"$(rootpath {})".format(manifest),
"--update-target",
update_target_label,
]
if use_pip_repository_aliases:
update_args += [
"--use-pip-repository-aliases",
"true",
]
go_binary(
name = update_target,
embed = [Label("//manifest/generate:generate_lib")],
data = [
manifest,
modules_mapping,
requirements,
manifest_generator_hash,
],
args = update_args,
visibility = ["//visibility:private"],
tags = ["manual"],
)
go_test(
name = "{}.test".format(name),
srcs = [Label("//manifest/test:test.go")],
data = [
manifest,
requirements,
manifest_generator_hash,
],
env = {
"_TEST_MANIFEST": "$(rootpath {})".format(manifest),
"_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash),
"_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements),
},
rundir = ".",
deps = [Label("//manifest")],
size = "small",
)
native.filegroup(
name = name,
srcs = [manifest],
tags = ["manual"],
visibility = ["//visibility:public"],
)
# buildifier: disable=provider-params
AllSourcesInfo = provider(fields = {"all_srcs": "All sources collected from the target and dependencies."})
_rules_python_workspace = Label("@rules_python//:WORKSPACE")
def _get_all_sources_impl(target, ctx):
is_rules_python = target.label.workspace_name == _rules_python_workspace.workspace_name
if not is_rules_python:
# Avoid adding third-party dependency files to the checksum of the srcs.
return AllSourcesInfo(all_srcs = depset())
srcs = depset(
target[GoSource].orig_srcs,
transitive = [dep[AllSourcesInfo].all_srcs for dep in ctx.rule.attr.deps],
)
return [AllSourcesInfo(all_srcs = srcs)]
_get_all_sources = aspect(
implementation = _get_all_sources_impl,
attr_aspects = ["deps"],
)
def _sources_hash_impl(ctx):
all_srcs = ctx.attr.go_library[AllSourcesInfo].all_srcs
hash_file = ctx.actions.declare_file(ctx.attr.name + ".hash")
args = ctx.actions.args()
args.add(hash_file)
args.add_all(all_srcs)
ctx.actions.run(
outputs = [hash_file],
inputs = all_srcs,
arguments = [args],
executable = ctx.executable._hasher,
)
return [DefaultInfo(
files = depset([hash_file]),
runfiles = ctx.runfiles([hash_file]),
)]
sources_hash = rule(
_sources_hash_impl,
attrs = {
"go_library": attr.label(
aspects = [_get_all_sources],
providers = [GoSource],
),
"_hasher": attr.label(
cfg = "exec",
default = Label("//manifest/hasher"),
executable = True,
),
},
)
rules_python-0.22.1/gazelle/manifest/generate/ 0000775 0000000 0000000 00000000000 14540404546 0021360 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/manifest/generate/BUILD.bazel 0000664 0000000 0000000 00000001250 14540404546 0023234 0 ustar 00root root 0000000 0000000 load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//manifest:defs.bzl", "sources_hash")
go_library(
name = "generate_lib",
srcs = ["generate.go"],
importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/generate",
visibility = ["//visibility:public"],
deps = ["//manifest"],
)
sources_hash(
name = "generate_lib_sources_hash",
go_library = ":generate_lib",
visibility = ["//visibility:public"],
)
go_binary(
name = "generate",
embed = [":generate_lib"],
visibility = ["//visibility:public"],
)
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//manifest:__pkg__"],
)
rules_python-0.22.1/gazelle/manifest/generate/generate.go 0000664 0000000 0000000 00000012164 14540404546 0023505 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
generate.go is a program that generates the Gazelle YAML manifest.
The Gazelle manifest is a file that contains extra information required when
generating the Bazel BUILD files.
*/
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"os"
"strings"
"github.com/bazelbuild/rules_python/gazelle/manifest"
)
func init() {
if os.Getenv("BUILD_WORKSPACE_DIRECTORY") == "" {
log.Fatalln("ERROR: this program must run under Bazel")
}
}
func main() {
var (
manifestGeneratorHashPath string
requirementsPath string
pipRepositoryName string
usePipRepositoryAliases bool
modulesMappingPath string
outputPath string
updateTarget string
)
flag.StringVar(
&manifestGeneratorHashPath,
"manifest-generator-hash",
"",
"The file containing the hash for the source code of the manifest generator."+
"This is important to force manifest updates when the generator logic changes.")
flag.StringVar(
&requirementsPath,
"requirements",
"",
"The requirements.txt file.")
flag.StringVar(
&pipRepositoryName,
"pip-repository-name",
"",
"The name of the pip_install or pip_repository target.")
flag.BoolVar(
&usePipRepositoryAliases,
"use-pip-repository-aliases",
false,
"Whether to use the pip-repository aliases, which are generated when passing 'incompatible_generate_aliases = True'.")
flag.StringVar(
&modulesMappingPath,
"modules-mapping",
"",
"The modules_mapping.json file.")
flag.StringVar(
&outputPath,
"output",
"",
"The output YAML manifest file.")
flag.StringVar(
&updateTarget,
"update-target",
"",
"The Bazel target to update the YAML manifest file.")
flag.Parse()
if requirementsPath == "" {
log.Fatalln("ERROR: --requirements must be set")
}
if modulesMappingPath == "" {
log.Fatalln("ERROR: --modules-mapping must be set")
}
if outputPath == "" {
log.Fatalln("ERROR: --output must be set")
}
if updateTarget == "" {
log.Fatalln("ERROR: --update-target must be set")
}
modulesMapping, err := unmarshalJSON(modulesMappingPath)
if err != nil {
log.Fatalf("ERROR: %v\n", err)
}
header := generateHeader(updateTarget)
manifestFile := manifest.NewFile(&manifest.Manifest{
ModulesMapping: modulesMapping,
PipRepository: &manifest.PipRepository{
Name: pipRepositoryName,
UsePipRepositoryAliases: usePipRepositoryAliases,
},
})
if err := writeOutput(
outputPath,
header,
manifestFile,
manifestGeneratorHashPath,
requirementsPath,
); err != nil {
log.Fatalf("ERROR: %v\n", err)
}
}
// unmarshalJSON returns the parsed mapping from the given JSON file path.
func unmarshalJSON(jsonPath string) (map[string]string, error) {
file, err := os.Open(jsonPath)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal JSON file: %w", err)
}
defer file.Close()
decoder := json.NewDecoder(file)
output := make(map[string]string)
if err := decoder.Decode(&output); err != nil {
return nil, fmt.Errorf("failed to unmarshal JSON file: %w", err)
}
return output, nil
}
// generateHeader generates the YAML header human-readable comment.
func generateHeader(updateTarget string) string {
var header strings.Builder
header.WriteString("# GENERATED FILE - DO NOT EDIT!\n")
header.WriteString("#\n")
header.WriteString("# To update this file, run:\n")
header.WriteString(fmt.Sprintf("# bazel run %s\n", updateTarget))
return header.String()
}
// writeOutput writes to the final file the header and manifest structure.
func writeOutput(
outputPath string,
header string,
manifestFile *manifest.File,
manifestGeneratorHashPath string,
requirementsPath string,
) error {
stat, err := os.Stat(outputPath)
if err != nil {
return fmt.Errorf("failed to write output: %w", err)
}
outputFile, err := os.OpenFile(outputPath, os.O_WRONLY|os.O_TRUNC, stat.Mode())
if err != nil {
return fmt.Errorf("failed to write output: %w", err)
}
defer outputFile.Close()
if _, err := fmt.Fprintf(outputFile, "%s\n", header); err != nil {
return fmt.Errorf("failed to write output: %w", err)
}
manifestGeneratorHash, err := os.Open(manifestGeneratorHashPath)
if err != nil {
return fmt.Errorf("failed to write output: %w", err)
}
defer manifestGeneratorHash.Close()
requirements, err := os.Open(requirementsPath)
if err != nil {
return fmt.Errorf("failed to write output: %w", err)
}
defer requirements.Close()
if err := manifestFile.Encode(outputFile, manifestGeneratorHash, requirements); err != nil {
return fmt.Errorf("failed to write output: %w", err)
}
return nil
}
rules_python-0.22.1/gazelle/manifest/hasher/ 0000775 0000000 0000000 00000000000 14540404546 0021040 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/manifest/hasher/BUILD.bazel 0000664 0000000 0000000 00000000721 14540404546 0022716 0 ustar 00root root 0000000 0000000 load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "hasher_lib",
srcs = ["main.go"],
importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/hasher",
visibility = ["//visibility:private"],
)
go_binary(
name = "hasher",
embed = [":hasher_lib"],
visibility = ["//visibility:public"],
)
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//manifest:__pkg__"],
)
rules_python-0.22.1/gazelle/manifest/hasher/main.go 0000664 0000000 0000000 00000002057 14540404546 0022317 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"crypto/sha256"
"io"
"log"
"os"
)
func main() {
h := sha256.New()
out, err := os.Create(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer out.Close()
for _, filename := range os.Args[2:] {
f, err := os.Open(filename)
if err != nil {
log.Fatal(err)
}
defer f.Close()
if _, err := io.Copy(h, f); err != nil {
log.Fatal(err)
}
}
if _, err := out.Write(h.Sum(nil)); err != nil {
log.Fatal(err)
}
}
rules_python-0.22.1/gazelle/manifest/manifest.go 0000664 0000000 0000000 00000012172 14540404546 0021726 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package manifest
import (
"crypto/sha256"
"fmt"
"io"
"os"
"github.com/emirpasic/gods/sets/treeset"
yaml "gopkg.in/yaml.v2"
)
// File represents the gazelle_python.yaml file.
type File struct {
Manifest *Manifest `yaml:"manifest,omitempty"`
// Integrity is the hash of the requirements.txt file and the Manifest for
// ensuring the integrity of the entire gazelle_python.yaml file. This
// controls the testing to keep the gazelle_python.yaml file up-to-date.
Integrity string `yaml:"integrity"`
}
// NewFile creates a new File with a given Manifest.
func NewFile(manifest *Manifest) *File {
return &File{Manifest: manifest}
}
// Encode encodes the manifest file to the given writer.
func (f *File) Encode(w io.Writer, manifestGeneratorHashFile, requirements io.Reader) error {
integrityBytes, err := f.calculateIntegrity(manifestGeneratorHashFile, requirements)
if err != nil {
return fmt.Errorf("failed to encode manifest file: %w", err)
}
f.Integrity = fmt.Sprintf("%x", integrityBytes)
encoder := yaml.NewEncoder(w)
defer encoder.Close()
if err := encoder.Encode(f); err != nil {
return fmt.Errorf("failed to encode manifest file: %w", err)
}
return nil
}
// VerifyIntegrity verifies if the integrity set in the File is valid.
func (f *File) VerifyIntegrity(manifestGeneratorHashFile, requirements io.Reader) (bool, error) {
integrityBytes, err := f.calculateIntegrity(manifestGeneratorHashFile, requirements)
if err != nil {
return false, fmt.Errorf("failed to verify integrity: %w", err)
}
valid := (f.Integrity == fmt.Sprintf("%x", integrityBytes))
return valid, nil
}
// calculateIntegrity calculates the integrity of the manifest file based on the
// provided checksum for the requirements.txt file used as input to the modules
// mapping, plus the manifest structure in the manifest file. This integrity
// calculation ensures the manifest files are kept up-to-date.
func (f *File) calculateIntegrity(
manifestGeneratorHash, requirements io.Reader,
) ([]byte, error) {
hash := sha256.New()
// Sum the manifest part of the file.
encoder := yaml.NewEncoder(hash)
defer encoder.Close()
if err := encoder.Encode(f.Manifest); err != nil {
return nil, fmt.Errorf("failed to calculate integrity: %w", err)
}
// Sum the manifest generator checksum bytes.
if _, err := io.Copy(hash, manifestGeneratorHash); err != nil {
return nil, fmt.Errorf("failed to calculate integrity: %w", err)
}
// Sum the requirements.txt checksum bytes.
if _, err := io.Copy(hash, requirements); err != nil {
return nil, fmt.Errorf("failed to calculate integrity: %w", err)
}
return hash.Sum(nil), nil
}
// Decode decodes the manifest file from the given path.
func (f *File) Decode(manifestPath string) error {
file, err := os.Open(manifestPath)
if err != nil {
return fmt.Errorf("failed to decode manifest file: %w", err)
}
defer file.Close()
decoder := yaml.NewDecoder(file)
if err := decoder.Decode(f); err != nil {
return fmt.Errorf("failed to decode manifest file: %w", err)
}
return nil
}
// ModulesMapping is the type used to map from importable Python modules to
// the wheel names that provide these modules.
type ModulesMapping map[string]string
// MarshalYAML makes sure that we sort the module names before marshaling
// the contents of `ModulesMapping` to a YAML file. This ensures that the
// file is deterministically generated from the map.
func (m ModulesMapping) MarshalYAML() (interface{}, error) {
var mapslice yaml.MapSlice
keySet := treeset.NewWithStringComparator()
for key := range m {
keySet.Add(key)
}
for _, key := range keySet.Values() {
mapslice = append(mapslice, yaml.MapItem{Key: key, Value: m[key.(string)]})
}
return mapslice, nil
}
// Manifest represents the structure of the Gazelle manifest file.
type Manifest struct {
// ModulesMapping is the mapping from importable modules to which Python
// wheel name provides these modules.
ModulesMapping ModulesMapping `yaml:"modules_mapping"`
// PipDepsRepositoryName is the name of the pip_install repository target.
// DEPRECATED
PipDepsRepositoryName string `yaml:"pip_deps_repository_name,omitempty"`
// PipRepository contains the information for pip_install or pip_repository
// target.
PipRepository *PipRepository `yaml:"pip_repository,omitempty"`
}
type PipRepository struct {
// The name of the pip_install or pip_repository target.
Name string
// UsePipRepositoryAliases allows to use aliases generated pip_repository
// when passing incompatible_generate_aliases = True.
UsePipRepositoryAliases bool `yaml:"use_pip_repository_aliases,omitempty"`
}
rules_python-0.22.1/gazelle/manifest/manifest_test.go 0000664 0000000 0000000 00000006002 14540404546 0022760 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package manifest_test
import (
"bytes"
"log"
"os"
"reflect"
"strings"
"testing"
"github.com/bazelbuild/rules_python/gazelle/manifest"
)
var modulesMapping = manifest.ModulesMapping{
"arrow": "arrow",
"arrow.__init__": "arrow",
"arrow.api": "arrow",
"arrow.arrow": "arrow",
"arrow.factory": "arrow",
"arrow.formatter": "arrow",
"arrow.locales": "arrow",
"arrow.parser": "arrow",
"arrow.util": "arrow",
}
const pipDepsRepositoryName = "test_repository_name"
func TestFile(t *testing.T) {
t.Run("Encode", func(t *testing.T) {
f := manifest.NewFile(&manifest.Manifest{
ModulesMapping: modulesMapping,
PipDepsRepositoryName: pipDepsRepositoryName,
})
var b bytes.Buffer
manifestGeneratorHashFile := strings.NewReader("")
requirements, err := os.Open("testdata/requirements.txt")
if err != nil {
log.Println(err)
t.FailNow()
}
defer requirements.Close()
if err := f.Encode(&b, manifestGeneratorHashFile, requirements); err != nil {
log.Println(err)
t.FailNow()
}
expected, err := os.ReadFile("testdata/gazelle_python.yaml")
if err != nil {
log.Println(err)
t.FailNow()
}
if !bytes.Equal(expected, b.Bytes()) {
log.Printf("encoded manifest doesn't match expected output: %v\n", b.String())
t.FailNow()
}
})
t.Run("Decode", func(t *testing.T) {
f := manifest.NewFile(&manifest.Manifest{})
if err := f.Decode("testdata/gazelle_python.yaml"); err != nil {
log.Println(err)
t.FailNow()
}
if !reflect.DeepEqual(modulesMapping, f.Manifest.ModulesMapping) {
log.Println("decoded modules_mapping doesn't match expected value")
t.FailNow()
}
if f.Manifest.PipDepsRepositoryName != pipDepsRepositoryName {
log.Println("decoded pip repository name doesn't match expected value")
t.FailNow()
}
})
t.Run("VerifyIntegrity", func(t *testing.T) {
f := manifest.NewFile(&manifest.Manifest{})
if err := f.Decode("testdata/gazelle_python.yaml"); err != nil {
log.Println(err)
t.FailNow()
}
manifestGeneratorHashFile := strings.NewReader("")
requirements, err := os.Open("testdata/requirements.txt")
if err != nil {
log.Println(err)
t.FailNow()
}
defer requirements.Close()
valid, err := f.VerifyIntegrity(manifestGeneratorHashFile, requirements)
if err != nil {
log.Println(err)
t.FailNow()
}
if !valid {
log.Println("decoded manifest file is not valid")
t.FailNow()
}
})
}
rules_python-0.22.1/gazelle/manifest/test/ 0000775 0000000 0000000 00000000000 14540404546 0020545 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/manifest/test/BUILD.bazel 0000664 0000000 0000000 00000000230 14540404546 0022416 0 ustar 00root root 0000000 0000000 # gazelle:ignore
exports_files(["test.go"])
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//manifest:__pkg__"],
)
rules_python-0.22.1/gazelle/manifest/test/test.go 0000664 0000000 0000000 00000004446 14540404546 0022063 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
test.go is a unit test that asserts the Gazelle YAML manifest is up-to-date in
regards to the requirements.txt.
It re-hashes the requirements.txt and compares it to the recorded one in the
existing generated Gazelle manifest.
*/
package test
import (
"os"
"path/filepath"
"testing"
"github.com/bazelbuild/rules_python/gazelle/manifest"
)
func TestGazelleManifestIsUpdated(t *testing.T) {
requirementsPath := os.Getenv("_TEST_REQUIREMENTS")
if requirementsPath == "" {
t.Fatalf("_TEST_REQUIREMENTS must be set")
}
manifestPath := os.Getenv("_TEST_MANIFEST")
if manifestPath == "" {
t.Fatalf("_TEST_MANIFEST must be set")
}
manifestFile := new(manifest.File)
if err := manifestFile.Decode(manifestPath); err != nil {
t.Fatalf("decoding manifest file: %v", err)
}
if manifestFile.Integrity == "" {
t.Fatal("failed to find the Gazelle manifest file integrity")
}
manifestGeneratorHashPath := os.Getenv("_TEST_MANIFEST_GENERATOR_HASH")
manifestGeneratorHash, err := os.Open(manifestGeneratorHashPath)
if err != nil {
t.Fatalf("opening %q: %v", manifestGeneratorHashPath, err)
}
defer manifestGeneratorHash.Close()
requirements, err := os.Open(requirementsPath)
if err != nil {
t.Fatalf("opening %q: %v", requirementsPath, err)
}
defer requirements.Close()
valid, err := manifestFile.VerifyIntegrity(manifestGeneratorHash, requirements)
if err != nil {
t.Fatalf("verifying integrity: %v", err)
}
if !valid {
manifestRealpath, err := filepath.EvalSymlinks(manifestPath)
if err != nil {
t.Fatalf("evaluating symlink %q: %v", manifestPath, err)
}
t.Errorf(
"%q is out-of-date. Follow the update instructions in that file to resolve this",
manifestRealpath)
}
}
rules_python-0.22.1/gazelle/manifest/testdata/ 0000775 0000000 0000000 00000000000 14540404546 0021377 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/manifest/testdata/gazelle_python.yaml 0000664 0000000 0000000 00000000554 14540404546 0025313 0 ustar 00root root 0000000 0000000 manifest:
modules_mapping:
arrow: arrow
arrow.__init__: arrow
arrow.api: arrow
arrow.arrow: arrow
arrow.factory: arrow
arrow.formatter: arrow
arrow.locales: arrow
arrow.parser: arrow
arrow.util: arrow
pip_deps_repository_name: test_repository_name
integrity: eedf187f8b7ec27cdfc682feee4206e063b51d13d78f77c05d3a30ec11bd7411
rules_python-0.22.1/gazelle/manifest/testdata/requirements.txt 0000664 0000000 0000000 00000000061 14540404546 0024660 0 ustar 00root root 0000000 0000000 # This is a file for testing only.
arrow==0.12.1 rules_python-0.22.1/gazelle/modules_mapping/ 0000775 0000000 0000000 00000000000 14540404546 0021143 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/modules_mapping/BUILD.bazel 0000664 0000000 0000000 00000000404 14540404546 0023017 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "generator",
srcs = ["generator.py"],
visibility = ["//visibility:public"],
)
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//:__pkg__"],
)
rules_python-0.22.1/gazelle/modules_mapping/def.bzl 0000664 0000000 0000000 00000005244 14540404546 0022417 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Definitions for the modules_mapping.json generation.
The modules_mapping.json file is a mapping from Python modules to the wheel
names that provide those modules. It is used for determining which wheel
distribution should be used in the `deps` attribute of `py_*` targets.
This mapping is necessary when reading Python import statements and determining
if they are provided by third-party dependencies. Most importantly, when the
module name doesn't match the wheel distribution name.
"""
def _modules_mapping_impl(ctx):
modules_mapping = ctx.actions.declare_file(ctx.attr.modules_mapping_name)
args = ctx.actions.args()
args.add("--output_file", modules_mapping.path)
args.add_all("--exclude_patterns", ctx.attr.exclude_patterns)
args.add_all("--wheels", [whl.path for whl in ctx.files.wheels])
ctx.actions.run(
inputs = ctx.files.wheels,
outputs = [modules_mapping],
executable = ctx.executable._generator,
arguments = [args],
use_default_shell_env = False,
)
return [DefaultInfo(files = depset([modules_mapping]))]
modules_mapping = rule(
_modules_mapping_impl,
attrs = {
"exclude_patterns": attr.string_list(
default = ["^_|(\\._)+"],
doc = "A set of regex patterns to match against each calculated module path. By default, exclude the modules starting with underscores.",
mandatory = False,
),
"modules_mapping_name": attr.string(
default = "modules_mapping.json",
doc = "The name for the output JSON file.",
mandatory = False,
),
"wheels": attr.label_list(
allow_files = True,
doc = "The list of wheels, usually the 'all_whl_requirements' from @//:requirements.bzl",
mandatory = True,
),
"_generator": attr.label(
cfg = "exec",
default = "//modules_mapping:generator",
executable = True,
),
},
doc = "Creates a modules_mapping.json file for mapping module names to wheel distribution names.",
)
rules_python-0.22.1/gazelle/modules_mapping/generator.py 0000664 0000000 0000000 00000011560 14540404546 0023506 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import json
import pathlib
import re
import sys
import zipfile
# Generator is the modules_mapping.json file generator.
class Generator:
stderr = None
output_file = None
excluded_patterns = None
mapping = {}
def __init__(self, stderr, output_file, excluded_patterns):
self.stderr = stderr
self.output_file = output_file
self.excluded_patterns = [re.compile(pattern) for pattern in excluded_patterns]
# dig_wheel analyses the wheel .whl file determining the modules it provides
# by looking at the directory structure.
def dig_wheel(self, whl):
with zipfile.ZipFile(whl, "r") as zip_file:
for path in zip_file.namelist():
if is_metadata(path):
if data_has_purelib_or_platlib(path):
self.module_for_path(path, whl)
else:
continue
else:
self.module_for_path(path, whl)
def module_for_path(self, path, whl):
ext = pathlib.Path(path).suffix
if ext == ".py" or ext == ".so":
if "purelib" in path or "platlib" in path:
root = "/".join(path.split("/")[2:])
else:
root = path
wheel_name = get_wheel_name(whl)
if root.endswith("/__init__.py"):
# Note the '/' here means that the __init__.py is not in the
# root of the wheel, therefore we can index the directory
# where this file is as an importable package.
module = root[: -len("/__init__.py")].replace("/", ".")
if not self.is_excluded(module):
self.mapping[module] = wheel_name
# Always index the module file.
if ext == ".so":
# Also remove extra metadata that is embeded as part of
# the file name as an extra extension.
ext = "".join(pathlib.Path(root).suffixes)
module = root[: -len(ext)].replace("/", ".")
if not self.is_excluded(module):
self.mapping[module] = wheel_name
def is_excluded(self, module):
for pattern in self.excluded_patterns:
if pattern.search(module):
return True
return False
# run is the entrypoint for the generator.
def run(self, wheels):
for whl in wheels:
try:
self.dig_wheel(whl)
except AssertionError as error:
print(error, file=self.stderr)
return 1
mapping_json = json.dumps(self.mapping)
with open(self.output_file, "w") as f:
f.write(mapping_json)
return 0
def get_wheel_name(path):
pp = pathlib.PurePath(path)
if pp.suffix != ".whl":
raise RuntimeError(
"{} is not a valid wheel file name: the wheel doesn't follow ".format(
pp.name
)
+ "https://www.python.org/dev/peps/pep-0427/#file-name-convention"
)
return pp.name[: pp.name.find("-")]
# is_metadata checks if the path is in a metadata directory.
# Ref: https://www.python.org/dev/peps/pep-0427/#file-contents.
def is_metadata(path):
top_level = path.split("/")[0].lower()
return top_level.endswith(".dist-info") or top_level.endswith(".data")
# The .data is allowed to contain a full purelib or platlib directory
# These get unpacked into site-packages, so require indexing too.
# This is the same if "Root-Is-Purelib: true" is set and the files are at the root.
# Ref: https://peps.python.org/pep-0427/#what-s-the-deal-with-purelib-vs-platlib
def data_has_purelib_or_platlib(path):
maybe_lib = path.split("/")[1].lower()
return is_metadata(path) and (maybe_lib == "purelib" or maybe_lib == "platlib")
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="generator",
description="Generates the modules mapping used by the Gazelle manifest.",
)
parser.add_argument("--output_file", type=str)
parser.add_argument("--exclude_patterns", nargs="+", default=[])
parser.add_argument("--wheels", nargs="+", default=[])
args = parser.parse_args()
generator = Generator(sys.stderr, args.output_file, args.exclude_patterns)
exit(generator.run(args.wheels))
rules_python-0.22.1/gazelle/python/ 0000775 0000000 0000000 00000000000 14540404546 0017301 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/BUILD.bazel 0000664 0000000 0000000 00000004116 14540404546 0021161 0 ustar 00root root 0000000 0000000 load("@bazel_gazelle//:def.bzl", "gazelle_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@rules_python//python:defs.bzl", "py_binary")
go_library(
name = "python",
srcs = [
"configure.go",
"fix.go",
"generate.go",
"kinds.go",
"language.go",
"parser.go",
"resolve.go",
"std_modules.go",
"target.go",
],
data = [
":parse",
":std_modules",
],
importpath = "github.com/bazelbuild/rules_python/gazelle/python",
visibility = ["//visibility:public"],
deps = [
"//manifest",
"//pythonconfig",
"@bazel_gazelle//config:go_default_library",
"@bazel_gazelle//label:go_default_library",
"@bazel_gazelle//language:go_default_library",
"@bazel_gazelle//repo:go_default_library",
"@bazel_gazelle//resolve:go_default_library",
"@bazel_gazelle//rule:go_default_library",
"@com_github_bazelbuild_buildtools//build:go_default_library",
"@com_github_bmatcuk_doublestar//:doublestar",
"@com_github_emirpasic_gods//lists/singlylinkedlist",
"@com_github_emirpasic_gods//sets/treeset",
"@com_github_emirpasic_gods//utils",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
],
)
py_binary(
name = "parse",
srcs = ["parse.py"],
visibility = ["//visibility:public"],
)
py_binary(
name = "std_modules",
srcs = ["std_modules.py"],
visibility = ["//visibility:public"],
)
go_test(
name = "python_test",
srcs = ["python_test.go"],
data = [
":gazelle_binary",
":parse",
":std_modules",
] + glob(["testdata/**"]),
deps = [
"@bazel_gazelle//testtools:go_default_library",
"@com_github_ghodss_yaml//:yaml",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
],
)
gazelle_binary(
name = "gazelle_binary",
languages = [":python"],
visibility = ["//visibility:public"],
)
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//:__pkg__"],
)
rules_python-0.22.1/gazelle/python/configure.go 0000664 0000000 0000000 00000014301 14540404546 0021610 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"strconv"
"strings"
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/bazelbuild/rules_python/gazelle/manifest"
"github.com/bazelbuild/rules_python/gazelle/pythonconfig"
)
// Configurer satisfies the config.Configurer interface. It's the
// language-specific configuration extension.
type Configurer struct{}
// RegisterFlags registers command-line flags used by the extension. This
// method is called once with the root configuration when Gazelle
// starts. RegisterFlags may set an initial values in Config.Exts. When flags
// are set, they should modify these values.
func (py *Configurer) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {}
// CheckFlags validates the configuration after command line flags are parsed.
// This is called once with the root configuration when Gazelle starts.
// CheckFlags may set default values in flags or make implied changes.
func (py *Configurer) CheckFlags(fs *flag.FlagSet, c *config.Config) error {
return nil
}
// KnownDirectives returns a list of directive keys that this Configurer can
// interpret. Gazelle prints errors for directives that are not recoginized by
// any Configurer.
func (py *Configurer) KnownDirectives() []string {
return []string{
pythonconfig.PythonExtensionDirective,
pythonconfig.PythonRootDirective,
pythonconfig.PythonManifestFileNameDirective,
pythonconfig.IgnoreFilesDirective,
pythonconfig.IgnoreDependenciesDirective,
pythonconfig.ValidateImportStatementsDirective,
pythonconfig.GenerationMode,
pythonconfig.LibraryNamingConvention,
pythonconfig.BinaryNamingConvention,
pythonconfig.TestNamingConvention,
}
}
// Configure modifies the configuration using directives and other information
// extracted from a build file. Configure is called in each directory.
//
// c is the configuration for the current directory. It starts out as a copy
// of the configuration for the parent directory.
//
// rel is the slash-separated relative path from the repository root to
// the current directory. It is "" for the root directory itself.
//
// f is the build file for the current directory or nil if there is no
// existing build file.
func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) {
// Create the root config.
if _, exists := c.Exts[languageName]; !exists {
rootConfig := pythonconfig.New(c.RepoRoot, "")
c.Exts[languageName] = pythonconfig.Configs{"": rootConfig}
}
configs := c.Exts[languageName].(pythonconfig.Configs)
config, exists := configs[rel]
if !exists {
parent := configs.ParentForPackage(rel)
config = parent.NewChild()
configs[rel] = config
}
if f == nil {
return
}
gazelleManifestFilename := "gazelle_python.yaml"
for _, d := range f.Directives {
switch d.Key {
case "exclude":
// We record the exclude directive for coarse-grained packages
// since we do manual tree traversal in this mode.
config.AddExcludedPattern(filepath.Join(rel, strings.TrimSpace(d.Value)))
case pythonconfig.PythonExtensionDirective:
switch d.Value {
case "enabled":
config.SetExtensionEnabled(true)
case "disabled":
config.SetExtensionEnabled(false)
default:
err := fmt.Errorf("invalid value for directive %q: %s: possible values are enabled/disabled",
pythonconfig.PythonExtensionDirective, d.Value)
log.Fatal(err)
}
case pythonconfig.PythonRootDirective:
config.SetPythonProjectRoot(rel)
case pythonconfig.PythonManifestFileNameDirective:
gazelleManifestFilename = strings.TrimSpace(d.Value)
case pythonconfig.IgnoreFilesDirective:
for _, ignoreFile := range strings.Split(d.Value, ",") {
config.AddIgnoreFile(ignoreFile)
}
case pythonconfig.IgnoreDependenciesDirective:
for _, ignoreDependency := range strings.Split(d.Value, ",") {
config.AddIgnoreDependency(ignoreDependency)
}
case pythonconfig.ValidateImportStatementsDirective:
v, err := strconv.ParseBool(strings.TrimSpace(d.Value))
if err != nil {
log.Fatal(err)
}
config.SetValidateImportStatements(v)
case pythonconfig.GenerationMode:
switch pythonconfig.GenerationModeType(strings.TrimSpace(d.Value)) {
case pythonconfig.GenerationModePackage:
config.SetCoarseGrainedGeneration(false)
case pythonconfig.GenerationModeProject:
config.SetCoarseGrainedGeneration(true)
default:
err := fmt.Errorf("invalid value for directive %q: %s",
pythonconfig.GenerationMode, d.Value)
log.Fatal(err)
}
case pythonconfig.LibraryNamingConvention:
config.SetLibraryNamingConvention(strings.TrimSpace(d.Value))
case pythonconfig.BinaryNamingConvention:
config.SetBinaryNamingConvention(strings.TrimSpace(d.Value))
case pythonconfig.TestNamingConvention:
config.SetTestNamingConvention(strings.TrimSpace(d.Value))
}
}
gazelleManifestPath := filepath.Join(c.RepoRoot, rel, gazelleManifestFilename)
gazelleManifest, err := py.loadGazelleManifest(gazelleManifestPath)
if err != nil {
log.Fatal(err)
}
if gazelleManifest != nil {
config.SetGazelleManifest(gazelleManifest)
}
}
func (py *Configurer) loadGazelleManifest(gazelleManifestPath string) (*manifest.Manifest, error) {
if _, err := os.Stat(gazelleManifestPath); err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, fmt.Errorf("failed to load Gazelle manifest at %q: %w", gazelleManifestPath, err)
}
manifestFile := new(manifest.File)
if err := manifestFile.Decode(gazelleManifestPath); err != nil {
return nil, fmt.Errorf("failed to load Gazelle manifest at %q: %w", gazelleManifestPath, err)
}
return manifestFile.Manifest, nil
}
rules_python-0.22.1/gazelle/python/fix.go 0000664 0000000 0000000 00000002000 14540404546 0020406 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/rule"
)
// Fix repairs deprecated usage of language-specific rules in f. This is
// called before the file is indexed. Unless c.ShouldFix is true, fixes
// that delete or rename rules should not be performed.
func (py *Python) Fix(c *config.Config, f *rule.File) {
// TODO(f0rmiga): implement.
}
rules_python-0.22.1/gazelle/python/generate.go 0000664 0000000 0000000 00000034715 14540404546 0021434 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"fmt"
"io/fs"
"log"
"os"
"path/filepath"
"strings"
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/label"
"github.com/bazelbuild/bazel-gazelle/language"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/bazelbuild/rules_python/gazelle/pythonconfig"
"github.com/bmatcuk/doublestar"
"github.com/emirpasic/gods/lists/singlylinkedlist"
"github.com/emirpasic/gods/sets/treeset"
godsutils "github.com/emirpasic/gods/utils"
)
const (
pyLibraryEntrypointFilename = "__init__.py"
pyBinaryEntrypointFilename = "__main__.py"
pyTestEntrypointFilename = "__test__.py"
pyTestEntrypointTargetname = "__test__"
conftestFilename = "conftest.py"
conftestTargetname = "conftest"
)
var (
buildFilenames = []string{"BUILD", "BUILD.bazel"}
)
func GetActualKindName(kind string, args language.GenerateArgs) string {
if kindOverride, ok := args.Config.KindMap[kind]; ok {
return kindOverride.KindName
}
return kind
}
// GenerateRules extracts build metadata from source files in a directory.
// GenerateRules is called in each directory where an update is requested
// in depth-first post-order.
func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateResult {
cfgs := args.Config.Exts[languageName].(pythonconfig.Configs)
cfg := cfgs[args.Rel]
if !cfg.ExtensionEnabled() {
return language.GenerateResult{}
}
if !isBazelPackage(args.Dir) {
if cfg.CoarseGrainedGeneration() {
// Determine if the current directory is the root of the coarse-grained
// generation. If not, return without generating anything.
parent := cfg.Parent()
if parent != nil && parent.CoarseGrainedGeneration() {
return language.GenerateResult{}
}
} else if !hasEntrypointFile(args.Dir) {
return language.GenerateResult{}
}
}
actualPyBinaryKind := GetActualKindName(pyBinaryKind, args)
actualPyLibraryKind := GetActualKindName(pyLibraryKind, args)
actualPyTestKind := GetActualKindName(pyTestKind, args)
pythonProjectRoot := cfg.PythonProjectRoot()
packageName := filepath.Base(args.Dir)
pyLibraryFilenames := treeset.NewWith(godsutils.StringComparator)
pyTestFilenames := treeset.NewWith(godsutils.StringComparator)
pyFileNames := treeset.NewWith(godsutils.StringComparator)
// hasPyBinary controls whether a py_binary target should be generated for
// this package or not.
hasPyBinary := false
// hasPyTestEntryPointFile and hasPyTestEntryPointTarget control whether a py_test target should
// be generated for this package or not.
hasPyTestEntryPointFile := false
hasPyTestEntryPointTarget := false
hasConftestFile := false
for _, f := range args.RegularFiles {
if cfg.IgnoresFile(filepath.Base(f)) {
continue
}
ext := filepath.Ext(f)
if ext == ".py" {
pyFileNames.Add(f)
if !hasPyBinary && f == pyBinaryEntrypointFilename {
hasPyBinary = true
} else if !hasPyTestEntryPointFile && f == pyTestEntrypointFilename {
hasPyTestEntryPointFile = true
} else if f == conftestFilename {
hasConftestFile = true
} else if strings.HasSuffix(f, "_test.py") || strings.HasPrefix(f, "test_") {
pyTestFilenames.Add(f)
} else {
pyLibraryFilenames.Add(f)
}
}
}
// If a __test__.py file was not found on disk, search for targets that are
// named __test__.
if !hasPyTestEntryPointFile && args.File != nil {
for _, rule := range args.File.Rules {
if rule.Name() == pyTestEntrypointTargetname {
hasPyTestEntryPointTarget = true
break
}
}
}
// Add files from subdirectories if they meet the criteria.
for _, d := range args.Subdirs {
// boundaryPackages represents child Bazel packages that are used as a
// boundary to stop processing under that tree.
boundaryPackages := make(map[string]struct{})
err := filepath.WalkDir(
filepath.Join(args.Dir, d),
func(path string, entry fs.DirEntry, err error) error {
if err != nil {
return err
}
// Ignore the path if it crosses any boundary package. Walking
// the tree is still important because subsequent paths can
// represent files that have not crossed any boundaries.
for bp := range boundaryPackages {
if strings.HasPrefix(path, bp) {
return nil
}
}
if entry.IsDir() {
// If we are visiting a directory, we determine if we should
// halt digging the tree based on a few criterias:
// 1. The directory has a BUILD or BUILD.bazel files. Then
// it doesn't matter at all what it has since it's a
// separate Bazel package.
// 2. (only for fine-grained generation) The directory has
// an __init__.py, __main__.py or __test__.py, meaning
// a BUILD file will be generated.
if isBazelPackage(path) {
boundaryPackages[path] = struct{}{}
return nil
}
if !cfg.CoarseGrainedGeneration() && hasEntrypointFile(path) {
return fs.SkipDir
}
return nil
}
if filepath.Ext(path) == ".py" {
if cfg.CoarseGrainedGeneration() || !isEntrypointFile(path) {
srcPath, _ := filepath.Rel(args.Dir, path)
repoPath := filepath.Join(args.Rel, srcPath)
excludedPatterns := cfg.ExcludedPatterns()
if excludedPatterns != nil {
it := excludedPatterns.Iterator()
for it.Next() {
excludedPattern := it.Value().(string)
isExcluded, err := doublestar.Match(excludedPattern, repoPath)
if err != nil {
return err
}
if isExcluded {
return nil
}
}
}
baseName := filepath.Base(path)
if strings.HasSuffix(baseName, "_test.py") || strings.HasPrefix(baseName, "test_") {
pyTestFilenames.Add(srcPath)
} else {
pyLibraryFilenames.Add(srcPath)
}
}
}
return nil
},
)
if err != nil {
log.Printf("ERROR: %v\n", err)
return language.GenerateResult{}
}
}
parser := newPython3Parser(args.Config.RepoRoot, args.Rel, cfg.IgnoresDependency)
visibility := fmt.Sprintf("//%s:__subpackages__", pythonProjectRoot)
var result language.GenerateResult
result.Gen = make([]*rule.Rule, 0)
collisionErrors := singlylinkedlist.New()
var pyLibrary *rule.Rule
if !pyLibraryFilenames.Empty() {
deps, err := parser.parse(pyLibraryFilenames)
if err != nil {
log.Fatalf("ERROR: %v\n", err)
}
pyLibraryTargetName := cfg.RenderLibraryName(packageName)
// Check if a target with the same name we are generating already
// exists, and if it is of a different kind from the one we are
// generating. If so, we have to throw an error since Gazelle won't
// generate it correctly.
if args.File != nil {
for _, t := range args.File.Rules {
if t.Name() == pyLibraryTargetName && t.Kind() != actualPyLibraryKind {
fqTarget := label.New("", args.Rel, pyLibraryTargetName)
err := fmt.Errorf("failed to generate target %q of kind %q: "+
"a target of kind %q with the same name already exists. "+
"Use the '# gazelle:%s' directive to change the naming convention.",
fqTarget.String(), actualPyLibraryKind, t.Kind(), pythonconfig.LibraryNamingConvention)
collisionErrors.Add(err)
}
}
}
pyLibrary = newTargetBuilder(pyLibraryKind, pyLibraryTargetName, pythonProjectRoot, args.Rel, pyFileNames).
addVisibility(visibility).
addSrcs(pyLibraryFilenames).
addModuleDependencies(deps).
generateImportsAttribute().
build()
result.Gen = append(result.Gen, pyLibrary)
result.Imports = append(result.Imports, pyLibrary.PrivateAttr(config.GazelleImportsKey))
}
if hasPyBinary {
deps, err := parser.parseSingle(pyBinaryEntrypointFilename)
if err != nil {
log.Fatalf("ERROR: %v\n", err)
}
pyBinaryTargetName := cfg.RenderBinaryName(packageName)
// Check if a target with the same name we are generating already
// exists, and if it is of a different kind from the one we are
// generating. If so, we have to throw an error since Gazelle won't
// generate it correctly.
if args.File != nil {
for _, t := range args.File.Rules {
if t.Name() == pyBinaryTargetName && t.Kind() != actualPyBinaryKind {
fqTarget := label.New("", args.Rel, pyBinaryTargetName)
err := fmt.Errorf("failed to generate target %q of kind %q: "+
"a target of kind %q with the same name already exists. "+
"Use the '# gazelle:%s' directive to change the naming convention.",
fqTarget.String(), actualPyBinaryKind, t.Kind(), pythonconfig.BinaryNamingConvention)
collisionErrors.Add(err)
}
}
}
pyBinaryTarget := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel, pyFileNames).
setMain(pyBinaryEntrypointFilename).
addVisibility(visibility).
addSrc(pyBinaryEntrypointFilename).
addModuleDependencies(deps).
generateImportsAttribute()
pyBinary := pyBinaryTarget.build()
result.Gen = append(result.Gen, pyBinary)
result.Imports = append(result.Imports, pyBinary.PrivateAttr(config.GazelleImportsKey))
}
var conftest *rule.Rule
if hasConftestFile {
deps, err := parser.parseSingle(conftestFilename)
if err != nil {
log.Fatalf("ERROR: %v\n", err)
}
// Check if a target with the same name we are generating already
// exists, and if it is of a different kind from the one we are
// generating. If so, we have to throw an error since Gazelle won't
// generate it correctly.
if args.File != nil {
for _, t := range args.File.Rules {
if t.Name() == conftestTargetname && t.Kind() != actualPyLibraryKind {
fqTarget := label.New("", args.Rel, conftestTargetname)
err := fmt.Errorf("failed to generate target %q of kind %q: "+
"a target of kind %q with the same name already exists.",
fqTarget.String(), actualPyLibraryKind, t.Kind())
collisionErrors.Add(err)
}
}
}
conftestTarget := newTargetBuilder(pyLibraryKind, conftestTargetname, pythonProjectRoot, args.Rel, pyFileNames).
addSrc(conftestFilename).
addModuleDependencies(deps).
addVisibility(visibility).
setTestonly().
generateImportsAttribute()
conftest = conftestTarget.build()
result.Gen = append(result.Gen, conftest)
result.Imports = append(result.Imports, conftest.PrivateAttr(config.GazelleImportsKey))
}
var pyTestTargets []*targetBuilder
newPyTestTargetBuilder := func(srcs *treeset.Set, pyTestTargetName string) *targetBuilder {
deps, err := parser.parse(srcs)
if err != nil {
log.Fatalf("ERROR: %v\n", err)
}
// Check if a target with the same name we are generating already
// exists, and if it is of a different kind from the one we are
// generating. If so, we have to throw an error since Gazelle won't
// generate it correctly.
if args.File != nil {
for _, t := range args.File.Rules {
if t.Name() == pyTestTargetName && t.Kind() != actualPyTestKind {
fqTarget := label.New("", args.Rel, pyTestTargetName)
err := fmt.Errorf("failed to generate target %q of kind %q: "+
"a target of kind %q with the same name already exists. "+
"Use the '# gazelle:%s' directive to change the naming convention.",
fqTarget.String(), actualPyTestKind, t.Kind(), pythonconfig.TestNamingConvention)
collisionErrors.Add(err)
}
}
}
return newTargetBuilder(pyTestKind, pyTestTargetName, pythonProjectRoot, args.Rel, pyFileNames).
addSrcs(srcs).
addModuleDependencies(deps).
generateImportsAttribute()
}
if hasPyTestEntryPointFile || hasPyTestEntryPointTarget {
if hasPyTestEntryPointFile {
// Only add the pyTestEntrypointFilename to the pyTestFilenames if
// the file exists on disk.
pyTestFilenames.Add(pyTestEntrypointFilename)
}
pyTestTargetName := cfg.RenderTestName(packageName)
pyTestTarget := newPyTestTargetBuilder(pyTestFilenames, pyTestTargetName)
if hasPyTestEntryPointTarget {
entrypointTarget := fmt.Sprintf(":%s", pyTestEntrypointTargetname)
main := fmt.Sprintf(":%s", pyTestEntrypointFilename)
pyTestTarget.
addSrc(entrypointTarget).
addResolvedDependency(entrypointTarget).
setMain(main)
} else {
pyTestTarget.setMain(pyTestEntrypointFilename)
}
pyTestTargets = append(pyTestTargets, pyTestTarget)
} else {
// Create one py_test target per file
pyTestFilenames.Each(func(index int, testFile interface{}) {
srcs := treeset.NewWith(godsutils.StringComparator, testFile)
pyTestTargetName := strings.TrimSuffix(filepath.Base(testFile.(string)), ".py")
pyTestTargets = append(pyTestTargets, newPyTestTargetBuilder(srcs, pyTestTargetName))
})
}
for _, pyTestTarget := range pyTestTargets {
if conftest != nil {
pyTestTarget.addModuleDependency(module{Name: strings.TrimSuffix(conftestFilename, ".py")})
}
pyTest := pyTestTarget.build()
result.Gen = append(result.Gen, pyTest)
result.Imports = append(result.Imports, pyTest.PrivateAttr(config.GazelleImportsKey))
}
if !collisionErrors.Empty() {
it := collisionErrors.Iterator()
for it.Next() {
log.Printf("ERROR: %v\n", it.Value())
}
os.Exit(1)
}
return result
}
// isBazelPackage determines if the directory is a Bazel package by probing for
// the existence of a known BUILD file name.
func isBazelPackage(dir string) bool {
for _, buildFilename := range buildFilenames {
path := filepath.Join(dir, buildFilename)
if _, err := os.Stat(path); err == nil {
return true
}
}
return false
}
// hasEntrypointFile determines if the directory has any of the established
// entrypoint filenames.
func hasEntrypointFile(dir string) bool {
for _, entrypointFilename := range []string{
pyLibraryEntrypointFilename,
pyBinaryEntrypointFilename,
pyTestEntrypointFilename,
} {
path := filepath.Join(dir, entrypointFilename)
if _, err := os.Stat(path); err == nil {
return true
}
}
return false
}
// isEntrypointFile returns whether the given path is an entrypoint file. The
// given path can be absolute or relative.
func isEntrypointFile(path string) bool {
basePath := filepath.Base(path)
switch basePath {
case pyLibraryEntrypointFilename,
pyBinaryEntrypointFilename,
pyTestEntrypointFilename:
return true
default:
return false
}
}
rules_python-0.22.1/gazelle/python/kinds.go 0000664 0000000 0000000 00000004606 14540404546 0020746 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"github.com/bazelbuild/bazel-gazelle/rule"
)
const (
pyBinaryKind = "py_binary"
pyLibraryKind = "py_library"
pyTestKind = "py_test"
)
// Kinds returns a map that maps rule names (kinds) and information on how to
// match and merge attributes that may be found in rules of those kinds.
func (*Python) Kinds() map[string]rule.KindInfo {
return pyKinds
}
var pyKinds = map[string]rule.KindInfo{
pyBinaryKind: {
MatchAny: true,
NonEmptyAttrs: map[string]bool{
"deps": true,
"main": true,
"srcs": true,
"imports": true,
"visibility": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": true,
},
},
pyLibraryKind: {
MatchAny: true,
NonEmptyAttrs: map[string]bool{
"deps": true,
"srcs": true,
"imports": true,
"visibility": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": true,
},
},
pyTestKind: {
MatchAny: false,
NonEmptyAttrs: map[string]bool{
"deps": true,
"main": true,
"srcs": true,
"imports": true,
"visibility": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": true,
},
},
}
// Loads returns .bzl files and symbols they define. Every rule generated by
// GenerateRules, now or in the past, should be loadable from one of these
// files.
func (py *Python) Loads() []rule.LoadInfo {
return pyLoads
}
var pyLoads = []rule.LoadInfo{
{
Name: "@rules_python//python:defs.bzl",
Symbols: []string{
pyBinaryKind,
pyLibraryKind,
pyTestKind,
},
},
}
rules_python-0.22.1/gazelle/python/language.go 0000664 0000000 0000000 00000002030 14540404546 0021406 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"github.com/bazelbuild/bazel-gazelle/language"
)
// Python satisfies the language.Language interface. It is the Gazelle extension
// for Python rules.
type Python struct {
Configurer
Resolver
}
// NewLanguage initializes a new Python that satisfies the language.Language
// interface. This is the entrypoint for the extension initialization.
func NewLanguage() language.Language {
return &Python{}
}
rules_python-0.22.1/gazelle/python/parse.py 0000664 0000000 0000000 00000007476 14540404546 0021003 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# parse.py is a long-living program that communicates over STDIN and STDOUT.
# STDIN receives parse requests, one per line. It outputs the parsed modules and
# comments from all the files from each request.
import ast
import concurrent.futures
import json
import os
import sys
from io import BytesIO
from tokenize import COMMENT, tokenize
def parse_import_statements(content, filepath):
modules = list()
tree = ast.parse(content, filename=filepath)
for node in ast.walk(tree):
if isinstance(node, ast.Import):
for subnode in node.names:
module = {
"name": subnode.name,
"lineno": node.lineno,
"filepath": filepath,
"from": "",
}
modules.append(module)
elif isinstance(node, ast.ImportFrom) and node.level == 0:
for subnode in node.names:
module = {
"name": f"{node.module}.{subnode.name}",
"lineno": node.lineno,
"filepath": filepath,
"from": node.module,
}
modules.append(module)
return modules
def parse_comments(content):
comments = list()
g = tokenize(BytesIO(content.encode("utf-8")).readline)
for toknum, tokval, _, _, _ in g:
if toknum == COMMENT:
comments.append(tokval)
return comments
def parse(repo_root, rel_package_path, filename):
rel_filepath = os.path.join(rel_package_path, filename)
abs_filepath = os.path.join(repo_root, rel_filepath)
with open(abs_filepath, "r") as file:
content = file.read()
# From simple benchmarks, 2 workers gave the best performance here.
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
modules_future = executor.submit(
parse_import_statements, content, rel_filepath
)
comments_future = executor.submit(parse_comments, content)
modules = modules_future.result()
comments = comments_future.result()
output = {
"modules": modules,
"comments": comments,
}
return output
def main(stdin, stdout):
with concurrent.futures.ProcessPoolExecutor() as executor:
for parse_request in stdin:
parse_request = json.loads(parse_request)
repo_root = parse_request["repo_root"]
rel_package_path = parse_request["rel_package_path"]
filenames = parse_request["filenames"]
outputs = list()
if len(filenames) == 1:
outputs.append(parse(repo_root, rel_package_path, filenames[0]))
else:
futures = [
executor.submit(parse, repo_root, rel_package_path, filename)
for filename in filenames
if filename != ""
]
for future in concurrent.futures.as_completed(futures):
outputs.append(future.result())
print(json.dumps(outputs), end="", file=stdout, flush=True)
stdout.buffer.write(bytes([0]))
stdout.flush()
if __name__ == "__main__":
exit(main(sys.stdin, sys.stdout))
rules_python-0.22.1/gazelle/python/parser.go 0000664 0000000 0000000 00000017233 14540404546 0021132 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"bufio"
"context"
"encoding/json"
"fmt"
"io"
"log"
"os"
"os/exec"
"strings"
"sync"
"time"
"github.com/bazelbuild/rules_go/go/tools/bazel"
"github.com/emirpasic/gods/sets/treeset"
godsutils "github.com/emirpasic/gods/utils"
)
var (
parserStdin io.Writer
parserStdout io.Reader
parserMutex sync.Mutex
)
func init() {
parseScriptRunfile, err := bazel.Runfile("python/parse")
if err != nil {
log.Printf("failed to initialize parser: %v\n", err)
os.Exit(1)
}
ctx := context.Background()
ctx, parserCancel := context.WithTimeout(ctx, time.Minute*10)
cmd := exec.CommandContext(ctx, parseScriptRunfile)
cmd.Stderr = os.Stderr
stdin, err := cmd.StdinPipe()
if err != nil {
log.Printf("failed to initialize parser: %v\n", err)
os.Exit(1)
}
parserStdin = stdin
stdout, err := cmd.StdoutPipe()
if err != nil {
log.Printf("failed to initialize parser: %v\n", err)
os.Exit(1)
}
parserStdout = stdout
if err := cmd.Start(); err != nil {
log.Printf("failed to initialize parser: %v\n", err)
os.Exit(1)
}
go func() {
defer parserCancel()
if err := cmd.Wait(); err != nil {
log.Printf("failed to wait for parser: %v\n", err)
os.Exit(1)
}
}()
}
// python3Parser implements a parser for Python files that extracts the modules
// as seen in the import statements.
type python3Parser struct {
// The value of language.GenerateArgs.Config.RepoRoot.
repoRoot string
// The value of language.GenerateArgs.Rel.
relPackagePath string
// The function that determines if a dependency is ignored from a Gazelle
// directive. It's the signature of pythonconfig.Config.IgnoresDependency.
ignoresDependency func(dep string) bool
}
// newPython3Parser constructs a new python3Parser.
func newPython3Parser(
repoRoot string,
relPackagePath string,
ignoresDependency func(dep string) bool,
) *python3Parser {
return &python3Parser{
repoRoot: repoRoot,
relPackagePath: relPackagePath,
ignoresDependency: ignoresDependency,
}
}
// parseSingle parses a single Python file and returns the extracted modules
// from the import statements as well as the parsed comments.
func (p *python3Parser) parseSingle(pyFilename string) (*treeset.Set, error) {
pyFilenames := treeset.NewWith(godsutils.StringComparator)
pyFilenames.Add(pyFilename)
return p.parse(pyFilenames)
}
// parse parses multiple Python files and returns the extracted modules from
// the import statements as well as the parsed comments.
func (p *python3Parser) parse(pyFilenames *treeset.Set) (*treeset.Set, error) {
parserMutex.Lock()
defer parserMutex.Unlock()
modules := treeset.NewWith(moduleComparator)
req := map[string]interface{}{
"repo_root": p.repoRoot,
"rel_package_path": p.relPackagePath,
"filenames": pyFilenames.Values(),
}
encoder := json.NewEncoder(parserStdin)
if err := encoder.Encode(&req); err != nil {
return nil, fmt.Errorf("failed to parse: %w", err)
}
reader := bufio.NewReader(parserStdout)
data, err := reader.ReadBytes(0)
if err != nil {
return nil, fmt.Errorf("failed to parse: %w", err)
}
data = data[:len(data)-1]
var allRes []parserResponse
if err := json.Unmarshal(data, &allRes); err != nil {
return nil, fmt.Errorf("failed to parse: %w", err)
}
for _, res := range allRes {
annotations, err := annotationsFromComments(res.Comments)
if err != nil {
return nil, fmt.Errorf("failed to parse annotations: %w", err)
}
for _, m := range res.Modules {
// Check for ignored dependencies set via an annotation to the Python
// module.
if annotations.ignores(m.Name) || annotations.ignores(m.From) {
continue
}
// Check for ignored dependencies set via a Gazelle directive in a BUILD
// file.
if p.ignoresDependency(m.Name) || p.ignoresDependency(m.From) {
continue
}
modules.Add(m)
}
}
return modules, nil
}
// parserResponse represents a response returned by the parser.py for a given
// parsed Python module.
type parserResponse struct {
// The modules depended by the parsed module.
Modules []module `json:"modules"`
// The comments contained in the parsed module. This contains the
// annotations as they are comments in the Python module.
Comments []comment `json:"comments"`
}
// module represents a fully-qualified, dot-separated, Python module as seen on
// the import statement, alongside the line number where it happened.
type module struct {
// The fully-qualified, dot-separated, Python module name as seen on import
// statements.
Name string `json:"name"`
// The line number where the import happened.
LineNumber uint32 `json:"lineno"`
// The path to the module file relative to the Bazel workspace root.
Filepath string `json:"filepath"`
// If this was a from import, e.g. from foo import bar, From indicates the module
// from which it is imported.
From string `json:"from"`
}
// moduleComparator compares modules by name.
func moduleComparator(a, b interface{}) int {
return godsutils.StringComparator(a.(module).Name, b.(module).Name)
}
// annotationKind represents Gazelle annotation kinds.
type annotationKind string
const (
// The Gazelle annotation prefix.
annotationPrefix string = "gazelle:"
// The ignore annotation kind. E.g. '# gazelle:ignore '.
annotationKindIgnore annotationKind = "ignore"
)
// comment represents a Python comment.
type comment string
// asAnnotation returns an annotation object if the comment has the
// annotationPrefix.
func (c *comment) asAnnotation() (*annotation, error) {
uncomment := strings.TrimLeft(string(*c), "# ")
if !strings.HasPrefix(uncomment, annotationPrefix) {
return nil, nil
}
withoutPrefix := strings.TrimPrefix(uncomment, annotationPrefix)
annotationParts := strings.SplitN(withoutPrefix, " ", 2)
if len(annotationParts) < 2 {
return nil, fmt.Errorf("`%s` requires a value", *c)
}
return &annotation{
kind: annotationKind(annotationParts[0]),
value: annotationParts[1],
}, nil
}
// annotation represents a single Gazelle annotation parsed from a Python
// comment.
type annotation struct {
kind annotationKind
value string
}
// annotations represent the collection of all Gazelle annotations parsed out of
// the comments of a Python module.
type annotations struct {
// The parsed modules to be ignored by Gazelle.
ignore map[string]struct{}
}
// annotationsFromComments returns all the annotations parsed out of the
// comments of a Python module.
func annotationsFromComments(comments []comment) (*annotations, error) {
ignore := make(map[string]struct{})
for _, comment := range comments {
annotation, err := comment.asAnnotation()
if err != nil {
return nil, err
}
if annotation != nil {
if annotation.kind == annotationKindIgnore {
modules := strings.Split(annotation.value, ",")
for _, m := range modules {
if m == "" {
continue
}
m = strings.TrimSpace(m)
ignore[m] = struct{}{}
}
}
}
}
return &annotations{
ignore: ignore,
}, nil
}
// ignored returns true if the given module was ignored via the ignore
// annotation.
func (a *annotations) ignores(module string) bool {
_, ignores := a.ignore[module]
return ignores
}
rules_python-0.22.1/gazelle/python/python_test.go 0000664 0000000 0000000 00000012571 14540404546 0022216 0 ustar 00root root 0000000 0000000 /* Copyright 2020 The Bazel Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This test file was first seen on:
// https://github.com/bazelbuild/bazel-skylib/blob/f80bc733d4b9f83d427ce3442be2e07427b2cc8d/gazelle/bzl/BUILD.
// It was modified for the needs of this extension.
package python_test
import (
"bytes"
"context"
"errors"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"
"github.com/bazelbuild/bazel-gazelle/testtools"
"github.com/bazelbuild/rules_go/go/tools/bazel"
"github.com/ghodss/yaml"
)
const (
extensionDir = "python" + string(os.PathSeparator)
testDataPath = extensionDir + "testdata" + string(os.PathSeparator)
gazelleBinaryName = "gazelle_binary"
)
var gazellePath = mustFindGazelle()
func TestGazelleBinary(t *testing.T) {
tests := map[string][]bazel.RunfileEntry{}
runfiles, err := bazel.ListRunfiles()
if err != nil {
t.Fatalf("bazel.ListRunfiles() error: %v", err)
}
for _, f := range runfiles {
if strings.HasPrefix(f.ShortPath, testDataPath) {
relativePath := strings.TrimPrefix(f.ShortPath, testDataPath)
parts := strings.SplitN(relativePath, string(os.PathSeparator), 2)
if len(parts) < 2 {
// This file is not a part of a testcase since it must be in a dir that
// is the test case and then have a path inside of that.
continue
}
tests[parts[0]] = append(tests[parts[0]], f)
}
}
if len(tests) == 0 {
t.Fatal("no tests found")
}
for testName, files := range tests {
testPath(t, testName, files)
}
}
func testPath(t *testing.T, name string, files []bazel.RunfileEntry) {
t.Run(name, func(t *testing.T) {
t.Parallel()
var inputs, goldens []testtools.FileSpec
var config *testYAML
for _, f := range files {
path := f.Path
trim := filepath.Join(testDataPath, name) + string(os.PathSeparator)
shortPath := strings.TrimPrefix(f.ShortPath, trim)
info, err := os.Stat(path)
if err != nil {
t.Fatalf("os.Stat(%q) error: %v", path, err)
}
if info.IsDir() {
continue
}
content, err := os.ReadFile(path)
if err != nil {
t.Errorf("os.ReadFile(%q) error: %v", path, err)
}
if filepath.Base(shortPath) == "test.yaml" {
if config != nil {
t.Fatal("only 1 test.yaml is supported")
}
config = new(testYAML)
if err := yaml.Unmarshal(content, config); err != nil {
t.Fatal(err)
}
}
if strings.HasSuffix(shortPath, ".in") {
inputs = append(inputs, testtools.FileSpec{
Path: filepath.Join(name, strings.TrimSuffix(shortPath, ".in")),
Content: string(content),
})
continue
}
if strings.HasSuffix(shortPath, ".out") {
goldens = append(goldens, testtools.FileSpec{
Path: filepath.Join(name, strings.TrimSuffix(shortPath, ".out")),
Content: string(content),
})
continue
}
inputs = append(inputs, testtools.FileSpec{
Path: filepath.Join(name, shortPath),
Content: string(content),
})
goldens = append(goldens, testtools.FileSpec{
Path: filepath.Join(name, shortPath),
Content: string(content),
})
}
testdataDir, cleanup := testtools.CreateFiles(t, inputs)
t.Cleanup(cleanup)
t.Cleanup(func() {
if !t.Failed() {
return
}
filepath.Walk(testdataDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
t.Logf("%q exists", strings.TrimPrefix(path, testdataDir))
return nil
})
})
workspaceRoot := filepath.Join(testdataDir, name)
args := []string{"-build_file_name=BUILD,BUILD.bazel"}
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
t.Cleanup(cancel)
cmd := exec.CommandContext(ctx, gazellePath, args...)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Dir = workspaceRoot
if err := cmd.Run(); err != nil {
var e *exec.ExitError
if !errors.As(err, &e) {
t.Fatal(err)
}
}
actualExitCode := cmd.ProcessState.ExitCode()
if config.Expect.ExitCode != actualExitCode {
t.Errorf("expected gazelle exit code: %d\ngot: %d",
config.Expect.ExitCode, actualExitCode)
}
actualStdout := stdout.String()
if strings.TrimSpace(config.Expect.Stdout) != strings.TrimSpace(actualStdout) {
t.Errorf("expected gazelle stdout: %s\ngot: %s",
config.Expect.Stdout, actualStdout)
}
actualStderr := stderr.String()
if strings.TrimSpace(config.Expect.Stderr) != strings.TrimSpace(actualStderr) {
t.Errorf("expected gazelle stderr: %s\ngot: %s",
config.Expect.Stderr, actualStderr)
}
if t.Failed() {
t.FailNow()
}
testtools.CheckFiles(t, testdataDir, goldens)
})
}
func mustFindGazelle() string {
gazellePath, ok := bazel.FindBinary(extensionDir, gazelleBinaryName)
if !ok {
panic("could not find gazelle binary")
}
return gazellePath
}
type testYAML struct {
Expect struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
} `json:"expect"`
}
rules_python-0.22.1/gazelle/python/resolve.go 0000664 0000000 0000000 00000025627 14540404546 0021323 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/label"
"github.com/bazelbuild/bazel-gazelle/repo"
"github.com/bazelbuild/bazel-gazelle/resolve"
"github.com/bazelbuild/bazel-gazelle/rule"
bzl "github.com/bazelbuild/buildtools/build"
"github.com/emirpasic/gods/sets/treeset"
godsutils "github.com/emirpasic/gods/utils"
"github.com/bazelbuild/rules_python/gazelle/pythonconfig"
)
const languageName = "py"
const (
// resolvedDepsKey is the attribute key used to pass dependencies that don't
// need to be resolved by the dependency resolver in the Resolver step.
resolvedDepsKey = "_gazelle_python_resolved_deps"
)
// Resolver satisfies the resolve.Resolver interface. It resolves dependencies
// in rules generated by this extension.
type Resolver struct{}
// Name returns the name of the language. This is the prefix of the kinds of
// rules generated. E.g. py_library and py_binary.
func (*Resolver) Name() string { return languageName }
// Imports returns a list of ImportSpecs that can be used to import the rule
// r. This is used to populate RuleIndex.
//
// If nil is returned, the rule will not be indexed. If any non-nil slice is
// returned, including an empty slice, the rule will be indexed.
func (py *Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec {
cfgs := c.Exts[languageName].(pythonconfig.Configs)
cfg := cfgs[f.Pkg]
srcs := r.AttrStrings("srcs")
provides := make([]resolve.ImportSpec, 0, len(srcs)+1)
for _, src := range srcs {
ext := filepath.Ext(src)
if ext == ".py" {
pythonProjectRoot := cfg.PythonProjectRoot()
provide := importSpecFromSrc(pythonProjectRoot, f.Pkg, src)
provides = append(provides, provide)
}
}
if len(provides) == 0 {
return nil
}
return provides
}
// importSpecFromSrc determines the ImportSpec based on the target that contains the src so that
// the target can be indexed for import statements that match the calculated src relative to the its
// Python project root.
func importSpecFromSrc(pythonProjectRoot, bzlPkg, src string) resolve.ImportSpec {
pythonPkgDir := filepath.Join(bzlPkg, filepath.Dir(src))
relPythonPkgDir, err := filepath.Rel(pythonProjectRoot, pythonPkgDir)
if err != nil {
panic(fmt.Errorf("unexpected failure: %v", err))
}
if relPythonPkgDir == "." {
relPythonPkgDir = ""
}
pythonPkg := strings.ReplaceAll(relPythonPkgDir, "/", ".")
filename := filepath.Base(src)
if filename == pyLibraryEntrypointFilename {
if pythonPkg != "" {
return resolve.ImportSpec{
Lang: languageName,
Imp: pythonPkg,
}
}
}
moduleName := strings.TrimSuffix(filename, ".py")
var imp string
if pythonPkg == "" {
imp = moduleName
} else {
imp = fmt.Sprintf("%s.%s", pythonPkg, moduleName)
}
return resolve.ImportSpec{
Lang: languageName,
Imp: imp,
}
}
// Embeds returns a list of labels of rules that the given rule embeds. If
// a rule is embedded by another importable rule of the same language, only
// the embedding rule will be indexed. The embedding rule will inherit
// the imports of the embedded rule.
func (py *Resolver) Embeds(r *rule.Rule, from label.Label) []label.Label {
// TODO(f0rmiga): implement.
return make([]label.Label, 0)
}
// Resolve translates imported libraries for a given rule into Bazel
// dependencies. Information about imported libraries is returned for each
// rule generated by language.GenerateRules in
// language.GenerateResult.Imports. Resolve generates a "deps" attribute (or
// the appropriate language-specific equivalent) for each import according to
// language-specific rules and heuristics.
func (py *Resolver) Resolve(
c *config.Config,
ix *resolve.RuleIndex,
rc *repo.RemoteCache,
r *rule.Rule,
modulesRaw interface{},
from label.Label,
) {
// TODO(f0rmiga): may need to be defensive here once this Gazelle extension
// join with the main Gazelle binary with other rules. It may conflict with
// other generators that generate py_* targets.
deps := treeset.NewWith(godsutils.StringComparator)
if modulesRaw != nil {
cfgs := c.Exts[languageName].(pythonconfig.Configs)
cfg := cfgs[from.Pkg]
pythonProjectRoot := cfg.PythonProjectRoot()
modules := modulesRaw.(*treeset.Set)
it := modules.Iterator()
explainDependency := os.Getenv("EXPLAIN_DEPENDENCY")
hasFatalError := false
MODULES_LOOP:
for it.Next() {
mod := it.Value().(module)
moduleParts := strings.Split(mod.Name, ".")
possibleModules := []string{mod.Name}
for len(moduleParts) > 1 {
// Iterate back through the possible imports until
// a match is found.
// For example, "from foo.bar import baz" where bar is a variable, we should try
// `foo.bar.baz` first, then `foo.bar`, then `foo`. In the first case, the import could be file `baz.py`
// in the directory `foo/bar`.
// Or, the import could be variable `bar` in file `foo/bar.py`.
// The import could also be from a standard module, e.g. `six.moves`, where
// the dependency is actually `six`.
moduleParts = moduleParts[:len(moduleParts)-1]
possibleModules = append(possibleModules, strings.Join(moduleParts, "."))
}
errs := []error{}
POSSIBLE_MODULE_LOOP:
for _, moduleName := range possibleModules {
imp := resolve.ImportSpec{Lang: languageName, Imp: moduleName}
if override, ok := resolve.FindRuleWithOverride(c, imp, languageName); ok {
if override.Repo == "" {
override.Repo = from.Repo
}
if !override.Equal(from) {
if override.Repo == from.Repo {
override.Repo = ""
}
dep := override.String()
deps.Add(dep)
if explainDependency == dep {
log.Printf("Explaining dependency (%s): "+
"in the target %q, the file %q imports %q at line %d, "+
"which resolves using the \"gazelle:resolve\" directive.\n",
explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber)
}
continue MODULES_LOOP
}
} else {
if dep, ok := cfg.FindThirdPartyDependency(moduleName); ok {
deps.Add(dep)
if explainDependency == dep {
log.Printf("Explaining dependency (%s): "+
"in the target %q, the file %q imports %q at line %d, "+
"which resolves from the third-party module %q from the wheel %q.\n",
explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber, mod.Name, dep)
}
continue MODULES_LOOP
} else {
matches := ix.FindRulesByImportWithConfig(c, imp, languageName)
if len(matches) == 0 {
// Check if the imported module is part of the standard library.
if isStd, err := isStdModule(module{Name: moduleName}); err != nil {
log.Println("Error checking if standard module: ", err)
hasFatalError = true
continue POSSIBLE_MODULE_LOOP
} else if isStd {
continue MODULES_LOOP
} else if cfg.ValidateImportStatements() {
err := fmt.Errorf(
"%[1]q at line %[2]d from %[3]q is an invalid dependency: possible solutions:\n"+
"\t1. Add it as a dependency in the requirements.txt file.\n"+
"\t2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.\n"+
"\t3. Ignore it with a comment '# gazelle:ignore %[1]s' in the Python file.\n",
moduleName, mod.LineNumber, mod.Filepath,
)
errs = append(errs, err)
continue POSSIBLE_MODULE_LOOP
}
}
filteredMatches := make([]resolve.FindResult, 0, len(matches))
for _, match := range matches {
if match.IsSelfImport(from) {
// Prevent from adding itself as a dependency.
continue MODULES_LOOP
}
filteredMatches = append(filteredMatches, match)
}
if len(filteredMatches) == 0 {
continue POSSIBLE_MODULE_LOOP
}
if len(filteredMatches) > 1 {
sameRootMatches := make([]resolve.FindResult, 0, len(filteredMatches))
for _, match := range filteredMatches {
if strings.HasPrefix(match.Label.Pkg, pythonProjectRoot) {
sameRootMatches = append(sameRootMatches, match)
}
}
if len(sameRootMatches) != 1 {
err := fmt.Errorf(
"multiple targets (%s) may be imported with %q at line %d in %q "+
"- this must be fixed using the \"gazelle:resolve\" directive",
targetListFromResults(filteredMatches), moduleName, mod.LineNumber, mod.Filepath)
errs = append(errs, err)
continue POSSIBLE_MODULE_LOOP
}
filteredMatches = sameRootMatches
}
matchLabel := filteredMatches[0].Label.Rel(from.Repo, from.Pkg)
dep := matchLabel.String()
deps.Add(dep)
if explainDependency == dep {
log.Printf("Explaining dependency (%s): "+
"in the target %q, the file %q imports %q at line %d, "+
"which resolves from the first-party indexed labels.\n",
explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber)
}
continue MODULES_LOOP
}
}
} // End possible modules loop.
if len(errs) > 0 {
// If, after trying all possible modules, we still haven't found anything, error out.
joinedErrs := ""
for _, err := range errs {
joinedErrs = fmt.Sprintf("%s%s\n", joinedErrs, err)
}
log.Printf("ERROR: failed to validate dependencies for target %q: %v\n", from.String(), joinedErrs)
hasFatalError = true
}
}
if hasFatalError {
os.Exit(1)
}
}
resolvedDeps := r.PrivateAttr(resolvedDepsKey).(*treeset.Set)
if !resolvedDeps.Empty() {
it := resolvedDeps.Iterator()
for it.Next() {
deps.Add(it.Value())
}
}
if !deps.Empty() {
r.SetAttr("deps", convertDependencySetToExpr(deps))
}
}
// targetListFromResults returns a string with the human-readable list of
// targets contained in the given results.
func targetListFromResults(results []resolve.FindResult) string {
list := make([]string, len(results))
for i, result := range results {
list[i] = result.Label.String()
}
return strings.Join(list, ", ")
}
// convertDependencySetToExpr converts the given set of dependencies to an
// expression to be used in the deps attribute.
func convertDependencySetToExpr(set *treeset.Set) bzl.Expr {
deps := make([]bzl.Expr, set.Size())
it := set.Iterator()
for it.Next() {
dep := it.Value().(string)
deps[it.Index()] = &bzl.StringExpr{Value: dep}
}
return &bzl.ListExpr{List: deps}
}
rules_python-0.22.1/gazelle/python/std_modules.go 0000664 0000000 0000000 00000005111 14540404546 0022150 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"bufio"
"context"
"fmt"
"io"
"log"
"os"
"os/exec"
"strconv"
"strings"
"sync"
"time"
"github.com/bazelbuild/rules_go/go/tools/bazel"
)
var (
stdModulesStdin io.Writer
stdModulesStdout io.Reader
stdModulesMutex sync.Mutex
stdModulesSeen map[string]struct{}
)
func init() {
stdModulesSeen = make(map[string]struct{})
stdModulesScriptRunfile, err := bazel.Runfile("python/std_modules")
if err != nil {
log.Printf("failed to initialize std_modules: %v\n", err)
os.Exit(1)
}
ctx := context.Background()
ctx, stdModulesCancel := context.WithTimeout(ctx, time.Minute*10)
cmd := exec.CommandContext(ctx, stdModulesScriptRunfile)
cmd.Stderr = os.Stderr
// All userland site-packages should be ignored.
cmd.Env = []string{"PYTHONNOUSERSITE=1"}
stdin, err := cmd.StdinPipe()
if err != nil {
log.Printf("failed to initialize std_modules: %v\n", err)
os.Exit(1)
}
stdModulesStdin = stdin
stdout, err := cmd.StdoutPipe()
if err != nil {
log.Printf("failed to initialize std_modules: %v\n", err)
os.Exit(1)
}
stdModulesStdout = stdout
if err := cmd.Start(); err != nil {
log.Printf("failed to initialize std_modules: %v\n", err)
os.Exit(1)
}
go func() {
defer stdModulesCancel()
if err := cmd.Wait(); err != nil {
log.Printf("failed to wait for std_modules: %v\n", err)
os.Exit(1)
}
}()
}
func isStdModule(m module) (bool, error) {
if _, seen := stdModulesSeen[m.Name]; seen {
return true, nil
}
stdModulesMutex.Lock()
defer stdModulesMutex.Unlock()
fmt.Fprintf(stdModulesStdin, "%s\n", m.Name)
stdoutReader := bufio.NewReader(stdModulesStdout)
line, err := stdoutReader.ReadString('\n')
if err != nil {
return false, err
}
if len(line) == 0 {
return false, fmt.Errorf("unexpected empty output from std_modules")
}
isStd, err := strconv.ParseBool(strings.TrimSpace(line))
if err != nil {
return false, err
}
if isStd {
stdModulesSeen[m.Name] = struct{}{}
return true, nil
}
return false, nil
}
rules_python-0.22.1/gazelle/python/std_modules.py 0000664 0000000 0000000 00000003365 14540404546 0022204 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# std_modules.py is a long-living program that communicates over STDIN and
# STDOUT. STDIN receives module names, one per line. For each module statement
# it evaluates, it outputs true/false for whether the module is part of the
# standard library or not.
import os
import sys
from contextlib import redirect_stdout
def is_std_modules(module):
# If for some reason a module (such as pygame, see https://github.com/pygame/pygame/issues/542)
# prints to stdout upon import,
# the output of this script should still be parseable by golang.
# Therefore, redirect stdout while running the import.
with redirect_stdout(os.devnull):
try:
__import__(module, globals(), locals(), [], 0)
return True
except Exception:
return False
def main(stdin, stdout):
for module in stdin:
module = module.strip()
# Don't print the boolean directly as it is capitalized in Python.
print(
"true" if is_std_modules(module) else "false",
end="\n",
file=stdout,
)
stdout.flush()
if __name__ == "__main__":
exit(main(sys.stdin, sys.stdout))
rules_python-0.22.1/gazelle/python/target.go 0000664 0000000 0000000 00000011323 14540404546 0021116 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package python
import (
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/emirpasic/gods/sets/treeset"
godsutils "github.com/emirpasic/gods/utils"
"path/filepath"
)
// targetBuilder builds targets to be generated by Gazelle.
type targetBuilder struct {
kind string
name string
pythonProjectRoot string
bzlPackage string
srcs *treeset.Set
siblingSrcs *treeset.Set
deps *treeset.Set
resolvedDeps *treeset.Set
visibility *treeset.Set
main *string
imports []string
testonly bool
}
// newTargetBuilder constructs a new targetBuilder.
func newTargetBuilder(kind, name, pythonProjectRoot, bzlPackage string, siblingSrcs *treeset.Set) *targetBuilder {
return &targetBuilder{
kind: kind,
name: name,
pythonProjectRoot: pythonProjectRoot,
bzlPackage: bzlPackage,
srcs: treeset.NewWith(godsutils.StringComparator),
siblingSrcs: siblingSrcs,
deps: treeset.NewWith(moduleComparator),
resolvedDeps: treeset.NewWith(godsutils.StringComparator),
visibility: treeset.NewWith(godsutils.StringComparator),
}
}
// addSrc adds a single src to the target.
func (t *targetBuilder) addSrc(src string) *targetBuilder {
t.srcs.Add(src)
return t
}
// addSrcs copies all values from the provided srcs to the target.
func (t *targetBuilder) addSrcs(srcs *treeset.Set) *targetBuilder {
it := srcs.Iterator()
for it.Next() {
t.srcs.Add(it.Value().(string))
}
return t
}
// addModuleDependency adds a single module dep to the target.
func (t *targetBuilder) addModuleDependency(dep module) *targetBuilder {
fileName := dep.Name + ".py"
if dep.From != "" {
fileName = dep.From + ".py"
}
if t.siblingSrcs.Contains(fileName) && fileName != filepath.Base(dep.Filepath) {
// importing another module from the same package, converting to absolute imports to make
// dependency resolution easier
dep.Name = importSpecFromSrc(t.pythonProjectRoot, t.bzlPackage, fileName).Imp
}
t.deps.Add(dep)
return t
}
// addModuleDependencies copies all values from the provided deps to the target.
func (t *targetBuilder) addModuleDependencies(deps *treeset.Set) *targetBuilder {
it := deps.Iterator()
for it.Next() {
t.addModuleDependency(it.Value().(module))
}
return t
}
// addResolvedDependency adds a single dependency the target that has already
// been resolved or generated. The Resolver step doesn't process it further.
func (t *targetBuilder) addResolvedDependency(dep string) *targetBuilder {
t.resolvedDeps.Add(dep)
return t
}
// addVisibility adds a visibility to the target.
func (t *targetBuilder) addVisibility(visibility string) *targetBuilder {
t.visibility.Add(visibility)
return t
}
// setMain sets the main file to the target.
func (t *targetBuilder) setMain(main string) *targetBuilder {
t.main = &main
return t
}
// setTestonly sets the testonly attribute to true.
func (t *targetBuilder) setTestonly() *targetBuilder {
t.testonly = true
return t
}
// generateImportsAttribute generates the imports attribute.
// These are a list of import directories to be added to the PYTHONPATH. In our
// case, the value we add is on Bazel sub-packages to be able to perform imports
// relative to the root project package.
func (t *targetBuilder) generateImportsAttribute() *targetBuilder {
p, _ := filepath.Rel(t.bzlPackage, t.pythonProjectRoot)
p = filepath.Clean(p)
if p == "." {
return t
}
t.imports = []string{p}
return t
}
// build returns the assembled *rule.Rule for the target.
func (t *targetBuilder) build() *rule.Rule {
r := rule.NewRule(t.kind, t.name)
if !t.srcs.Empty() {
r.SetAttr("srcs", t.srcs.Values())
}
if !t.visibility.Empty() {
r.SetAttr("visibility", t.visibility.Values())
}
if t.main != nil {
r.SetAttr("main", *t.main)
}
if t.imports != nil {
r.SetAttr("imports", t.imports)
}
if !t.deps.Empty() {
r.SetPrivateAttr(config.GazelleImportsKey, t.deps)
}
if t.testonly {
r.SetAttr("testonly", true)
}
r.SetPrivateAttr(resolvedDepsKey, t.resolvedDeps)
return r
}
rules_python-0.22.1/gazelle/python/testdata/ 0000775 0000000 0000000 00000000000 14540404546 0021112 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/README.md 0000664 0000000 0000000 00000001167 14540404546 0022376 0 ustar 00root root 0000000 0000000 # Gazelle Python extension test cases
Each directory is a test case that contains `BUILD.in` and `BUILD.out` files for
assertion. `BUILD.in` is used as how the build file looks before running
Gazelle, and `BUILD.out` how the build file should look like after running
Gazelle.
Each test case is a Bazel workspace and Gazelle will run with its working
directory set to the root of this workspace, though, the test runner will find
`test.yaml` files and use them to determine the directory Gazelle should use for
each inner Python project. The `test.yaml` file is a manifest for the test -
check for the existing ones for examples.
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/ 0000775 0000000 0000000 00000000000 14540404546 0026706 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/BUILD.in 0000664 0000000 0000000 00000000051 14540404546 0030071 0 ustar 00root root 0000000 0000000 # gazelle:resolve py bar //somewhere/bar
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/BUILD.out 0000664 0000000 0000000 00000000514 14540404546 0030276 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:resolve py bar //somewhere/bar
py_library(
name = "dependency_resolution_order",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
deps = [
"//baz",
"//somewhere/bar",
"@gazelle_python_test_some_foo//:pkg",
],
)
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/README.md 0000664 0000000 0000000 00000000415 14540404546 0030165 0 ustar 00root root 0000000 0000000 # Dependency resolution order
This asserts that the generator resolves the dependencies in the right order:
1. Explicit resolution via gazelle:resolve.
2. Third-party dependencies matching in the `modules_mapping.json`.
3. Indexed generated first-party dependencies.
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/WORKSPACE 0000664 0000000 0000000 00000000047 14540404546 0030170 0 ustar 00root root 0000000 0000000 # This is a test data Bazel workspace.
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/__init__.py 0000664 0000000 0000000 00000001252 14540404546 0031017 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import bar
import baz
import foo
_ = sys
_ = bar
_ = baz
_ = foo
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/bar/ 0000775 0000000 0000000 00000000000 14540404546 0027452 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/bar/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030627 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/bar/BUILD.out 0000664 0000000 0000000 00000000261 14540404546 0031041 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bar",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/bar/__init__.py 0000664 0000000 0000000 00000001156 14540404546 0031566 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
_ = os
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/baz/ 0000775 0000000 0000000 00000000000 14540404546 0027462 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/baz/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030637 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/baz/BUILD.out 0000664 0000000 0000000 00000000261 14540404546 0031051 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "baz",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/baz/__init__.py 0000664 0000000 0000000 00000001156 14540404546 0031576 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
_ = os
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/foo/ 0000775 0000000 0000000 00000000000 14540404546 0027471 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/foo/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030646 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/foo/BUILD.out 0000664 0000000 0000000 00000000261 14540404546 0031060 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/foo/__init__.py 0000664 0000000 0000000 00000001156 14540404546 0031605 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
_ = os
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/gazelle_python.yaml 0000664 0000000 0000000 00000001273 14540404546 0032621 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
foo: some_foo
pip_deps_repository_name: gazelle_python_test
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/somewhere/ 0000775 0000000 0000000 00000000000 14540404546 0030704 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/ 0000775 0000000 0000000 00000000000 14540404546 0031450 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0032625 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.out 0000664 0000000 0000000 00000000264 14540404546 0033042 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bar",
srcs = ["__init__.py"],
imports = ["../.."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/__init__.py 0000664 0000000 0000000 00000001156 14540404546 0033564 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
_ = os
rules_python-0.22.1/gazelle/python/testdata/dependency_resolution_order/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0030545 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/disable_import_statements_validation/ 0000775 0000000 0000000 00000000000 14540404546 0030570 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/disable_import_statements_validation/BUILD.in 0000664 0000000 0000000 00000000062 14540404546 0031755 0 ustar 00root root 0000000 0000000 # gazelle:python_validate_import_statements false
rules_python-0.22.1/gazelle/python/testdata/disable_import_statements_validation/BUILD.out 0000664 0000000 0000000 00000000357 14540404546 0032165 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_validate_import_statements false
py_library(
name = "disable_import_statements_validation",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/disable_import_statements_validation/README.md 0000664 0000000 0000000 00000000163 14540404546 0032047 0 ustar 00root root 0000000 0000000 # Disable import statements validation
This test case asserts that the module's validation step is not performed.
rules_python-0.22.1/gazelle/python/testdata/disable_import_statements_validation/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0032054 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/disable_import_statements_validation/__init__.py 0000664 0000000 0000000 00000001170 14540404546 0032700 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import abcdefg
_ = abcdefg
rules_python-0.22.1/gazelle/python/testdata/disable_import_statements_validation/test.yaml 0000664 0000000 0000000 00000001167 14540404546 0032440 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 0
rules_python-0.22.1/gazelle/python/testdata/dont_rename_target/ 0000775 0000000 0000000 00000000000 14540404546 0024753 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/dont_rename_target/BUILD.in 0000664 0000000 0000000 00000000143 14540404546 0026140 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "my_custom_target",
)
rules_python-0.22.1/gazelle/python/testdata/dont_rename_target/BUILD.out 0000664 0000000 0000000 00000000250 14540404546 0026340 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "my_custom_target",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/dont_rename_target/README.md 0000664 0000000 0000000 00000000207 14540404546 0026231 0 ustar 00root root 0000000 0000000 # Don't rename target
This test case asserts that an existing target with a custom name doesn't get
renamed by the Gazelle extension.
rules_python-0.22.1/gazelle/python/testdata/dont_rename_target/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0026237 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/dont_rename_target/__init__.py 0000664 0000000 0000000 00000001134 14540404546 0027063 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rules_python-0.22.1/gazelle/python/testdata/dont_rename_target/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0026612 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/ 0000775 0000000 0000000 00000000000 14540404546 0030213 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0031370 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/BUILD.out 0000664 0000000 0000000 00000000445 14540404546 0031606 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "file_name_matches_import_statement",
srcs = [
"__init__.py",
"rest_framework.py",
],
visibility = ["//:__subpackages__"],
deps = ["@gazelle_python_test_djangorestframework//:pkg"],
)
rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/README.md 0000664 0000000 0000000 00000000267 14540404546 0031477 0 ustar 00root root 0000000 0000000 # File name matches import statement
This test case asserts that a file with an import statement that matches its own
name does the right thing of resolving the third-party package.
rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0031477 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0032330 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/gazelle_python.yaml 0000664 0000000 0000000 00000001321 14540404546 0034120 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
rest_framework: djangorestframework
pip_deps_repository_name: gazelle_python_test
rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/rest_framework.py 0000664 0000000 0000000 00000001206 14540404546 0033616 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import rest_framework
_ = rest_framework
rules_python-0.22.1/gazelle/python/testdata/file_name_matches_import_statement/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0032052 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/ 0000775 0000000 0000000 00000000000 14540404546 0026166 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027343 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0027544 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/README.md 0000664 0000000 0000000 00000000645 14540404546 0027452 0 ustar 00root root 0000000 0000000 # First-party dependencies
There are 2 different scenarios that the extension needs to handle:
1. Import statements that match sub-directory names.
2. Import statements that don't match sub-directory names and need a hint from
the user via directives.
This test case asserts that the generated targets cover both scenarios.
With the hint we need to check if it's a .py file or a directory with `__init__.py` file.
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/WORKSPACE 0000664 0000000 0000000 00000000047 14540404546 0027450 0 ustar 00root root 0000000 0000000 # This is a test data Bazel workspace.
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/ 0000775 0000000 0000000 00000000000 14540404546 0026747 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/BUILD.in 0000664 0000000 0000000 00000000026 14540404546 0030134 0 ustar 00root root 0000000 0000000 # gazelle:python_root
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/BUILD.out 0000664 0000000 0000000 00000000450 14540404546 0030336 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary")
# gazelle:python_root
py_binary(
name = "one_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//one:__subpackages__"],
deps = [
"//one/bar",
"//one/bar/baz",
"//one/foo",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/__main__.py 0000664 0000000 0000000 00000001745 14540404546 0031050 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from bar import bar
from bar.baz import baz
from foo import foo
if __name__ == "__main__":
INIT_FILENAME = "__init__.py"
dirname = os.path.dirname(os.path.abspath(__file__))
assert bar() == os.path.join(dirname, "bar", INIT_FILENAME)
assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME)
assert foo() == os.path.join(dirname, "foo", INIT_FILENAME)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/ 0000775 0000000 0000000 00000000000 14540404546 0027513 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.in 0000664 0000000 0000000 00000000320 14540404546 0030675 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bar",
srcs = ["__init__.py"],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.out 0000664 0000000 0000000 00000000346 14540404546 0031106 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bar",
srcs = ["__init__.py"],
imports = [".."],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0031620 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def bar():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/baz/ 0000775 0000000 0000000 00000000000 14540404546 0030267 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.in 0000664 0000000 0000000 00000000320 14540404546 0031451 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "baz",
srcs = ["__init__.py"],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.out 0000664 0000000 0000000 00000000351 14540404546 0031656 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "baz",
srcs = ["__init__.py"],
imports = ["../.."],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/bar/baz/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0032374 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def baz():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/foo/ 0000775 0000000 0000000 00000000000 14540404546 0027532 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.in 0000664 0000000 0000000 00000000361 14540404546 0030721 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = ["__init__.py"],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
"//two:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.out 0000664 0000000 0000000 00000000407 14540404546 0031123 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = ["__init__.py"],
imports = [".."],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
"//two:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/one/foo/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0031637 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def foo():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0030025 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/three/ 0000775 0000000 0000000 00000000000 14540404546 0027275 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/three/BUILD.in 0000664 0000000 0000000 00000000026 14540404546 0030462 0 ustar 00root root 0000000 0000000 # gazelle:python_root
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/three/BUILD.out 0000664 0000000 0000000 00000000420 14540404546 0030661 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_root
py_library(
name = "three",
srcs = ["__init__.py"],
visibility = ["//three:__subpackages__"],
deps = [
"//one/bar",
"//one/bar/baz",
"//one/foo",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/three/__init__.py 0000664 0000000 0000000 00000001307 14540404546 0031407 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from bar import bar
from bar.baz import baz
from foo import foo
_ = os
_ = bar
_ = baz
_ = foo
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/two/ 0000775 0000000 0000000 00000000000 14540404546 0026777 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/two/BUILD.in 0000664 0000000 0000000 00000000026 14540404546 0030164 0 ustar 00root root 0000000 0000000 # gazelle:python_root
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/two/BUILD.out 0000664 0000000 0000000 00000000317 14540404546 0030370 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_root
py_library(
name = "two",
srcs = ["__init__.py"],
visibility = ["//two:__subpackages__"],
deps = ["//one/foo"],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_dependencies/two/__init__.py 0000664 0000000 0000000 00000001213 14540404546 0031105 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from foo import foo
_ = os
_ = foo
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/ 0000775 0000000 0000000 00000000000 14540404546 0031115 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.in 0000664 0000000 0000000 00000000037 14540404546 0032304 0 ustar 00root root 0000000 0000000 # gazelle:resolve py foo //foo
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.out 0000664 0000000 0000000 00000001107 14540404546 0032504 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library")
# gazelle:resolve py foo //foo
py_library(
name = "first_party_file_and_directory_modules",
srcs = [
"baz.py",
"foo.py",
],
visibility = ["//:__subpackages__"],
)
py_binary(
name = "first_party_file_and_directory_modules_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [
":first_party_file_and_directory_modules",
"//foo",
"//one",
"//undiscoverable/package1/subpackage1",
],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/README.md 0000664 0000000 0000000 00000000737 14540404546 0032403 0 ustar 00root root 0000000 0000000 # First-party file and directory module dependencies
This test case asserts that a `py_library` is generated with the dependencies
pointing to the correct first-party target that contains a Python module file
that was imported directly instead of a directory containing `__init__.py`.
Also, it asserts that the directory with the `__init__.py` file is selected
instead of a module file with same. E.g. `foo/__init__.py` takes precedence over
`foo.py` when `import foo` exists.
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0032401 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/__main__.py 0000664 0000000 0000000 00000001615 14540404546 0033212 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import foo
from baz import baz as another_baz
from foo.bar import baz
from one.two import two
from package1.subpackage1.module1 import find_me
assert not hasattr(foo, "foo")
assert baz() == "baz from foo/bar.py"
assert another_baz() == "baz from baz.py"
assert two() == "two"
assert find_me() == "found"
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py 0000664 0000000 0000000 00000001204 14540404546 0032240 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def baz():
return "baz from baz.py"
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py 0000664 0000000 0000000 00000001170 14540404546 0032251 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def foo():
print("foo")
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/foo/ 0000775 0000000 0000000 00000000000 14540404546 0031700 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0033055 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.out 0000664 0000000 0000000 00000000350 14540404546 0033266 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = [
"__init__.py",
"bar.py",
],
imports = [".."],
visibility = ["//:__subpackages__"],
deps = ["//one"],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/foo/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0034015 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/foo/bar.py 0000664 0000000 0000000 00000001251 14540404546 0033015 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import one.two as two
_ = two
def baz():
return "baz from foo/bar.py"
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/one/ 0000775 0000000 0000000 00000000000 14540404546 0031676 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0033053 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.out 0000664 0000000 0000000 00000000322 14540404546 0033263 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "one",
srcs = [
"__init__.py",
"two.py",
],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/one/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0034013 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py 0000664 0000000 0000000 00000001170 14540404546 0033060 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def two():
return "two"
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0032754 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/ 0000775 0000000 0000000 00000000000 14540404546 0034122 5 ustar 00root root 0000000 0000000 BUILD.in 0000664 0000000 0000000 00000000026 14540404546 0035230 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable # gazelle:python_root
BUILD.out 0000664 0000000 0000000 00000000026 14540404546 0035431 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable # gazelle:python_root
package1/ 0000775 0000000 0000000 00000000000 14540404546 0035517 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable subpackage1/ 0000775 0000000 0000000 00000000000 14540404546 0037705 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1 BUILD.in 0000664 0000000 0000000 00000000432 14540404546 0041073 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "subpackage1",
srcs = [
"__init__.py",
"module1.py",
],
imports = ["../.."],
# Manual fix to visibility after initial generation.
visibility = ["//:__subpackages__"],
)
BUILD.out 0000664 0000000 0000000 00000000432 14540404546 0041274 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "subpackage1",
srcs = [
"__init__.py",
"module1.py",
],
imports = ["../.."],
# Manual fix to visibility after initial generation.
visibility = ["//:__subpackages__"],
)
__init__.py 0000664 0000000 0000000 00000001166 14540404546 0042022 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
module1.py 0000664 0000000 0000000 00000001176 14540404546 0041632 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def find_me():
return "found"
rules_python-0.22.1/gazelle/python/testdata/from_imports/ 0000775 0000000 0000000 00000000000 14540404546 0023632 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/BUILD.in 0000664 0000000 0000000 00000000043 14540404546 0025016 0 ustar 00root root 0000000 0000000 # gazelle:python_extension enabled
rules_python-0.22.1/gazelle/python/testdata/from_imports/BUILD.out 0000664 0000000 0000000 00000000043 14540404546 0025217 0 ustar 00root root 0000000 0000000 # gazelle:python_extension enabled
rules_python-0.22.1/gazelle/python/testdata/from_imports/README.md 0000664 0000000 0000000 00000000141 14540404546 0025105 0 ustar 00root root 0000000 0000000 # From Imports
This test case simulates imports of the form:
```python
from foo import bar
```
rules_python-0.22.1/gazelle/python/testdata/from_imports/WORKSPACE 0000664 0000000 0000000 00000000047 14540404546 0025114 0 ustar 00root root 0000000 0000000 # This is a test data Bazel workspace.
rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/ 0000775 0000000 0000000 00000000000 14540404546 0024415 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/BUILD.in 0000664 0000000 0000000 00000000001 14540404546 0025573 0 ustar 00root root 0000000 0000000
rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/BUILD.out 0000664 0000000 0000000 00000000261 14540404546 0026004 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/__init__.py 0000664 0000000 0000000 00000001150 14540404546 0026523 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
foo = "foo"
rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/bar/ 0000775 0000000 0000000 00000000000 14540404546 0025161 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/bar/BUILD.in 0000664 0000000 0000000 00000000561 14540404546 0026352 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_ignore_files baz.py
py_library(
name = "baz",
srcs = [
"baz.py",
],
imports = ["../.."],
visibility = ["//:__subpackages__"],
)
py_library(
name = "bar",
srcs = [
"__init__.py",
],
imports = ["../.."],
visibility = ["//:__subpackages__"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/bar/BUILD.out 0000664 0000000 0000000 00000000561 14540404546 0026553 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_ignore_files baz.py
py_library(
name = "baz",
srcs = [
"baz.py",
],
imports = ["../.."],
visibility = ["//:__subpackages__"],
)
py_library(
name = "bar",
srcs = [
"__init__.py",
],
imports = ["../.."],
visibility = ["//:__subpackages__"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/bar/__init__.py 0000664 0000000 0000000 00000001150 14540404546 0027267 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
bar = "bar"
rules_python-0.22.1/gazelle/python/testdata/from_imports/foo/bar/baz.py 0000664 0000000 0000000 00000001150 14540404546 0026304 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
baz = "baz"
rules_python-0.22.1/gazelle/python/testdata/from_imports/gazelle_python.yaml 0000664 0000000 0000000 00000001315 14540404546 0027542 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: rootboto3
boto4: rootboto4
pip_deps_repository_name: root_pip_deps
rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_init_py/ 0000775 0000000 0000000 00000000000 14540404546 0027722 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_init_py/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0031077 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_init_py/BUILD.out 0000664 0000000 0000000 00000000332 14540404546 0031310 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "import_from_init_py",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
deps = ["//foo/bar"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_init_py/__init__.py 0000664 0000000 0000000 00000001243 14540404546 0032033 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# bar is a variable inside foo/bar/__init__.py
from foo.bar import bar
rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_multiple/ 0000775 0000000 0000000 00000000000 14540404546 0030102 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_multiple/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0031257 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_multiple/BUILD.out 0000664 0000000 0000000 00000000403 14540404546 0031467 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "import_from_multiple",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
deps = [
"//foo/bar",
"//foo/bar:baz",
],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/import_from_multiple/__init__.py 0000664 0000000 0000000 00000001250 14540404546 0032211 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Import multiple values from the same import.
from foo.bar import bar, baz
rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_file/ 0000775 0000000 0000000 00000000000 14540404546 0027505 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_file/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030662 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_file/BUILD.out 0000664 0000000 0000000 00000000335 14540404546 0031076 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "import_nested_file",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
deps = ["//foo/bar:baz"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_file/__init__.py 0000664 0000000 0000000 00000001231 14540404546 0031613 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# baz.py is a file at foo/bar/baz.py
from foo.bar import baz
rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_module/ 0000775 0000000 0000000 00000000000 14540404546 0030053 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_module/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0031230 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_module/BUILD.out 0000664 0000000 0000000 00000000333 14540404546 0031442 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "import_nested_module",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
deps = ["//foo/bar"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_module/__init__.py 0000664 0000000 0000000 00000001231 14540404546 0032161 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# bar is a module at foo/bar/__init__.py
from foo import bar
rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_var/ 0000775 0000000 0000000 00000000000 14540404546 0027356 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_var/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030533 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_var/BUILD.out 0000664 0000000 0000000 00000000334 14540404546 0030746 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "import_nested_var",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
deps = ["//foo/bar:baz"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/import_nested_var/__init__.py 0000664 0000000 0000000 00000001236 14540404546 0031471 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# baz is a variable in foo/bar/baz.py
from foo.bar.baz import baz
rules_python-0.22.1/gazelle/python/testdata/from_imports/import_top_level_var/ 0000775 0000000 0000000 00000000000 14540404546 0030065 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_top_level_var/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0031242 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/import_top_level_var/BUILD.out 0000664 0000000 0000000 00000000327 14540404546 0031457 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "import_top_level_var",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
deps = ["//foo"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/import_top_level_var/__init__.py 0000664 0000000 0000000 00000001227 14540404546 0032200 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# foo is a variable in foo/__init__.py
from foo import foo
rules_python-0.22.1/gazelle/python/testdata/from_imports/std_module/ 0000775 0000000 0000000 00000000000 14540404546 0025771 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/std_module/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027146 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/from_imports/std_module/BUILD.out 0000664 0000000 0000000 00000000267 14540404546 0027366 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "std_module",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
) rules_python-0.22.1/gazelle/python/testdata/from_imports/std_module/__init__.py 0000664 0000000 0000000 00000001323 14540404546 0030101 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Gazelle should recognize this from import
# as the standard module __future__.
from __future__ import print_function
rules_python-0.22.1/gazelle/python/testdata/from_imports/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0025471 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/ 0000775 0000000 0000000 00000000000 14540404546 0026402 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/BUILD.in 0000664 0000000 0000000 00000000255 14540404546 0027573 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
something(
name = "__test__",
)
py_library(
name = "generated_test_entrypoint",
srcs = ["__init__.py"],
)
rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/BUILD.out 0000664 0000000 0000000 00000000612 14540404546 0027771 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
something(
name = "__test__",
)
py_library(
name = "generated_test_entrypoint",
srcs = [
"__init__.py",
"foo.py",
],
visibility = ["//:__subpackages__"],
)
py_test(
name = "generated_test_entrypoint_test",
srcs = [":__test__"],
main = ":__test__.py",
deps = [":__test__"],
)
rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/README.md 0000664 0000000 0000000 00000000214 14540404546 0027656 0 ustar 00root root 0000000 0000000 # Generated test entrypoint
This test case asserts that a `py_test` is generated using a target named
`__test__` as its `main` entrypoint.
rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0027666 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/__init__.py 0000664 0000000 0000000 00000001171 14540404546 0030513 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from foo import foo
_ = foo
rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/foo.py 0000664 0000000 0000000 00000001170 14540404546 0027536 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def foo():
return "foo"
rules_python-0.22.1/gazelle/python/testdata/generated_test_entrypoint/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0030241 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/ 0000775 0000000 0000000 00000000000 14540404546 0027517 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030674 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/BUILD.out 0000664 0000000 0000000 00000000346 14540404546 0031112 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "ignored_invalid_imported_module",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
deps = ["@gazelle_python_test_foo//:pkg"],
)
rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/README.md 0000664 0000000 0000000 00000000162 14540404546 0030775 0 ustar 00root root 0000000 0000000 # Ignored invalid imported module
This test case asserts that the module's validation step succeeds as expected.
rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0031003 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/__init__.py 0000664 0000000 0000000 00000001611 14540404546 0031627 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# gazelle:ignore abcdefg1,abcdefg2
# gazelle:ignore abcdefg3
import abcdefg1
import abcdefg2
import abcdefg3
import foo
_ = abcdefg1
_ = abcdefg2
_ = abcdefg3
_ = foo
try:
# gazelle:ignore grpc
import grpc
grpc_available = True
except ImportError:
grpc_available = False
_ = grpc
rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/gazelle_python.yaml 0000664 0000000 0000000 00000001266 14540404546 0033434 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
foo: foo
pip_deps_repository_name: gazelle_python_test
rules_python-0.22.1/gazelle/python/testdata/ignored_invalid_imported_module/test.yaml 0000664 0000000 0000000 00000001167 14540404546 0031367 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 0
rules_python-0.22.1/gazelle/python/testdata/invalid_annotation/ 0000775 0000000 0000000 00000000000 14540404546 0024772 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/invalid_annotation/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0026147 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/invalid_annotation/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0026350 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/invalid_annotation/README.md 0000664 0000000 0000000 00000000165 14540404546 0026253 0 ustar 00root root 0000000 0000000 # Invalid annotation
This test case asserts that the parse step fails as expected due to invalid annotation format.
rules_python-0.22.1/gazelle/python/testdata/invalid_annotation/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0026256 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/invalid_annotation/__init__.py 0000664 0000000 0000000 00000001155 14540404546 0027105 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# gazelle:ignore
rules_python-0.22.1/gazelle/python/testdata/invalid_annotation/test.yaml 0000664 0000000 0000000 00000001330 14540404546 0026632 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 1
stderr: |
gazelle: ERROR: failed to parse annotations: `# gazelle:ignore` requires a value
rules_python-0.22.1/gazelle/python/testdata/invalid_imported_module/ 0000775 0000000 0000000 00000000000 14540404546 0026010 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/invalid_imported_module/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027165 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/invalid_imported_module/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0027366 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/invalid_imported_module/README.md 0000664 0000000 0000000 00000000147 14540404546 0027271 0 ustar 00root root 0000000 0000000 # Invalid imported module
This test case asserts that the module's validation step fails as expected.
rules_python-0.22.1/gazelle/python/testdata/invalid_imported_module/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0027274 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/invalid_imported_module/__init__.py 0000664 0000000 0000000 00000001305 14540404546 0030120 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
try:
import grpc
grpc_available = True
except ImportError:
grpc_available = False
_ = grpc
rules_python-0.22.1/gazelle/python/testdata/invalid_imported_module/test.yaml 0000664 0000000 0000000 00000002034 14540404546 0027652 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 1
stderr: |
gazelle: ERROR: failed to validate dependencies for target "//:invalid_imported_module": "grpc" at line 16 from "__init__.py" is an invalid dependency: possible solutions:
1. Add it as a dependency in the requirements.txt file.
2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.
3. Ignore it with a comment '# gazelle:ignore grpc' in the Python file.
rules_python-0.22.1/gazelle/python/testdata/monorepo/ 0000775 0000000 0000000 00000000000 14540404546 0022750 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/BUILD.in 0000664 0000000 0000000 00000000044 14540404546 0024135 0 ustar 00root root 0000000 0000000 # gazelle:python_extension disabled
rules_python-0.22.1/gazelle/python/testdata/monorepo/BUILD.out 0000664 0000000 0000000 00000000044 14540404546 0024336 0 ustar 00root root 0000000 0000000 # gazelle:python_extension disabled
rules_python-0.22.1/gazelle/python/testdata/monorepo/README.md 0000664 0000000 0000000 00000000164 14540404546 0024230 0 ustar 00root root 0000000 0000000 # Monorepo
This test case focuses on having multiple configurations tweaked in combination
to simulate a monorepo.
rules_python-0.22.1/gazelle/python/testdata/monorepo/WORKSPACE 0000664 0000000 0000000 00000000047 14540404546 0024232 0 ustar 00root root 0000000 0000000 # This is a test data Bazel workspace.
rules_python-0.22.1/gazelle/python/testdata/monorepo/a/ 0000775 0000000 0000000 00000000000 14540404546 0023170 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/a/BUILD.in 0000664 0000000 0000000 00000000040 14540404546 0024351 0 ustar 00root root 0000000 0000000 # gazelle:exclude bar/baz/hue.py rules_python-0.22.1/gazelle/python/testdata/monorepo/a/BUILD.out 0000664 0000000 0000000 00000000040 14540404546 0024552 0 ustar 00root root 0000000 0000000 # gazelle:exclude bar/baz/hue.py rules_python-0.22.1/gazelle/python/testdata/monorepo/a/README.md 0000664 0000000 0000000 00000000264 14540404546 0024451 0 ustar 00root root 0000000 0000000 # Exclusions
* Intentionally make the directory "a" so Gazelle visit this before "coarse_grained"
* Making sure that the exclusion here doesn't affect coarse_grained/bar/baz/hue.py rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/ 0000775 0000000 0000000 00000000000 14540404546 0025715 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/BUILD.in 0000664 0000000 0000000 00000000426 14540404546 0027106 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_extension enabled
# gazelle:python_root
# gazelle:python_generation_mode project
# gazelle:exclude bar/baz/*_excluded.py
py_library(
name = "coarse_grained",
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/BUILD.out 0000664 0000000 0000000 00000000737 14540404546 0027314 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_extension enabled
# gazelle:python_root
# gazelle:python_generation_mode project
# gazelle:exclude bar/baz/*_excluded.py
py_library(
name = "coarse_grained",
srcs = [
"__init__.py",
"bar/__init__.py",
"bar/baz/__init__.py",
"bar/baz/hue.py",
"foo/__init__.py",
],
visibility = ["//:__subpackages__"],
deps = ["@root_pip_deps_rootboto3//:pkg"],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/__init__.py 0000664 0000000 0000000 00000001336 14540404546 0030031 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import boto3
from bar import bar
from bar.baz import baz
from foo import foo
_ = os
_ = boto3
_ = bar
_ = baz
_ = foo
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/_boundary/ 0000775 0000000 0000000 00000000000 14540404546 0027677 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.in 0000664 0000000 0000000 00000000051 14540404546 0031062 0 ustar 00root root 0000000 0000000 # gazelle:python_generation_mode package
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.out 0000664 0000000 0000000 00000000357 14540404546 0031274 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_generation_mode package
py_library(
name = "_boundary",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//coarse_grained:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/_boundary/README.md 0000664 0000000 0000000 00000000336 14540404546 0031160 0 ustar 00root root 0000000 0000000 # \_boundary
This Bazel package must be before other packages in the `coarse_grained`
directory so that we assert that walking the tree still happens after ignoring
this package from the parent coarse-grained generation.
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py 0000664 0000000 0000000 00000001134 14540404546 0032007 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/bar/ 0000775 0000000 0000000 00000000000 14540404546 0026461 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/bar/__init__.py 0000664 0000000 0000000 00000001261 14540404546 0030572 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import boto3
_ = boto3
def bar():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/ 0000775 0000000 0000000 00000000000 14540404546 0027235 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0031342 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def baz():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py 0000664 0000000 0000000 00000001166 14540404546 0032617 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/hue.py 0000664 0000000 0000000 00000001166 14540404546 0030374 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py 0000664 0000000 0000000 00000001166 14540404546 0032743 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/foo/ 0000775 0000000 0000000 00000000000 14540404546 0026500 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/coarse_grained/foo/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0030605 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def foo():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/gazelle_python.yaml 0000664 0000000 0000000 00000001315 14540404546 0026660 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: rootboto3
boto4: rootboto4
pip_deps_repository_name: root_pip_deps
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/ 0000775 0000000 0000000 00000000000 14540404546 0023531 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/one/BUILD.in 0000664 0000000 0000000 00000000071 14540404546 0024716 0 ustar 00root root 0000000 0000000 # gazelle:python_extension enabled
# gazelle:python_root
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/BUILD.out 0000664 0000000 0000000 00000000605 14540404546 0025122 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary")
# gazelle:python_extension enabled
# gazelle:python_root
py_binary(
name = "one_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//one:__subpackages__"],
deps = [
"//one/bar",
"//one/bar/baz:modified_name_baz",
"//one/foo",
"@one_pip_deps_oneboto3//:pkg",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/__main__.py 0000664 0000000 0000000 00000001775 14540404546 0025635 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import boto3
from bar import bar
from bar.baz import baz
from foo import foo
_ = boto3
if __name__ == "__main__":
INIT_FILENAME = "__init__.py"
dirname = os.path.dirname(os.path.abspath(__file__))
assert bar() == os.path.join(dirname, "bar", INIT_FILENAME)
assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME)
assert foo() == os.path.join(dirname, "foo", INIT_FILENAME)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/ 0000775 0000000 0000000 00000000000 14540404546 0024275 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/BUILD.in 0000664 0000000 0000000 00000000320 14540404546 0025457 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bar",
srcs = ["__init__.py"],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/BUILD.out 0000664 0000000 0000000 00000000423 14540404546 0025664 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bar",
srcs = ["__init__.py"],
imports = [".."],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
deps = ["@one_pip_deps_oneboto3//:pkg"],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/__init__.py 0000664 0000000 0000000 00000001261 14540404546 0026406 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import boto3
_ = boto3
def bar():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/baz/ 0000775 0000000 0000000 00000000000 14540404546 0025051 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.in 0000664 0000000 0000000 00000000336 14540404546 0026242 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "modified_name_baz",
srcs = ["__init__.py"],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.out 0000664 0000000 0000000 00000000367 14540404546 0026447 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "modified_name_baz",
srcs = ["__init__.py"],
imports = ["../.."],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/bar/baz/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0027156 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def baz():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/foo/ 0000775 0000000 0000000 00000000000 14540404546 0024314 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/one/foo/BUILD.in 0000664 0000000 0000000 00000000361 14540404546 0025503 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = ["__init__.py"],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
"//two:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/foo/BUILD.out 0000664 0000000 0000000 00000000407 14540404546 0025705 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = ["__init__.py"],
imports = [".."],
visibility = [
"//one:__subpackages__",
"//three:__subpackages__",
"//two:__subpackages__",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/foo/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0026421 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def foo():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/one/gazelle_python.yaml 0000664 0000000 0000000 00000001266 14540404546 0027446 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: oneboto3
pip_deps_repository_name: one_pip_deps
rules_python-0.22.1/gazelle/python/testdata/monorepo/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0024607 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/monorepo/three/ 0000775 0000000 0000000 00000000000 14540404546 0024057 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/three/BUILD.in 0000664 0000000 0000000 00000000274 14540404546 0025251 0 ustar 00root root 0000000 0000000 # gazelle:python_extension enabled
# gazelle:python_root
# gazelle:resolve py bar //one/bar
# gazelle:resolve py bar.baz //one/bar/baz:modified_name_baz
# gazelle:resolve py foo //one/foo
rules_python-0.22.1/gazelle/python/testdata/monorepo/three/BUILD.out 0000664 0000000 0000000 00000001072 14540404546 0025447 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_extension enabled
# gazelle:python_root
# gazelle:resolve py bar //one/bar
# gazelle:resolve py bar.baz //one/bar/baz:modified_name_baz
# gazelle:resolve py foo //one/foo
py_library(
name = "three",
srcs = ["__init__.py"],
visibility = ["//three:__subpackages__"],
deps = [
"//coarse_grained",
"//one/bar",
"//one/bar/baz:modified_name_baz",
"//one/foo",
"@root_pip_deps_rootboto4//:pkg",
"@three_pip_deps_threeboto3//:pkg",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/three/__init__.py 0000664 0000000 0000000 00000001427 14540404546 0026174 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import bar.baz.hue as hue
import boto3
import boto4
from bar import bar
from bar.baz import baz
from foo import foo
_ = os
_ = boto3
_ = boto4
_ = bar
_ = baz
_ = foo
_ = hue
rules_python-0.22.1/gazelle/python/testdata/monorepo/three/gazelle_python.yaml 0000664 0000000 0000000 00000001272 14540404546 0027771 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: threeboto3
pip_repository:
name: three_pip_deps
rules_python-0.22.1/gazelle/python/testdata/monorepo/two/ 0000775 0000000 0000000 00000000000 14540404546 0023561 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/two/BUILD.in 0000664 0000000 0000000 00000000134 14540404546 0024746 0 ustar 00root root 0000000 0000000 # gazelle:python_extension enabled
# gazelle:python_root
# gazelle:resolve py foo //one/foo
rules_python-0.22.1/gazelle/python/testdata/monorepo/two/BUILD.out 0000664 0000000 0000000 00000000514 14540404546 0025151 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_extension enabled
# gazelle:python_root
# gazelle:resolve py foo //one/foo
py_library(
name = "two",
srcs = ["__init__.py"],
visibility = ["//two:__subpackages__"],
deps = [
"//one/foo",
"@two_pip_deps_twoboto3//:pkg",
],
)
rules_python-0.22.1/gazelle/python/testdata/monorepo/two/__init__.py 0000664 0000000 0000000 00000001242 14540404546 0025671 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import boto3
from foo import foo
_ = os
_ = boto3
_ = foo
rules_python-0.22.1/gazelle/python/testdata/monorepo/two/gazelle_python.yaml 0000664 0000000 0000000 00000001266 14540404546 0027476 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: twoboto3
pip_deps_repository_name: two_pip_deps
rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/ 0000775 0000000 0000000 00000000000 14540404546 0025611 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0026766 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0027167 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/__main__.py 0000664 0000000 0000000 00000001745 14540404546 0027712 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from bar import bar
from bar.baz import baz
from foo import foo
if __name__ == "__main__":
INIT_FILENAME = "__init__.py"
dirname = os.path.dirname(os.path.abspath(__file__))
assert bar() == os.path.join(dirname, "bar", INIT_FILENAME)
assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME)
assert foo() == os.path.join(dirname, "foo", INIT_FILENAME)
rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/ 0000775 0000000 0000000 00000000000 14540404546 0026355 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027532 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0027733 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0030462 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def bar():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/baz/ 0000775 0000000 0000000 00000000000 14540404546 0027131 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030306 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0030507 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/bar/baz/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0031236 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def baz():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/foo/ 0000775 0000000 0000000 00000000000 14540404546 0026374 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027551 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0027752 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/monorepo/wont_generate/foo/__init__.py 0000664 0000000 0000000 00000001230 14540404546 0030501 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
def foo():
return os.path.abspath(__file__)
rules_python-0.22.1/gazelle/python/testdata/multiple_tests/ 0000775 0000000 0000000 00000000000 14540404546 0024167 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/multiple_tests/BUILD.in 0000664 0000000 0000000 00000000360 14540404546 0025355 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "multiple_tests",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
py_test(
name = "bar_test",
srcs = ["bar_test.py"],
)
rules_python-0.22.1/gazelle/python/testdata/multiple_tests/BUILD.out 0000664 0000000 0000000 00000000457 14540404546 0025565 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "multiple_tests",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
py_test(
name = "bar_test",
srcs = ["bar_test.py"],
)
py_test(
name = "foo_test",
srcs = ["foo_test.py"],
)
rules_python-0.22.1/gazelle/python/testdata/multiple_tests/README.md 0000664 0000000 0000000 00000000261 14540404546 0025445 0 ustar 00root root 0000000 0000000 # Multiple tests
This test case asserts that a second `py_test` rule is correctly created when a second `*_test.py` file is added to a package with an existing `py_test` rule.
rules_python-0.22.1/gazelle/python/testdata/multiple_tests/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0025453 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/multiple_tests/__init__.py 0000664 0000000 0000000 00000000000 14540404546 0026266 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/multiple_tests/bar_test.py 0000664 0000000 0000000 00000001346 14540404546 0026350 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
class BarTest(unittest.TestCase):
def test_foo(self):
pass
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/gazelle/python/testdata/multiple_tests/foo_test.py 0000664 0000000 0000000 00000001346 14540404546 0026367 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
class FooTest(unittest.TestCase):
def test_foo(self):
pass
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/gazelle/python/testdata/multiple_tests/test.yaml 0000664 0000000 0000000 00000001167 14540404546 0026037 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 0
rules_python-0.22.1/gazelle/python/testdata/naming_convention/ 0000775 0000000 0000000 00000000000 14540404546 0024625 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/naming_convention/BUILD.in 0000664 0000000 0000000 00000000307 14540404546 0026014 0 ustar 00root root 0000000 0000000 # gazelle:python_library_naming_convention my_$package_name$_library
# gazelle:python_binary_naming_convention my_$package_name$_binary
# gazelle:python_test_naming_convention my_$package_name$_test
rules_python-0.22.1/gazelle/python/testdata/naming_convention/BUILD.out 0000664 0000000 0000000 00000001361 14540404546 0026216 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
# gazelle:python_library_naming_convention my_$package_name$_library
# gazelle:python_binary_naming_convention my_$package_name$_binary
# gazelle:python_test_naming_convention my_$package_name$_test
py_library(
name = "my_naming_convention_library",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
py_binary(
name = "my_naming_convention_binary",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [":my_naming_convention_library"],
)
py_test(
name = "my_naming_convention_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":my_naming_convention_library"],
)
rules_python-0.22.1/gazelle/python/testdata/naming_convention/README.md 0000664 0000000 0000000 00000000252 14540404546 0026103 0 ustar 00root root 0000000 0000000 # Naming convention
This test case asserts that py\_{library,binary,test} targets are generated
correctly based on the directives that control their naming conventions.
rules_python-0.22.1/gazelle/python/testdata/naming_convention/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0026111 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/naming_convention/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0026742 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/naming_convention/__main__.py 0000664 0000000 0000000 00000001205 14540404546 0026715 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import __init__ rules_python-0.22.1/gazelle/python/testdata/naming_convention/__test__.py 0000664 0000000 0000000 00000001205 14540404546 0026750 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import __init__ rules_python-0.22.1/gazelle/python/testdata/naming_convention/dont_rename/ 0000775 0000000 0000000 00000000000 14540404546 0027120 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/naming_convention/dont_rename/BUILD.in 0000664 0000000 0000000 00000000273 14540404546 0030311 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
py_library(
name = "dont_rename",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/naming_convention/dont_rename/BUILD.out 0000664 0000000 0000000 00000001054 14540404546 0030510 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
py_library(
name = "dont_rename",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
py_binary(
name = "my_dont_rename_binary",
srcs = ["__main__.py"],
imports = [".."],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [":dont_rename"],
)
py_test(
name = "my_dont_rename_test",
srcs = ["__test__.py"],
imports = [".."],
main = "__test__.py",
deps = [":dont_rename"],
)
rules_python-0.22.1/gazelle/python/testdata/naming_convention/dont_rename/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0031235 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/naming_convention/dont_rename/__main__.py 0000664 0000000 0000000 00000001205 14540404546 0031210 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import __init__ rules_python-0.22.1/gazelle/python/testdata/naming_convention/dont_rename/__test__.py 0000664 0000000 0000000 00000001205 14540404546 0031243 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import __init__ rules_python-0.22.1/gazelle/python/testdata/naming_convention/resolve_conflict/ 0000775 0000000 0000000 00000000000 14540404546 0030165 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.in 0000664 0000000 0000000 00000000171 14540404546 0031353 0 ustar 00root root 0000000 0000000 go_library(name = "resolve_conflict")
go_binary(name = "resolve_conflict_bin")
go_test(name = "resolve_conflict_test")
rules_python-0.22.1/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.out 0000664 0000000 0000000 00000001340 14540404546 0031553 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
go_library(name = "resolve_conflict")
go_binary(name = "resolve_conflict_bin")
go_test(name = "resolve_conflict_test")
py_library(
name = "my_resolve_conflict_library",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
py_binary(
name = "my_resolve_conflict_binary",
srcs = ["__main__.py"],
imports = [".."],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [":my_resolve_conflict_library"],
)
py_test(
name = "my_resolve_conflict_test",
srcs = ["__test__.py"],
imports = [".."],
main = "__test__.py",
deps = [":my_resolve_conflict_library"],
)
rules_python-0.22.1/gazelle/python/testdata/naming_convention/resolve_conflict/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0032302 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py 0000664 0000000 0000000 00000001205 14540404546 0032255 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import __init__ rules_python-0.22.1/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py 0000664 0000000 0000000 00000001205 14540404546 0032310 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import __init__ rules_python-0.22.1/gazelle/python/testdata/naming_convention/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0026464 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/naming_convention_binary_fail/ 0000775 0000000 0000000 00000000000 14540404546 0027164 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/naming_convention_binary_fail/BUILD.in 0000664 0000000 0000000 00000000066 14540404546 0030355 0 ustar 00root root 0000000 0000000 go_binary(name = "naming_convention_binary_fail_bin")
rules_python-0.22.1/gazelle/python/testdata/naming_convention_binary_fail/BUILD.out 0000664 0000000 0000000 00000000066 14540404546 0030556 0 ustar 00root root 0000000 0000000 go_binary(name = "naming_convention_binary_fail_bin")
rules_python-0.22.1/gazelle/python/testdata/naming_convention_binary_fail/README.md 0000664 0000000 0000000 00000000214 14540404546 0030440 0 ustar 00root root 0000000 0000000 # Naming convention py_binary fail
This test case asserts that a py_binary is not generated due to a naming conflict
with existing target.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_binary_fail/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030450 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_binary_fail/__main__.py 0000664 0000000 0000000 00000001166 14540404546 0031262 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_binary_fail/test.yaml 0000664 0000000 0000000 00000001624 14540404546 0031032 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 1
stderr: >
gazelle: ERROR: failed to generate target "//:naming_convention_binary_fail_bin" of kind "py_binary":
a target of kind "go_binary" with the same name already exists.
Use the '# gazelle:python_binary_naming_convention' directive to change the naming convention.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_library_fail/ 0000775 0000000 0000000 00000000000 14540404546 0027344 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/naming_convention_library_fail/BUILD.in 0000664 0000000 0000000 00000000064 14540404546 0030533 0 ustar 00root root 0000000 0000000 go_library(name = "naming_convention_library_fail")
rules_python-0.22.1/gazelle/python/testdata/naming_convention_library_fail/BUILD.out 0000664 0000000 0000000 00000000064 14540404546 0030734 0 ustar 00root root 0000000 0000000 go_library(name = "naming_convention_library_fail")
rules_python-0.22.1/gazelle/python/testdata/naming_convention_library_fail/README.md 0000664 0000000 0000000 00000000216 14540404546 0030622 0 ustar 00root root 0000000 0000000 # Naming convention py_library fail
This test case asserts that a py_library is not generated due to a naming conflict
with existing target.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_library_fail/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030630 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_library_fail/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0031461 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_library_fail/test.yaml 0000664 0000000 0000000 00000001624 14540404546 0031212 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 1
stderr: >
gazelle: ERROR: failed to generate target "//:naming_convention_library_fail" of kind "py_library":
a target of kind "go_library" with the same name already exists.
Use the '# gazelle:python_library_naming_convention' directive to change the naming convention.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_test_fail/ 0000775 0000000 0000000 00000000000 14540404546 0026657 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/naming_convention_test_fail/BUILD.in 0000664 0000000 0000000 00000000063 14540404546 0030045 0 ustar 00root root 0000000 0000000 go_test(name = "naming_convention_test_fail_test")
rules_python-0.22.1/gazelle/python/testdata/naming_convention_test_fail/BUILD.out 0000664 0000000 0000000 00000000063 14540404546 0030246 0 ustar 00root root 0000000 0000000 go_test(name = "naming_convention_test_fail_test")
rules_python-0.22.1/gazelle/python/testdata/naming_convention_test_fail/README.md 0000664 0000000 0000000 00000000210 14540404546 0030127 0 ustar 00root root 0000000 0000000 # Naming convention py_test fail
This test case asserts that a py_test is not generated due to a naming conflict
with existing target.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_test_fail/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030143 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_test_fail/__test__.py 0000664 0000000 0000000 00000001166 14540404546 0031010 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/naming_convention_test_fail/test.yaml 0000664 0000000 0000000 00000001615 14540404546 0030525 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 1
stderr: >
gazelle: ERROR: failed to generate target "//:naming_convention_test_fail_test" of kind "py_test":
a target of kind "go_test" with the same name already exists.
Use the '# gazelle:python_test_naming_convention' directive to change the naming convention.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/ 0000775 0000000 0000000 00000000000 14540404546 0030542 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.in 0000664 0000000 0000000 00000000143 14540404546 0031727 0 ustar 00root root 0000000 0000000 # gazelle:python_ignore_dependencies foo,bar, baz
# gazelle:python_ignore_dependencies foo.bar.baz
rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.out 0000664 0000000 0000000 00000000521 14540404546 0032130 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_ignore_dependencies foo,bar, baz
# gazelle:python_ignore_dependencies foo.bar.baz
py_library(
name = "python_ignore_dependencies_directive",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
deps = ["@gazelle_python_test_boto3//:pkg"],
)
rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/README.md 0000664 0000000 0000000 00000000177 14540404546 0032026 0 ustar 00root root 0000000 0000000 # python_ignore_dependencies directive
This test case asserts that the target is generated ignoring some of the
dependencies.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0032026 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/__init__.py 0000664 0000000 0000000 00000001334 14540404546 0032654 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import bar
import boto3
import foo
import foo.bar.baz
from baz import baz as bazfn
_ = foo
_ = bar
_ = bazfn
_ = baz
_ = boto3
rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/gazelle_python.yaml0000664 0000000 0000000 00000001272 14540404546 0034454 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: boto3
pip_deps_repository_name: gazelle_python_test
rules_python-0.22.1/gazelle/python/testdata/python_ignore_dependencies_directive/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0032401 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/ 0000775 0000000 0000000 00000000000 14540404546 0027216 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/BUILD.in 0000664 0000000 0000000 00000000054 14540404546 0030404 0 ustar 00root root 0000000 0000000 # gazelle:python_ignore_files some_other.py
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/BUILD.out 0000664 0000000 0000000 00000000342 14540404546 0030605 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:python_ignore_files some_other.py
py_library(
name = "python_ignore_files_directive",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/README.md 0000664 0000000 0000000 00000000151 14540404546 0030472 0 ustar 00root root 0000000 0000000 # python_ignore_files directive
This test case asserts that no targets are generated for ignored files.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030502 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0031333 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/bar/ 0000775 0000000 0000000 00000000000 14540404546 0027762 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0031137 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.out 0000664 0000000 0000000 00000000254 14540404546 0031353 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "bar",
srcs = ["baz.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/bar/baz.py 0000664 0000000 0000000 00000001166 14540404546 0031114 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/bar/some_other.py 0000664 0000000 0000000 00000001166 14540404546 0032504 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/foo/ 0000775 0000000 0000000 00000000000 14540404546 0030001 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.in 0000664 0000000 0000000 00000000045 14540404546 0031167 0 ustar 00root root 0000000 0000000 # gazelle:python_ignore_files baz.py
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.out 0000664 0000000 0000000 00000000045 14540404546 0031370 0 ustar 00root root 0000000 0000000 # gazelle:python_ignore_files baz.py
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/foo/baz.py 0000664 0000000 0000000 00000001166 14540404546 0031133 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/setup.py 0000664 0000000 0000000 00000001166 14540404546 0030734 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/some_other.py 0000664 0000000 0000000 00000001166 14540404546 0031740 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/python_ignore_files_directive/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0031055 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/ 0000775 0000000 0000000 00000000000 14540404546 0027561 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030736 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/BUILD.out 0000664 0000000 0000000 00000000747 14540404546 0031161 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "python_target_with_test_in_name",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
py_test(
name = "real_test",
srcs = ["real_test.py"],
deps = [
":python_target_with_test_in_name",
"@gazelle_python_test_boto3//:pkg",
],
)
py_test(
name = "test_reality",
srcs = ["test_reality.py"],
deps = [":python_target_with_test_in_name"],
)
rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/README.md 0000664 0000000 0000000 00000000222 14540404546 0031034 0 ustar 00root root 0000000 0000000 # Python target with test in name
Cover the case where a python file either starts with `test_` or ends with `_test`, but is not an actual test.
rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/WORKSPACE 0000664 0000000 0000000 00000000000 14540404546 0031030 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0031676 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/gazelle_python.yaml 0000664 0000000 0000000 00000001272 14540404546 0033473 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: boto3
pip_deps_repository_name: gazelle_python_test
rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/real_test.py 0000664 0000000 0000000 00000001204 14540404546 0032112 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import boto3
import __init__
_ = boto3
rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0031420 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py 0000664 0000000 0000000 00000001205 14540404546 0032641 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import __init__ rules_python-0.22.1/gazelle/python/testdata/relative_imports/ 0000775 0000000 0000000 00000000000 14540404546 0024502 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/relative_imports/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0025657 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/relative_imports/BUILD.out 0000664 0000000 0000000 00000000702 14540404546 0026071 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library")
py_library(
name = "relative_imports",
srcs = [
"package1/module1.py",
"package1/module2.py",
],
visibility = ["//:__subpackages__"],
)
py_binary(
name = "relative_imports_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [
":relative_imports",
"//package2",
],
)
rules_python-0.22.1/gazelle/python/testdata/relative_imports/README.md 0000664 0000000 0000000 00000000163 14540404546 0025761 0 ustar 00root root 0000000 0000000 # Relative imports
This test case asserts that the generated targets handle relative imports in
Python correctly.
rules_python-0.22.1/gazelle/python/testdata/relative_imports/WORKSPACE 0000664 0000000 0000000 00000000047 14540404546 0025764 0 ustar 00root root 0000000 0000000 # This is a test data Bazel workspace.
rules_python-0.22.1/gazelle/python/testdata/relative_imports/__main__.py 0000664 0000000 0000000 00000001321 14540404546 0026571 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from package1.module1 import function1
from package2.module3 import function3
print(function1())
print(function3())
rules_python-0.22.1/gazelle/python/testdata/relative_imports/package1/ 0000775 0000000 0000000 00000000000 14540404546 0026156 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/relative_imports/package1/module1.py 0000664 0000000 0000000 00000001264 14540404546 0030101 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from .module2 import function2
def function1():
return "function1 " + function2()
rules_python-0.22.1/gazelle/python/testdata/relative_imports/package1/module2.py 0000664 0000000 0000000 00000001204 14540404546 0030074 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def function2():
return "function2"
rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/ 0000775 0000000 0000000 00000000000 14540404546 0026157 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027334 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/BUILD.out 0000664 0000000 0000000 00000000423 14540404546 0027546 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "package2",
srcs = [
"__init__.py",
"module3.py",
"module4.py",
"subpackage1/module5.py",
],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/__init__.py 0000664 0000000 0000000 00000001232 14540404546 0030266 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Class1:
def method1(self):
return "method1"
rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/module3.py 0000664 0000000 0000000 00000001374 14540404546 0030106 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from . import Class1
from .subpackage1.module5 import function5
def function3():
c1 = Class1()
return "function3 " + c1.method1() + " " + function5()
rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/module4.py 0000664 0000000 0000000 00000001204 14540404546 0030077 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def function4():
return "function4"
rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/subpackage1/ 0000775 0000000 0000000 00000000000 14540404546 0030345 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/relative_imports/package2/subpackage1/module5.py 0000664 0000000 0000000 00000001265 14540404546 0032275 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..module4 import function4
def function5():
return "function5 " + function4()
rules_python-0.22.1/gazelle/python/testdata/relative_imports/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0026341 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/ 0000775 0000000 0000000 00000000000 14540404546 0025277 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/BUILD.in 0000664 0000000 0000000 00000000503 14540404546 0026464 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
# gazelle:map_kind py_test my_test :mytest.bzl
py_library(
name = "respect_kind_mapping",
srcs = ["__init__.py"],
)
my_test(
name = "respect_kind_mapping_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":respect_kind_mapping"],
)
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/BUILD.out 0000664 0000000 0000000 00000000654 14540404546 0026674 0 ustar 00root root 0000000 0000000 load(":mytest.bzl", "my_test")
load("@rules_python//python:defs.bzl", "py_library")
# gazelle:map_kind py_test my_test :mytest.bzl
py_library(
name = "respect_kind_mapping",
srcs = [
"__init__.py",
"foo.py",
],
visibility = ["//:__subpackages__"],
)
my_test(
name = "respect_kind_mapping_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":respect_kind_mapping"],
)
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/README.md 0000664 0000000 0000000 00000000245 14540404546 0026557 0 ustar 00root root 0000000 0000000 # Respect Kind Mapping
This test case asserts that when using a kind mapping, gazelle will respect that mapping when parsing a BUILD file containing a mapped kind.
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0026563 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/__init__.py 0000664 0000000 0000000 00000001171 14540404546 0027410 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from foo import foo
_ = foo
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/__test__.py 0000664 0000000 0000000 00000001432 14540404546 0027424 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from __init__ import foo
class FooTest(unittest.TestCase):
def test_foo(self):
self.assertEqual("foo", foo())
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/foo.py 0000664 0000000 0000000 00000001170 14540404546 0026433 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def foo():
return "foo"
rules_python-0.22.1/gazelle/python/testdata/respect_kind_mapping/test.yaml 0000664 0000000 0000000 00000001167 14540404546 0027147 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 0
rules_python-0.22.1/gazelle/python/testdata/sibling_imports/ 0000775 0000000 0000000 00000000000 14540404546 0024316 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/sibling_imports/README.md 0000664 0000000 0000000 00000000240 14540404546 0025571 0 ustar 00root root 0000000 0000000 # Sibling imports
This test case asserts that imports from sibling modules are resolved correctly. It covers 3 different types of imports in `pkg/unit_test.py` rules_python-0.22.1/gazelle/python/testdata/sibling_imports/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0025602 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/ 0000775 0000000 0000000 00000000000 14540404546 0025077 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0026254 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/BUILD.out 0000664 0000000 0000000 00000000724 14540404546 0026472 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "pkg",
srcs = [
"__init__.py",
"a.py",
"b.py",
],
imports = [".."],
visibility = ["//:__subpackages__"],
)
py_test(
name = "test_util",
srcs = ["test_util.py"],
imports = [".."],
)
py_test(
name = "unit_test",
srcs = ["unit_test.py"],
imports = [".."],
deps = [
":pkg",
":test_util",
],
)
rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/__init__.py 0000664 0000000 0000000 00000000000 14540404546 0027176 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/a.py 0000664 0000000 0000000 00000000000 14540404546 0025657 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/b.py 0000664 0000000 0000000 00000000023 14540404546 0025665 0 ustar 00root root 0000000 0000000 def run():
pass rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/test_util.py 0000664 0000000 0000000 00000000000 14540404546 0027453 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/sibling_imports/pkg/unit_test.py 0000664 0000000 0000000 00000000053 14540404546 0027465 0 ustar 00root root 0000000 0000000 import a
from b import run
import test_util rules_python-0.22.1/gazelle/python/testdata/sibling_imports/test.yaml 0000664 0000000 0000000 00000000004 14540404546 0026153 0 ustar 00root root 0000000 0000000 ---
rules_python-0.22.1/gazelle/python/testdata/simple_binary/ 0000775 0000000 0000000 00000000000 14540404546 0023747 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_binary/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0025124 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_binary/BUILD.out 0000664 0000000 0000000 00000000301 14540404546 0025331 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "simple_binary_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/simple_binary/README.md 0000664 0000000 0000000 00000000134 14540404546 0025224 0 ustar 00root root 0000000 0000000 # Simple binary
This test case asserts that a simple `py_binary` is generated as expected.
rules_python-0.22.1/gazelle/python/testdata/simple_binary/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0025233 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/simple_binary/__main__.py 0000664 0000000 0000000 00000001166 14540404546 0026045 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/simple_binary/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0025606 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/ 0000775 0000000 0000000 00000000000 14540404546 0026526 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/BUILD.in 0000664 0000000 0000000 00000000472 14540404546 0027720 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "simple_binary_with_library",
srcs = [
"__init__.py",
"bar.py",
"foo.py",
],
)
# This target should be kept unmodified by Gazelle.
py_library(
name = "custom",
srcs = [
"bar.py",
],
)
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/BUILD.out 0000664 0000000 0000000 00000001066 14540404546 0030121 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library")
py_library(
name = "simple_binary_with_library",
srcs = [
"__init__.py",
"bar.py",
"foo.py",
],
visibility = ["//:__subpackages__"],
)
# This target should be kept unmodified by Gazelle.
py_library(
name = "custom",
srcs = [
"bar.py",
],
)
py_binary(
name = "simple_binary_with_library_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [":simple_binary_with_library"],
)
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/README.md 0000664 0000000 0000000 00000000204 14540404546 0030001 0 ustar 00root root 0000000 0000000 # Simple binary with library
This test case asserts that a simple `py_binary` is generated as expected
referencing a `py_library`.
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030012 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0030643 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/__main__.py 0000664 0000000 0000000 00000001201 14540404546 0030612 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import foo
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/bar.py 0000664 0000000 0000000 00000001166 14540404546 0027650 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/foo.py 0000664 0000000 0000000 00000001166 14540404546 0027667 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/simple_binary_with_library/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0030365 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/simple_library/ 0000775 0000000 0000000 00000000000 14540404546 0024127 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_library/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0025304 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_library/BUILD.out 0000664 0000000 0000000 00000000246 14540404546 0025521 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "simple_library",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/simple_library/README.md 0000664 0000000 0000000 00000000136 14540404546 0025406 0 ustar 00root root 0000000 0000000 # Simple library
This test case asserts that a simple `py_library` is generated as expected.
rules_python-0.22.1/gazelle/python/testdata/simple_library/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0025413 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/simple_library/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0026244 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/simple_library/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0025766 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/ 0000775 0000000 0000000 00000000000 14540404546 0026735 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030112 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/BUILD.out 0000664 0000000 0000000 00000000000 14540404546 0030313 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/README.md 0000664 0000000 0000000 00000000275 14540404546 0030220 0 ustar 00root root 0000000 0000000 # Simple library without `__init__.py`
This test case asserts that a simple `py_library` is generated as expected
without an `__init__.py` but with a `BUILD` file marking it as a package.
rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030221 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/foo/ 0000775 0000000 0000000 00000000000 14540404546 0027520 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/foo/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030675 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/foo/BUILD.out 0000664 0000000 0000000 00000000254 14540404546 0031111 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = ["foo.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/foo/foo.py 0000664 0000000 0000000 00000001166 14540404546 0030661 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/simple_library_without_init/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0030574 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/simple_test/ 0000775 0000000 0000000 00000000000 14540404546 0023442 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_test/BUILD.in 0000664 0000000 0000000 00000000172 14540404546 0024631 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "simple_test",
srcs = ["__init__.py"],
)
rules_python-0.22.1/gazelle/python/testdata/simple_test/BUILD.out 0000664 0000000 0000000 00000000515 14540404546 0025033 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "simple_test",
srcs = [
"__init__.py",
"foo.py",
],
visibility = ["//:__subpackages__"],
)
py_test(
name = "simple_test_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [":simple_test"],
)
rules_python-0.22.1/gazelle/python/testdata/simple_test/README.md 0000664 0000000 0000000 00000000130 14540404546 0024713 0 ustar 00root root 0000000 0000000 # Simple test
This test case asserts that a simple `py_test` is generated as expected.
rules_python-0.22.1/gazelle/python/testdata/simple_test/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0024726 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/simple_test/__init__.py 0000664 0000000 0000000 00000001171 14540404546 0025553 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from foo import foo
_ = foo
rules_python-0.22.1/gazelle/python/testdata/simple_test/__test__.py 0000664 0000000 0000000 00000001432 14540404546 0025567 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from __init__ import foo
class FooTest(unittest.TestCase):
def test_foo(self):
self.assertEqual("foo", foo())
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/gazelle/python/testdata/simple_test/foo.py 0000664 0000000 0000000 00000001170 14540404546 0024576 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def foo():
return "foo"
rules_python-0.22.1/gazelle/python/testdata/simple_test/test.yaml 0000664 0000000 0000000 00000001167 14540404546 0025312 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 0
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/ 0000775 0000000 0000000 00000000000 14540404546 0026402 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/BUILD.in 0000664 0000000 0000000 00000000065 14540404546 0027572 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/BUILD.out 0000664 0000000 0000000 00000001033 14540404546 0027767 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "simple_test_with_conftest",
srcs = [
"__init__.py",
"foo.py",
],
visibility = ["//:__subpackages__"],
)
py_library(
name = "conftest",
testonly = True,
srcs = ["conftest.py"],
visibility = ["//:__subpackages__"],
)
py_test(
name = "simple_test_with_conftest_test",
srcs = ["__test__.py"],
main = "__test__.py",
deps = [
":conftest",
":simple_test_with_conftest",
],
)
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/README.md 0000664 0000000 0000000 00000000211 14540404546 0027653 0 ustar 00root root 0000000 0000000 # Simple test with conftest.py
This test case asserts that a simple `py_test` is generated as expected when a
`conftest.py` is present.
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0027666 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/__init__.py 0000664 0000000 0000000 00000001171 14540404546 0030513 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from foo import foo
_ = foo
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/__test__.py 0000664 0000000 0000000 00000001432 14540404546 0030527 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from __init__ import foo
class FooTest(unittest.TestCase):
def test_foo(self):
self.assertEqual("foo", foo())
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/bar/ 0000775 0000000 0000000 00000000000 14540404546 0027146 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.in 0000664 0000000 0000000 00000000065 14540404546 0030336 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.out 0000664 0000000 0000000 00000001033 14540404546 0030533 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "bar",
srcs = [
"__init__.py",
"bar.py",
],
imports = [".."],
visibility = ["//:__subpackages__"],
)
py_library(
name = "conftest",
testonly = True,
srcs = ["conftest.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
py_test(
name = "bar_test",
srcs = ["__test__.py"],
imports = [".."],
main = "__test__.py",
deps = [
":bar",
":conftest",
],
)
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/bar/__init__.py 0000664 0000000 0000000 00000001171 14540404546 0031257 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from bar import bar
_ = bar
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/bar/__test__.py 0000664 0000000 0000000 00000001432 14540404546 0031273 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from __init__ import bar
class BarTest(unittest.TestCase):
def test_bar(self):
self.assertEqual("bar", bar())
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/bar/bar.py 0000664 0000000 0000000 00000001171 14540404546 0030264 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def bar():
return "bar"
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/bar/conftest.py 0000664 0000000 0000000 00000001133 14540404546 0031343 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/conftest.py 0000664 0000000 0000000 00000001134 14540404546 0030600 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/foo.py 0000664 0000000 0000000 00000001170 14540404546 0027536 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def foo():
return "foo"
rules_python-0.22.1/gazelle/python/testdata/simple_test_with_conftest/test.yaml 0000664 0000000 0000000 00000001167 14540404546 0030252 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
expect:
exit_code: 0
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/ 0000775 0000000 0000000 00000000000 14540404546 0024145 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0025322 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/BUILD.out 0000664 0000000 0000000 00000000374 14540404546 0025541 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "subdir_sources_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [
"//foo",
"//one/two",
],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/README.md 0000664 0000000 0000000 00000000324 14540404546 0025423 0 ustar 00root root 0000000 0000000 # Subdir sources
This test case asserts that `py_library` targets are generated with sources from
subdirectories and that dependencies are added according to the target that the
imported source file belongs to.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0025431 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/__main__.py 0000664 0000000 0000000 00000001311 14540404546 0026233 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import foo.bar.bar as bar
import foo.baz.baz as baz
import one.two.three as three
_ = bar
_ = baz
_ = three
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/ 0000775 0000000 0000000 00000000000 14540404546 0024730 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0026105 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/BUILD.out 0000664 0000000 0000000 00000000376 14540404546 0026326 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "foo",
srcs = [
"__init__.py",
"bar/bar.py",
"baz/baz.py",
"foo.py",
],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0027045 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/bar/ 0000775 0000000 0000000 00000000000 14540404546 0025474 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/bar/bar.py 0000664 0000000 0000000 00000001166 14540404546 0026616 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/baz/ 0000775 0000000 0000000 00000000000 14540404546 0025504 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/baz/baz.py 0000664 0000000 0000000 00000001166 14540404546 0026636 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/foo.py 0000664 0000000 0000000 00000001177 14540404546 0026073 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import foo.bar.bar as bar
_ = bar
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build/ 0000775 0000000 0000000 00000000000 14540404546 0026662 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030037 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.out 0000664 0000000 0000000 00000000302 14540404546 0030245 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "has_build",
srcs = ["python/my_module.py"],
imports = ["../.."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build/python/ 0000775 0000000 0000000 00000000000 14540404546 0030203 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build/python/my_module.py 0000664 0000000 0000000 00000001166 14540404546 0032553 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/ 0000775 0000000 0000000 00000000000 14540404546 0030037 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.in 0000664 0000000 0000000 00000000000 14540404546 0032310 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/python/ 0000775 0000000 0000000 00000000000 14540404546 0031360 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py 0000664 0000000 0000000 00000001166 14540404546 0033730 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_init/ 0000775 0000000 0000000 00000000000 14540404546 0026526 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027703 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.out 0000664 0000000 0000000 00000000347 14540404546 0030122 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "has_init",
srcs = [
"__init__.py",
"python/my_module.py",
],
imports = ["../.."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_init/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0030643 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_init/python/ 0000775 0000000 0000000 00000000000 14540404546 0030047 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_init/python/my_module.py 0000664 0000000 0000000 00000001166 14540404546 0032417 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_main/ 0000775 0000000 0000000 00000000000 14540404546 0026507 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027664 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out 0000664 0000000 0000000 00000000611 14540404546 0030075 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library")
py_library(
name = "has_main",
srcs = ["python/my_module.py"],
imports = ["../.."],
visibility = ["//:__subpackages__"],
)
py_binary(
name = "has_main_bin",
srcs = ["__main__.py"],
imports = ["../.."],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [":has_main"],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py 0000664 0000000 0000000 00000001232 14540404546 0030577 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import foo.has_main.python.my_module rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_main/python/ 0000775 0000000 0000000 00000000000 14540404546 0030030 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_main/python/my_module.py 0000664 0000000 0000000 00000001166 14540404546 0032400 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_test/ 0000775 0000000 0000000 00000000000 14540404546 0026542 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0027717 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out 0000664 0000000 0000000 00000000535 14540404546 0030135 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "has_test",
srcs = ["python/my_module.py"],
imports = ["../.."],
visibility = ["//:__subpackages__"],
)
py_test(
name = "has_test_test",
srcs = ["__test__.py"],
imports = ["../.."],
main = "__test__.py",
deps = [":has_test"],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py 0000664 0000000 0000000 00000001232 14540404546 0030665 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
import foo.has_test.python.my_module rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_test/python/ 0000775 0000000 0000000 00000000000 14540404546 0030063 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/foo/has_test/python/my_module.py 0000664 0000000 0000000 00000001166 14540404546 0032433 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/ 0000775 0000000 0000000 00000000000 14540404546 0024726 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0026103 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/BUILD.out 0000664 0000000 0000000 00000000261 14540404546 0026315 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "one",
srcs = ["__init__.py"],
imports = [".."],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0027043 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/two/ 0000775 0000000 0000000 00000000000 14540404546 0025537 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/two/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0026714 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/two/BUILD.out 0000664 0000000 0000000 00000000355 14540404546 0027132 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "two",
srcs = [
"__init__.py",
"three.py",
],
imports = ["../.."],
visibility = ["//:__subpackages__"],
deps = ["//foo"],
)
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/two/README.md 0000664 0000000 0000000 00000000177 14540404546 0027023 0 ustar 00root root 0000000 0000000 # Same package imports
This test case asserts that no `deps` is needed when a module imports another module in the same package rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/two/__init__.py 0000664 0000000 0000000 00000001214 14540404546 0027646 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import foo.baz.baz as baz
import three
_ = baz
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/one/two/three.py 0000664 0000000 0000000 00000001166 14540404546 0027224 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/subdir_sources/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0026004 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/ 0000775 0000000 0000000 00000000000 14540404546 0027270 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030445 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/BUILD.out 0000664 0000000 0000000 00000000346 14540404546 0030663 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "with_nested_import_statements",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
deps = ["@gazelle_python_test_boto3//:pkg"],
)
rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/README.md 0000664 0000000 0000000 00000000260 14540404546 0030545 0 ustar 00root root 0000000 0000000 # With nested import statements
This test case asserts that a `py_library` is generated with dependencies
extracted from nested import statements from the Python source file.
rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030554 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/__init__.py 0000664 0000000 0000000 00000001257 14540404546 0031406 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
_ = os
_ = sys
def main():
import boto3
_ = boto3
rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/gazelle_python.yaml 0000664 0000000 0000000 00000001272 14540404546 0033202 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: boto3
pip_deps_repository_name: gazelle_python_test
rules_python-0.22.1/gazelle/python/testdata/with_nested_import_statements/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0031127 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/with_std_requirements/ 0000775 0000000 0000000 00000000000 14540404546 0025542 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_std_requirements/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0026717 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_std_requirements/BUILD.out 0000664 0000000 0000000 00000000255 14540404546 0027134 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "with_std_requirements",
srcs = ["__init__.py"],
visibility = ["//:__subpackages__"],
)
rules_python-0.22.1/gazelle/python/testdata/with_std_requirements/README.md 0000664 0000000 0000000 00000000234 14540404546 0027020 0 ustar 00root root 0000000 0000000 # With std requirements
This test case asserts that a `py_library` is generated without any `deps` since
it only imports Python standard library packages.
rules_python-0.22.1/gazelle/python/testdata/with_std_requirements/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0027026 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/with_std_requirements/__init__.py 0000664 0000000 0000000 00000001201 14540404546 0027645 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
_ = os
_ = sys
rules_python-0.22.1/gazelle/python/testdata/with_std_requirements/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0027401 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/ 0000775 0000000 0000000 00000000000 14540404546 0027301 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0030456 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/BUILD.out 0000664 0000000 0000000 00000001145 14540404546 0030672 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library")
py_library(
name = "with_third_party_requirements",
srcs = [
"__init__.py",
"bar.py",
"foo.py",
],
visibility = ["//:__subpackages__"],
deps = [
"@gazelle_python_test_baz//:pkg",
"@gazelle_python_test_boto3//:pkg",
"@gazelle_python_test_djangorestframework//:pkg",
],
)
py_binary(
name = "with_third_party_requirements_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = ["@gazelle_python_test_baz//:pkg"],
)
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/README.md 0000664 0000000 0000000 00000000610 14540404546 0030555 0 ustar 00root root 0000000 0000000 # With third-party requirements
This test case asserts that
* a `py_library` is generated with dependencies
extracted from its sources and a `py_binary` is generated embeding the
`py_library` and inherits its dependencies, without specifying the `deps` again.
* when a third-party library and a module in the same package having the same name, the one in the same package takes precedence.
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0030565 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0031416 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/__main__.py 0000664 0000000 0000000 00000001203 14540404546 0031367 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import bar
import foo
_ = bar
_ = foo
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/bar.py 0000664 0000000 0000000 00000001303 14540404546 0030414 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import bar
import boto3
import rest_framework
_ = os
_ = bar
_ = boto3
_ = rest_framework
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/foo.py 0000664 0000000 0000000 00000001305 14540404546 0030435 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import boto3
import foo
import rest_framework
_ = sys
_ = boto3
_ = foo
_ = rest_framework
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/gazelle_python.yaml 0000664 0000000 0000000 00000001374 14540404546 0033216 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
boto3: boto3
rest_framework: djangorestframework
foo: baz
bar: baz
pip_deps_repository_name: gazelle_python_test
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0031140 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/ 0000775 0000000 0000000 00000000000 14540404546 0032101 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.in 0000664 0000000 0000000 00000000000 14540404546 0033256 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.out 0000664 0000000 0000000 00000001260 14540404546 0033470 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary", "py_library")
py_library(
name = "with_third_party_requirements_from_imports",
srcs = [
"__init__.py",
"bar.py",
],
visibility = ["//:__subpackages__"],
deps = [
"@gazelle_python_test_google_cloud_aiplatform//:pkg",
"@gazelle_python_test_google_cloud_storage//:pkg",
],
)
py_binary(
name = "with_third_party_requirements_from_imports_bin",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//:__subpackages__"],
deps = [
":with_third_party_requirements_from_imports",
"@gazelle_python_test_google_cloud_aiplatform//:pkg",
],
)
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/README.md 0000664 0000000 0000000 00000000504 14540404546 0033357 0 ustar 00root root 0000000 0000000 # With third-party requirements (from imports)
This test case covers imports of the form:
```python
from my_pip_dep import foo
```
for example
```python
from google.cloud import aiplatform, storage
```
See https://github.com/bazelbuild/rules_python/issues/709 and https://github.com/sramirezmartin/gazelle-toy-example.
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/WORKSPACE 0000664 0000000 0000000 00000000067 14540404546 0033365 0 ustar 00root root 0000000 0000000 # This is a Bazel workspace for the Gazelle test data.
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/__init__.py 0000664 0000000 0000000 00000001166 14540404546 0034216 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For test purposes only.
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/__main__.py 0000664 0000000 0000000 00000001322 14540404546 0034171 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from bar import main
from google.cloud import aiplatform
if __name__ == "__main__":
print(aiplatform)
main()
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/bar.py 0000664 0000000 0000000 00000001304 14540404546 0033215 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from google.cloud import aiplatform, storage
def main():
a = dir(aiplatform)
b = dir(storage)
gazelle_python.yaml 0000664 0000000 0000000 00000351605 14540404546 0035744 0 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
manifest:
modules_mapping:
cachetools: cachetools
cachetools.__init__: cachetools
cachetools.func: cachetools
cachetools.keys: cachetools
certifi: certifi
certifi.__init__: certifi
certifi.__main__: certifi
certifi.core: certifi
charset_normalizer: charset_normalizer
charset_normalizer.__init__: charset_normalizer
charset_normalizer.api: charset_normalizer
charset_normalizer.assets: charset_normalizer
charset_normalizer.assets.__init__: charset_normalizer
charset_normalizer.cd: charset_normalizer
charset_normalizer.cli: charset_normalizer
charset_normalizer.cli.__init__: charset_normalizer
charset_normalizer.cli.normalizer: charset_normalizer
charset_normalizer.constant: charset_normalizer
charset_normalizer.legacy: charset_normalizer
charset_normalizer.md: charset_normalizer
charset_normalizer.models: charset_normalizer
charset_normalizer.utils: charset_normalizer
charset_normalizer.version: charset_normalizer
dateutil: python_dateutil
dateutil.__init__: python_dateutil
dateutil._common: python_dateutil
dateutil._version: python_dateutil
dateutil.easter: python_dateutil
dateutil.parser: python_dateutil
dateutil.parser.__init__: python_dateutil
dateutil.parser._parser: python_dateutil
dateutil.parser.isoparser: python_dateutil
dateutil.relativedelta: python_dateutil
dateutil.rrule: python_dateutil
dateutil.tz: python_dateutil
dateutil.tz.__init__: python_dateutil
dateutil.tz._common: python_dateutil
dateutil.tz._factories: python_dateutil
dateutil.tz.tz: python_dateutil
dateutil.tz.win: python_dateutil
dateutil.tzwin: python_dateutil
dateutil.utils: python_dateutil
dateutil.zoneinfo: python_dateutil
dateutil.zoneinfo.__init__: python_dateutil
dateutil.zoneinfo.rebuild: python_dateutil
docs.conf: google_cloud_resource_manager
google._async_resumable_media: google_resumable_media
google._async_resumable_media.__init__: google_resumable_media
google._async_resumable_media._download: google_resumable_media
google._async_resumable_media._helpers: google_resumable_media
google._async_resumable_media._upload: google_resumable_media
google._async_resumable_media.requests: google_resumable_media
google._async_resumable_media.requests.__init__: google_resumable_media
google._async_resumable_media.requests._request_helpers: google_resumable_media
google._async_resumable_media.requests.download: google_resumable_media
google._async_resumable_media.requests.upload: google_resumable_media
google.api: googleapis_common_protos
google.api.__init__: googleapis_common_protos
google.api.annotations_pb2: googleapis_common_protos
google.api.auth_pb2: googleapis_common_protos
google.api.backend_pb2: googleapis_common_protos
google.api.billing_pb2: googleapis_common_protos
google.api.client_pb2: googleapis_common_protos
google.api.config_change_pb2: googleapis_common_protos
google.api.consumer_pb2: googleapis_common_protos
google.api.context_pb2: googleapis_common_protos
google.api.control_pb2: googleapis_common_protos
google.api.distribution_pb2: googleapis_common_protos
google.api.documentation_pb2: googleapis_common_protos
google.api.endpoint_pb2: googleapis_common_protos
google.api.error_reason_pb2: googleapis_common_protos
google.api.field_behavior_pb2: googleapis_common_protos
google.api.http_pb2: googleapis_common_protos
google.api.httpbody_pb2: googleapis_common_protos
google.api.label_pb2: googleapis_common_protos
google.api.launch_stage_pb2: googleapis_common_protos
google.api.log_pb2: googleapis_common_protos
google.api.logging_pb2: googleapis_common_protos
google.api.metric_pb2: googleapis_common_protos
google.api.monitored_resource_pb2: googleapis_common_protos
google.api.monitoring_pb2: googleapis_common_protos
google.api.quota_pb2: googleapis_common_protos
google.api.resource_pb2: googleapis_common_protos
google.api.routing_pb2: googleapis_common_protos
google.api.service_pb2: googleapis_common_protos
google.api.source_info_pb2: googleapis_common_protos
google.api.system_parameter_pb2: googleapis_common_protos
google.api.usage_pb2: googleapis_common_protos
google.api.visibility_pb2: googleapis_common_protos
google.api_core: google_api_core
google.api_core.__init__: google_api_core
google.api_core.bidi: google_api_core
google.api_core.client_info: google_api_core
google.api_core.client_options: google_api_core
google.api_core.datetime_helpers: google_api_core
google.api_core.exceptions: google_api_core
google.api_core.extended_operation: google_api_core
google.api_core.future: google_api_core
google.api_core.future.__init__: google_api_core
google.api_core.future._helpers: google_api_core
google.api_core.future.async_future: google_api_core
google.api_core.future.base: google_api_core
google.api_core.future.polling: google_api_core
google.api_core.gapic_v1: google_api_core
google.api_core.gapic_v1.__init__: google_api_core
google.api_core.gapic_v1.client_info: google_api_core
google.api_core.gapic_v1.config: google_api_core
google.api_core.gapic_v1.config_async: google_api_core
google.api_core.gapic_v1.method: google_api_core
google.api_core.gapic_v1.method_async: google_api_core
google.api_core.gapic_v1.routing_header: google_api_core
google.api_core.general_helpers: google_api_core
google.api_core.grpc_helpers: google_api_core
google.api_core.grpc_helpers_async: google_api_core
google.api_core.iam: google_api_core
google.api_core.operation: google_api_core
google.api_core.operation_async: google_api_core
google.api_core.operations_v1: google_api_core
google.api_core.operations_v1.__init__: google_api_core
google.api_core.operations_v1.abstract_operations_client: google_api_core
google.api_core.operations_v1.operations_async_client: google_api_core
google.api_core.operations_v1.operations_client: google_api_core
google.api_core.operations_v1.operations_client_config: google_api_core
google.api_core.operations_v1.pagers: google_api_core
google.api_core.operations_v1.transports: google_api_core
google.api_core.operations_v1.transports.__init__: google_api_core
google.api_core.operations_v1.transports.base: google_api_core
google.api_core.operations_v1.transports.rest: google_api_core
google.api_core.page_iterator: google_api_core
google.api_core.page_iterator_async: google_api_core
google.api_core.path_template: google_api_core
google.api_core.protobuf_helpers: google_api_core
google.api_core.rest_helpers: google_api_core
google.api_core.rest_streaming: google_api_core
google.api_core.retry: google_api_core
google.api_core.retry_async: google_api_core
google.api_core.timeout: google_api_core
google.api_core.version: google_api_core
google.auth: google_auth
google.auth.__init__: google_auth
google.auth._cloud_sdk: google_auth
google.auth._credentials_async: google_auth
google.auth._default: google_auth
google.auth._default_async: google_auth
google.auth._helpers: google_auth
google.auth._jwt_async: google_auth
google.auth._oauth2client: google_auth
google.auth._service_account_info: google_auth
google.auth.app_engine: google_auth
google.auth.aws: google_auth
google.auth.compute_engine: google_auth
google.auth.compute_engine.__init__: google_auth
google.auth.compute_engine._metadata: google_auth
google.auth.compute_engine.credentials: google_auth
google.auth.credentials: google_auth
google.auth.crypt: google_auth
google.auth.crypt.__init__: google_auth
google.auth.crypt._cryptography_rsa: google_auth
google.auth.crypt._helpers: google_auth
google.auth.crypt._python_rsa: google_auth
google.auth.crypt.base: google_auth
google.auth.crypt.es256: google_auth
google.auth.crypt.rsa: google_auth
google.auth.downscoped: google_auth
google.auth.environment_vars: google_auth
google.auth.exceptions: google_auth
google.auth.external_account: google_auth
google.auth.iam: google_auth
google.auth.identity_pool: google_auth
google.auth.impersonated_credentials: google_auth
google.auth.jwt: google_auth
google.auth.transport: google_auth
google.auth.transport.__init__: google_auth
google.auth.transport._aiohttp_requests: google_auth
google.auth.transport._http_client: google_auth
google.auth.transport._mtls_helper: google_auth
google.auth.transport.grpc: google_auth
google.auth.transport.mtls: google_auth
google.auth.transport.requests: google_auth
google.auth.transport.urllib3: google_auth
google.auth.version: google_auth
google.cloud._helpers: google_cloud_core
google.cloud._helpers.__init__: google_cloud_core
google.cloud._http: google_cloud_core
google.cloud._http.__init__: google_cloud_core
google.cloud._testing: google_cloud_core
google.cloud._testing.__init__: google_cloud_core
google.cloud.aiplatform: google_cloud_aiplatform
google.cloud.aiplatform.__init__: google_cloud_aiplatform
google.cloud.aiplatform._matching_engine: google_cloud_aiplatform
google.cloud.aiplatform._matching_engine.__init__: google_cloud_aiplatform
google.cloud.aiplatform._matching_engine.match_service_pb2: google_cloud_aiplatform
google.cloud.aiplatform._matching_engine.match_service_pb2_grpc: google_cloud_aiplatform
google.cloud.aiplatform._matching_engine.matching_engine_index: google_cloud_aiplatform
google.cloud.aiplatform._matching_engine.matching_engine_index_config: google_cloud_aiplatform
google.cloud.aiplatform._matching_engine.matching_engine_index_endpoint: google_cloud_aiplatform
google.cloud.aiplatform.base: google_cloud_aiplatform
google.cloud.aiplatform.compat: google_cloud_aiplatform
google.cloud.aiplatform.compat.__init__: google_cloud_aiplatform
google.cloud.aiplatform.compat.services: google_cloud_aiplatform
google.cloud.aiplatform.compat.services.__init__: google_cloud_aiplatform
google.cloud.aiplatform.compat.types: google_cloud_aiplatform
google.cloud.aiplatform.compat.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.constants: google_cloud_aiplatform
google.cloud.aiplatform.constants.__init__: google_cloud_aiplatform
google.cloud.aiplatform.constants.base: google_cloud_aiplatform
google.cloud.aiplatform.constants.prediction: google_cloud_aiplatform
google.cloud.aiplatform.datasets: google_cloud_aiplatform
google.cloud.aiplatform.datasets.__init__: google_cloud_aiplatform
google.cloud.aiplatform.datasets._datasources: google_cloud_aiplatform
google.cloud.aiplatform.datasets.column_names_dataset: google_cloud_aiplatform
google.cloud.aiplatform.datasets.dataset: google_cloud_aiplatform
google.cloud.aiplatform.datasets.image_dataset: google_cloud_aiplatform
google.cloud.aiplatform.datasets.tabular_dataset: google_cloud_aiplatform
google.cloud.aiplatform.datasets.text_dataset: google_cloud_aiplatform
google.cloud.aiplatform.datasets.time_series_dataset: google_cloud_aiplatform
google.cloud.aiplatform.datasets.video_dataset: google_cloud_aiplatform
google.cloud.aiplatform.explain: google_cloud_aiplatform
google.cloud.aiplatform.explain.__init__: google_cloud_aiplatform
google.cloud.aiplatform.explain.lit: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.__init__: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.metadata_builder: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf.__init__: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf.v1: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf.v1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf.v1.saved_model_metadata_builder: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf.v2: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf.v2.__init__: google_cloud_aiplatform
google.cloud.aiplatform.explain.metadata.tf.v2.saved_model_metadata_builder: google_cloud_aiplatform
google.cloud.aiplatform.featurestore: google_cloud_aiplatform
google.cloud.aiplatform.featurestore.__init__: google_cloud_aiplatform
google.cloud.aiplatform.featurestore.entity_type: google_cloud_aiplatform
google.cloud.aiplatform.featurestore.feature: google_cloud_aiplatform
google.cloud.aiplatform.featurestore.featurestore: google_cloud_aiplatform
google.cloud.aiplatform.gapic: google_cloud_aiplatform
google.cloud.aiplatform.gapic.__init__: google_cloud_aiplatform
google.cloud.aiplatform.gapic.schema: google_cloud_aiplatform
google.cloud.aiplatform.gapic.schema.__init__: google_cloud_aiplatform
google.cloud.aiplatform.helpers: google_cloud_aiplatform
google.cloud.aiplatform.helpers.__init__: google_cloud_aiplatform
google.cloud.aiplatform.helpers.container_uri_builders: google_cloud_aiplatform
google.cloud.aiplatform.hyperparameter_tuning: google_cloud_aiplatform
google.cloud.aiplatform.initializer: google_cloud_aiplatform
google.cloud.aiplatform.jobs: google_cloud_aiplatform
google.cloud.aiplatform.metadata: google_cloud_aiplatform
google.cloud.aiplatform.metadata.__init__: google_cloud_aiplatform
google.cloud.aiplatform.metadata.artifact: google_cloud_aiplatform
google.cloud.aiplatform.metadata.constants: google_cloud_aiplatform
google.cloud.aiplatform.metadata.context: google_cloud_aiplatform
google.cloud.aiplatform.metadata.execution: google_cloud_aiplatform
google.cloud.aiplatform.metadata.metadata: google_cloud_aiplatform
google.cloud.aiplatform.metadata.metadata_store: google_cloud_aiplatform
google.cloud.aiplatform.metadata.resource: google_cloud_aiplatform
google.cloud.aiplatform.model_evaluation: google_cloud_aiplatform
google.cloud.aiplatform.model_evaluation.__init__: google_cloud_aiplatform
google.cloud.aiplatform.model_evaluation.model_evaluation: google_cloud_aiplatform
google.cloud.aiplatform.models: google_cloud_aiplatform
google.cloud.aiplatform.pipeline_jobs: google_cloud_aiplatform
google.cloud.aiplatform.schema: google_cloud_aiplatform
google.cloud.aiplatform.tensorboard: google_cloud_aiplatform
google.cloud.aiplatform.tensorboard.__init__: google_cloud_aiplatform
google.cloud.aiplatform.tensorboard.plugins.tf_profiler.profile_uploader: google_cloud_aiplatform
google.cloud.aiplatform.tensorboard.tensorboard_resource: google_cloud_aiplatform
google.cloud.aiplatform.tensorboard.uploader: google_cloud_aiplatform
google.cloud.aiplatform.tensorboard.uploader_main: google_cloud_aiplatform
google.cloud.aiplatform.tensorboard.uploader_utils: google_cloud_aiplatform
google.cloud.aiplatform.training_jobs: google_cloud_aiplatform
google.cloud.aiplatform.training_utils: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.__init__: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.__init__: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.cloud_profiler_utils: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.initializer: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.plugins.base_plugin: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.plugins.tensorflow.tensorboard_api: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.plugins.tensorflow.tf_profiler: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.webserver: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.cloud_profiler.wsgi_types: google_cloud_aiplatform
google.cloud.aiplatform.training_utils.environment_variables: google_cloud_aiplatform
google.cloud.aiplatform.utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.__init__: google_cloud_aiplatform
google.cloud.aiplatform.utils.column_transformations_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.console_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.enhanced_library: google_cloud_aiplatform
google.cloud.aiplatform.utils.enhanced_library.__init__: google_cloud_aiplatform
google.cloud.aiplatform.utils.enhanced_library._decorators: google_cloud_aiplatform
google.cloud.aiplatform.utils.enhanced_library.value_converter: google_cloud_aiplatform
google.cloud.aiplatform.utils.featurestore_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.gcs_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.pipeline_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.resource_manager_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.source_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.tensorboard_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.worker_spec_utils: google_cloud_aiplatform
google.cloud.aiplatform.utils.yaml_utils: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_extraction: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_sentiment: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.tabular_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.tabular_regression: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.text_extraction: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.text_sentiment: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_tables: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_extraction: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_sentiment: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.export_evaluated_data_items_config: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_extraction: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_sentiment: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.tabular_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.tabular_regression: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.text_extraction: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.text_sentiment: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.time_series_forecasting: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_forecasting: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_object_detection: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_segmentation: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_tables: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_extraction: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_sentiment: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_time_series_forecasting: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_action_recognition: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_classification: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_object_tracking: google_cloud_aiplatform
google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.export_evaluated_data_items_config: google_cloud_aiplatform
google.cloud.aiplatform.version: google_cloud_aiplatform
google.cloud.aiplatform_v1: google_cloud_aiplatform
google.cloud.aiplatform_v1.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.dataset_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.featurestore_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.index_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.job_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.metadata_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.migration_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.model_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.pipeline_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.prediction_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.specialist_pool_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.tensorboard_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1.services.vizier_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1.types: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.accelerator_type: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.annotation: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.annotation_spec: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.artifact: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.batch_prediction_job: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.completion_stats: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.context: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.custom_job: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.data_item: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.data_labeling_job: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.dataset: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.dataset_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.deployed_index_ref: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.deployed_model_ref: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.encryption_spec: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.endpoint: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.entity_type: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.env_var: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.event: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.execution: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.explanation: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.explanation_metadata: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.feature: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.feature_monitoring_stats: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.feature_selector: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.featurestore: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.featurestore_monitoring: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.featurestore_online_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.featurestore_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.hyperparameter_tuning_job: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.index: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.index_endpoint: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.index_endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.index_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.io: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.job_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.job_state: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.lineage_subgraph: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.machine_resources: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.manual_batch_tuning_parameters: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.metadata_schema: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.metadata_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.metadata_store: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.migratable_resource: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.migration_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.model: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.model_deployment_monitoring_job: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.model_evaluation: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.model_evaluation_slice: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.model_monitoring: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.model_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.operation: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.pipeline_job: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.pipeline_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.pipeline_state: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.prediction_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.specialist_pool: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.specialist_pool_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.study: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.tensorboard: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.tensorboard_data: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.tensorboard_experiment: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.tensorboard_run: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.tensorboard_service: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.tensorboard_time_series: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.training_pipeline: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.types: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.unmanaged_container_model: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.user_action_reference: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.value: google_cloud_aiplatform
google.cloud.aiplatform_v1.types.vizier_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.dataset_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.index_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.job_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.metadata_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.migration_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.model_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.prediction_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.async_client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.client: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.pagers: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.transports: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.transports.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.transports.base: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.transports.grpc: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.services.vizier_service.transports.grpc_asyncio: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.__init__: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.accelerator_type: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.annotation: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.annotation_spec: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.artifact: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.batch_prediction_job: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.completion_stats: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.context: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.custom_job: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.data_item: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.data_labeling_job: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.dataset: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.dataset_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.deployed_index_ref: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.deployed_model_ref: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.encryption_spec: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.endpoint: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.entity_type: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.env_var: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.event: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.execution: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.explanation: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.explanation_metadata: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.feature: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.feature_monitoring_stats: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.feature_selector: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.featurestore: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.featurestore_monitoring: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.featurestore_online_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.featurestore_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.hyperparameter_tuning_job: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.index: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.index_endpoint: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.index_endpoint_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.index_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.io: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.job_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.job_state: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.lineage_subgraph: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.machine_resources: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.manual_batch_tuning_parameters: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.metadata_schema: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.metadata_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.metadata_store: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.migratable_resource: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.migration_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.model: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.model_deployment_monitoring_job: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.model_evaluation: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.model_evaluation_slice: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.model_monitoring: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.model_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.operation: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.pipeline_job: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.pipeline_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.pipeline_state: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.prediction_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.specialist_pool: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.specialist_pool_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.study: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.tensorboard: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.tensorboard_data: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.tensorboard_experiment: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.tensorboard_run: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.tensorboard_service: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.tensorboard_time_series: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.training_pipeline: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.types: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.unmanaged_container_model: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.user_action_reference: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.value: google_cloud_aiplatform
google.cloud.aiplatform_v1beta1.types.vizier_service: google_cloud_aiplatform
google.cloud.bigquery: google_cloud_bigquery
google.cloud.bigquery.__init__: google_cloud_bigquery
google.cloud.bigquery._helpers: google_cloud_bigquery
google.cloud.bigquery._http: google_cloud_bigquery
google.cloud.bigquery._pandas_helpers: google_cloud_bigquery
google.cloud.bigquery._tqdm_helpers: google_cloud_bigquery
google.cloud.bigquery.client: google_cloud_bigquery
google.cloud.bigquery.dataset: google_cloud_bigquery
google.cloud.bigquery.dbapi: google_cloud_bigquery
google.cloud.bigquery.dbapi.__init__: google_cloud_bigquery
google.cloud.bigquery.dbapi._helpers: google_cloud_bigquery
google.cloud.bigquery.dbapi.connection: google_cloud_bigquery
google.cloud.bigquery.dbapi.cursor: google_cloud_bigquery
google.cloud.bigquery.dbapi.exceptions: google_cloud_bigquery
google.cloud.bigquery.dbapi.types: google_cloud_bigquery
google.cloud.bigquery.encryption_configuration: google_cloud_bigquery
google.cloud.bigquery.enums: google_cloud_bigquery
google.cloud.bigquery.exceptions: google_cloud_bigquery
google.cloud.bigquery.external_config: google_cloud_bigquery
google.cloud.bigquery.format_options: google_cloud_bigquery
google.cloud.bigquery.iam: google_cloud_bigquery
google.cloud.bigquery.job: google_cloud_bigquery
google.cloud.bigquery.job.__init__: google_cloud_bigquery
google.cloud.bigquery.job.base: google_cloud_bigquery
google.cloud.bigquery.job.copy_: google_cloud_bigquery
google.cloud.bigquery.job.extract: google_cloud_bigquery
google.cloud.bigquery.job.load: google_cloud_bigquery
google.cloud.bigquery.job.query: google_cloud_bigquery
google.cloud.bigquery.magics: google_cloud_bigquery
google.cloud.bigquery.magics.__init__: google_cloud_bigquery
google.cloud.bigquery.magics.line_arg_parser: google_cloud_bigquery
google.cloud.bigquery.magics.line_arg_parser.__init__: google_cloud_bigquery
google.cloud.bigquery.magics.line_arg_parser.exceptions: google_cloud_bigquery
google.cloud.bigquery.magics.line_arg_parser.lexer: google_cloud_bigquery
google.cloud.bigquery.magics.line_arg_parser.parser: google_cloud_bigquery
google.cloud.bigquery.magics.line_arg_parser.visitors: google_cloud_bigquery
google.cloud.bigquery.magics.magics: google_cloud_bigquery
google.cloud.bigquery.model: google_cloud_bigquery
google.cloud.bigquery.opentelemetry_tracing: google_cloud_bigquery
google.cloud.bigquery.query: google_cloud_bigquery
google.cloud.bigquery.retry: google_cloud_bigquery
google.cloud.bigquery.routine: google_cloud_bigquery
google.cloud.bigquery.routine.__init__: google_cloud_bigquery
google.cloud.bigquery.routine.routine: google_cloud_bigquery
google.cloud.bigquery.schema: google_cloud_bigquery
google.cloud.bigquery.table: google_cloud_bigquery
google.cloud.bigquery.version: google_cloud_bigquery
google.cloud.bigquery_v2: google_cloud_bigquery
google.cloud.bigquery_v2.__init__: google_cloud_bigquery
google.cloud.bigquery_v2.types: google_cloud_bigquery
google.cloud.bigquery_v2.types.__init__: google_cloud_bigquery
google.cloud.bigquery_v2.types.encryption_config: google_cloud_bigquery
google.cloud.bigquery_v2.types.model: google_cloud_bigquery
google.cloud.bigquery_v2.types.model_reference: google_cloud_bigquery
google.cloud.bigquery_v2.types.standard_sql: google_cloud_bigquery
google.cloud.bigquery_v2.types.table_reference: google_cloud_bigquery
google.cloud.client: google_cloud_core
google.cloud.client.__init__: google_cloud_core
google.cloud.environment_vars: google_cloud_core
google.cloud.environment_vars.__init__: google_cloud_core
google.cloud.exceptions: google_cloud_core
google.cloud.exceptions.__init__: google_cloud_core
google.cloud.extended_operations_pb2: googleapis_common_protos
google.cloud.location.locations_pb2: googleapis_common_protos
google.cloud.obsolete: google_cloud_core
google.cloud.obsolete.__init__: google_cloud_core
google.cloud.operation: google_cloud_core
google.cloud.operation.__init__: google_cloud_core
google.cloud.resourcemanager: google_cloud_resource_manager
google.cloud.resourcemanager.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3: google_cloud_resource_manager
google.cloud.resourcemanager_v3.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.async_client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.pagers: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.transports: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.transports.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.transports.base: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.transports.grpc: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.folders.transports.grpc_asyncio: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.async_client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.pagers: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.transports: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.transports.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.transports.base: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.transports.grpc: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.organizations.transports.grpc_asyncio: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.async_client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.pagers: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.transports: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.transports.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.transports.base: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.transports.grpc: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.projects.transports.grpc_asyncio: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.async_client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.pagers: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.transports: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.transports.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.transports.base: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.transports.grpc: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_bindings.transports.grpc_asyncio: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.async_client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.pagers: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.transports: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.transports.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.transports.base: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.transports.grpc: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_keys.transports.grpc_asyncio: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.async_client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.client: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.pagers: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.transports: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.transports.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.transports.base: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.transports.grpc: google_cloud_resource_manager
google.cloud.resourcemanager_v3.services.tag_values.transports.grpc_asyncio: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types.__init__: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types.folders: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types.organizations: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types.projects: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types.tag_bindings: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types.tag_keys: google_cloud_resource_manager
google.cloud.resourcemanager_v3.types.tag_values: google_cloud_resource_manager
google.cloud.storage: google_cloud_storage
google.cloud.storage.__init__: google_cloud_storage
google.cloud.storage._helpers: google_cloud_storage
google.cloud.storage._http: google_cloud_storage
google.cloud.storage._signing: google_cloud_storage
google.cloud.storage.acl: google_cloud_storage
google.cloud.storage.batch: google_cloud_storage
google.cloud.storage.blob: google_cloud_storage
google.cloud.storage.bucket: google_cloud_storage
google.cloud.storage.client: google_cloud_storage
google.cloud.storage.constants: google_cloud_storage
google.cloud.storage.fileio: google_cloud_storage
google.cloud.storage.hmac_key: google_cloud_storage
google.cloud.storage.iam: google_cloud_storage
google.cloud.storage.notification: google_cloud_storage
google.cloud.storage.retry: google_cloud_storage
google.cloud.storage.version: google_cloud_storage
google.cloud.version: google_cloud_core
google.gapic.metadata: googleapis_common_protos
google.gapic.metadata.__init__: googleapis_common_protos
google.gapic.metadata.gapic_metadata_pb2: googleapis_common_protos
google.iam.v1: grpc_google_iam_v1
google.iam.v1.__init__: grpc_google_iam_v1
google.iam.v1.iam_policy_pb2: grpc_google_iam_v1
google.iam.v1.iam_policy_pb2_grpc: grpc_google_iam_v1
google.iam.v1.logging: grpc_google_iam_v1
google.iam.v1.logging.__init__: grpc_google_iam_v1
google.iam.v1.logging.audit_data_pb2: grpc_google_iam_v1
google.iam.v1.options_pb2: grpc_google_iam_v1
google.iam.v1.options_pb2_grpc: grpc_google_iam_v1
google.iam.v1.policy_pb2: grpc_google_iam_v1
google.iam.v1.policy_pb2_grpc: grpc_google_iam_v1
google.logging.type: googleapis_common_protos
google.logging.type.__init__: googleapis_common_protos
google.logging.type.http_request_pb2: googleapis_common_protos
google.logging.type.log_severity_pb2: googleapis_common_protos
google.longrunning: googleapis_common_protos
google.longrunning.__init__: googleapis_common_protos
google.longrunning.operations_grpc: googleapis_common_protos
google.longrunning.operations_grpc_pb2: googleapis_common_protos
google.longrunning.operations_pb2: googleapis_common_protos
google.longrunning.operations_pb2_grpc: googleapis_common_protos
google.longrunning.operations_proto: googleapis_common_protos
google.longrunning.operations_proto_pb2: googleapis_common_protos
google.oauth2: google_auth
google.oauth2.__init__: google_auth
google.oauth2._client: google_auth
google.oauth2._client_async: google_auth
google.oauth2._credentials_async: google_auth
google.oauth2._id_token_async: google_auth
google.oauth2._reauth_async: google_auth
google.oauth2._service_account_async: google_auth
google.oauth2.challenges: google_auth
google.oauth2.credentials: google_auth
google.oauth2.id_token: google_auth
google.oauth2.reauth: google_auth
google.oauth2.service_account: google_auth
google.oauth2.sts: google_auth
google.oauth2.utils: google_auth
google.protobuf: protobuf
google.protobuf.__init__: protobuf
google.protobuf.any_pb2: protobuf
google.protobuf.api_pb2: protobuf
google.protobuf.compiler: protobuf
google.protobuf.compiler.__init__: protobuf
google.protobuf.compiler.plugin_pb2: protobuf
google.protobuf.descriptor: protobuf
google.protobuf.descriptor_database: protobuf
google.protobuf.descriptor_pb2: protobuf
google.protobuf.descriptor_pool: protobuf
google.protobuf.duration_pb2: protobuf
google.protobuf.empty_pb2: protobuf
google.protobuf.field_mask_pb2: protobuf
google.protobuf.internal: protobuf
google.protobuf.internal.__init__: protobuf
google.protobuf.internal._api_implementation: protobuf
google.protobuf.internal.api_implementation: protobuf
google.protobuf.internal.builder: protobuf
google.protobuf.internal.containers: protobuf
google.protobuf.internal.decoder: protobuf
google.protobuf.internal.encoder: protobuf
google.protobuf.internal.enum_type_wrapper: protobuf
google.protobuf.internal.extension_dict: protobuf
google.protobuf.internal.message_listener: protobuf
google.protobuf.internal.python_message: protobuf
google.protobuf.internal.type_checkers: protobuf
google.protobuf.internal.well_known_types: protobuf
google.protobuf.internal.wire_format: protobuf
google.protobuf.json_format: protobuf
google.protobuf.message: protobuf
google.protobuf.message_factory: protobuf
google.protobuf.proto_builder: protobuf
google.protobuf.pyext: protobuf
google.protobuf.pyext.__init__: protobuf
google.protobuf.pyext._message: protobuf
google.protobuf.pyext.cpp_message: protobuf
google.protobuf.reflection: protobuf
google.protobuf.service: protobuf
google.protobuf.service_reflection: protobuf
google.protobuf.source_context_pb2: protobuf
google.protobuf.struct_pb2: protobuf
google.protobuf.symbol_database: protobuf
google.protobuf.text_encoding: protobuf
google.protobuf.text_format: protobuf
google.protobuf.timestamp_pb2: protobuf
google.protobuf.type_pb2: protobuf
google.protobuf.util: protobuf
google.protobuf.util.__init__: protobuf
google.protobuf.util.json_format_pb2: protobuf
google.protobuf.util.json_format_proto3_pb2: protobuf
google.protobuf.wrappers_pb2: protobuf
google.resumable_media: google_resumable_media
google.resumable_media.__init__: google_resumable_media
google.resumable_media._download: google_resumable_media
google.resumable_media._helpers: google_resumable_media
google.resumable_media._upload: google_resumable_media
google.resumable_media.common: google_resumable_media
google.resumable_media.requests: google_resumable_media
google.resumable_media.requests.__init__: google_resumable_media
google.resumable_media.requests._request_helpers: google_resumable_media
google.resumable_media.requests.download: google_resumable_media
google.resumable_media.requests.upload: google_resumable_media
google.rpc: googleapis_common_protos
google.rpc.__init__: googleapis_common_protos
google.rpc.code_pb2: googleapis_common_protos
google.rpc.context: googleapis_common_protos
google.rpc.context.__init__: googleapis_common_protos
google.rpc.context.attribute_context_pb2: googleapis_common_protos
google.rpc.error_details_pb2: googleapis_common_protos
google.rpc.status_pb2: googleapis_common_protos
google.type: googleapis_common_protos
google.type.__init__: googleapis_common_protos
google.type.calendar_period_pb2: googleapis_common_protos
google.type.color_pb2: googleapis_common_protos
google.type.date_pb2: googleapis_common_protos
google.type.datetime_pb2: googleapis_common_protos
google.type.dayofweek_pb2: googleapis_common_protos
google.type.decimal_pb2: googleapis_common_protos
google.type.expr_pb2: googleapis_common_protos
google.type.fraction_pb2: googleapis_common_protos
google.type.interval_pb2: googleapis_common_protos
google.type.latlng_pb2: googleapis_common_protos
google.type.localized_text_pb2: googleapis_common_protos
google.type.money_pb2: googleapis_common_protos
google.type.month_pb2: googleapis_common_protos
google.type.phone_number_pb2: googleapis_common_protos
google.type.postal_address_pb2: googleapis_common_protos
google.type.quaternion_pb2: googleapis_common_protos
google.type.timeofday_pb2: googleapis_common_protos
google_crc32c: google_crc32c
google_crc32c.__config__: google_crc32c
google_crc32c.__init__: google_crc32c
google_crc32c._checksum: google_crc32c
google_crc32c._crc32c: google_crc32c
google_crc32c.cext: google_crc32c
google_crc32c.libs.libcrc32c-672e1704: google_crc32c
google_crc32c.python: google_crc32c
grpc: grpcio
grpc.__init__: grpcio
grpc._auth: grpcio
grpc._channel: grpcio
grpc._common: grpcio
grpc._compression: grpcio
grpc._cython: grpcio
grpc._cython.__init__: grpcio
grpc._cython._cygrpc: grpcio
grpc._cython._cygrpc.__init__: grpcio
grpc._cython.cygrpc: grpcio
grpc._grpcio_metadata: grpcio
grpc._interceptor: grpcio
grpc._plugin_wrapping: grpcio
grpc._runtime_protos: grpcio
grpc._server: grpcio
grpc._simple_stubs: grpcio
grpc._utilities: grpcio
grpc.aio: grpcio
grpc.aio.__init__: grpcio
grpc.aio._base_call: grpcio
grpc.aio._base_channel: grpcio
grpc.aio._base_server: grpcio
grpc.aio._call: grpcio
grpc.aio._channel: grpcio
grpc.aio._interceptor: grpcio
grpc.aio._metadata: grpcio
grpc.aio._server: grpcio
grpc.aio._typing: grpcio
grpc.aio._utils: grpcio
grpc.beta: grpcio
grpc.beta.__init__: grpcio
grpc.beta._client_adaptations: grpcio
grpc.beta._metadata: grpcio
grpc.beta._server_adaptations: grpcio
grpc.beta.implementations: grpcio
grpc.beta.interfaces: grpcio
grpc.beta.utilities: grpcio
grpc.experimental: grpcio
grpc.experimental.__init__: grpcio
grpc.experimental.aio: grpcio
grpc.experimental.aio.__init__: grpcio
grpc.experimental.gevent: grpcio
grpc.experimental.session_cache: grpcio
grpc.framework: grpcio
grpc.framework.__init__: grpcio
grpc.framework.common: grpcio
grpc.framework.common.__init__: grpcio
grpc.framework.common.cardinality: grpcio
grpc.framework.common.style: grpcio
grpc.framework.foundation: grpcio
grpc.framework.foundation.__init__: grpcio
grpc.framework.foundation.abandonment: grpcio
grpc.framework.foundation.callable_util: grpcio
grpc.framework.foundation.future: grpcio
grpc.framework.foundation.logging_pool: grpcio
grpc.framework.foundation.stream: grpcio
grpc.framework.foundation.stream_util: grpcio
grpc.framework.interfaces: grpcio
grpc.framework.interfaces.__init__: grpcio
grpc.framework.interfaces.base: grpcio
grpc.framework.interfaces.base.__init__: grpcio
grpc.framework.interfaces.base.base: grpcio
grpc.framework.interfaces.base.utilities: grpcio
grpc.framework.interfaces.face: grpcio
grpc.framework.interfaces.face.__init__: grpcio
grpc.framework.interfaces.face.face: grpcio
grpc.framework.interfaces.face.utilities: grpcio
grpc_status: grpcio_status
grpc_status.__init__: grpcio_status
grpc_status._async: grpcio_status
grpc_status._common: grpcio_status
grpc_status.rpc_status: grpcio_status
idna: idna
idna.__init__: idna
idna.codec: idna
idna.compat: idna
idna.core: idna
idna.idnadata: idna
idna.intranges: idna
idna.package_data: idna
idna.uts46data: idna
packaging: packaging
packaging.__about__: packaging
packaging.__init__: packaging
packaging._manylinux: packaging
packaging._musllinux: packaging
packaging._structures: packaging
packaging.markers: packaging
packaging.requirements: packaging
packaging.specifiers: packaging
packaging.tags: packaging
packaging.utils: packaging
packaging.version: packaging
proto: proto_plus
proto.__init__: proto_plus
proto._file_info: proto_plus
proto._package_info: proto_plus
proto.datetime_helpers: proto_plus
proto.enums: proto_plus
proto.fields: proto_plus
proto.marshal: proto_plus
proto.marshal.__init__: proto_plus
proto.marshal.collections: proto_plus
proto.marshal.collections.__init__: proto_plus
proto.marshal.collections.maps: proto_plus
proto.marshal.collections.repeated: proto_plus
proto.marshal.compat: proto_plus
proto.marshal.marshal: proto_plus
proto.marshal.rules: proto_plus
proto.marshal.rules.__init__: proto_plus
proto.marshal.rules.bytes: proto_plus
proto.marshal.rules.dates: proto_plus
proto.marshal.rules.enums: proto_plus
proto.marshal.rules.message: proto_plus
proto.marshal.rules.stringy_numbers: proto_plus
proto.marshal.rules.struct: proto_plus
proto.marshal.rules.wrappers: proto_plus
proto.message: proto_plus
proto.modules: proto_plus
proto.primitives: proto_plus
proto.utils: proto_plus
pyasn1: pyasn1
pyasn1.__init__: pyasn1
pyasn1.codec: pyasn1
pyasn1.codec.__init__: pyasn1
pyasn1.codec.ber: pyasn1
pyasn1.codec.ber.__init__: pyasn1
pyasn1.codec.ber.decoder: pyasn1
pyasn1.codec.ber.encoder: pyasn1
pyasn1.codec.ber.eoo: pyasn1
pyasn1.codec.cer: pyasn1
pyasn1.codec.cer.__init__: pyasn1
pyasn1.codec.cer.decoder: pyasn1
pyasn1.codec.cer.encoder: pyasn1
pyasn1.codec.der: pyasn1
pyasn1.codec.der.__init__: pyasn1
pyasn1.codec.der.decoder: pyasn1
pyasn1.codec.der.encoder: pyasn1
pyasn1.codec.native: pyasn1
pyasn1.codec.native.__init__: pyasn1
pyasn1.codec.native.decoder: pyasn1
pyasn1.codec.native.encoder: pyasn1
pyasn1.compat: pyasn1
pyasn1.compat.__init__: pyasn1
pyasn1.compat.binary: pyasn1
pyasn1.compat.calling: pyasn1
pyasn1.compat.dateandtime: pyasn1
pyasn1.compat.integer: pyasn1
pyasn1.compat.octets: pyasn1
pyasn1.compat.string: pyasn1
pyasn1.debug: pyasn1
pyasn1.error: pyasn1
pyasn1.type: pyasn1
pyasn1.type.__init__: pyasn1
pyasn1.type.base: pyasn1
pyasn1.type.char: pyasn1
pyasn1.type.constraint: pyasn1
pyasn1.type.error: pyasn1
pyasn1.type.namedtype: pyasn1
pyasn1.type.namedval: pyasn1
pyasn1.type.opentype: pyasn1
pyasn1.type.tag: pyasn1
pyasn1.type.tagmap: pyasn1
pyasn1.type.univ: pyasn1
pyasn1.type.useful: pyasn1
pyasn1_modules: pyasn1_modules
pyasn1_modules.__init__: pyasn1_modules
pyasn1_modules.pem: pyasn1_modules
pyasn1_modules.rfc1155: pyasn1_modules
pyasn1_modules.rfc1157: pyasn1_modules
pyasn1_modules.rfc1901: pyasn1_modules
pyasn1_modules.rfc1902: pyasn1_modules
pyasn1_modules.rfc1905: pyasn1_modules
pyasn1_modules.rfc2251: pyasn1_modules
pyasn1_modules.rfc2314: pyasn1_modules
pyasn1_modules.rfc2315: pyasn1_modules
pyasn1_modules.rfc2437: pyasn1_modules
pyasn1_modules.rfc2459: pyasn1_modules
pyasn1_modules.rfc2511: pyasn1_modules
pyasn1_modules.rfc2560: pyasn1_modules
pyasn1_modules.rfc2631: pyasn1_modules
pyasn1_modules.rfc2634: pyasn1_modules
pyasn1_modules.rfc2985: pyasn1_modules
pyasn1_modules.rfc2986: pyasn1_modules
pyasn1_modules.rfc3114: pyasn1_modules
pyasn1_modules.rfc3161: pyasn1_modules
pyasn1_modules.rfc3274: pyasn1_modules
pyasn1_modules.rfc3279: pyasn1_modules
pyasn1_modules.rfc3280: pyasn1_modules
pyasn1_modules.rfc3281: pyasn1_modules
pyasn1_modules.rfc3412: pyasn1_modules
pyasn1_modules.rfc3414: pyasn1_modules
pyasn1_modules.rfc3447: pyasn1_modules
pyasn1_modules.rfc3560: pyasn1_modules
pyasn1_modules.rfc3565: pyasn1_modules
pyasn1_modules.rfc3709: pyasn1_modules
pyasn1_modules.rfc3770: pyasn1_modules
pyasn1_modules.rfc3779: pyasn1_modules
pyasn1_modules.rfc3852: pyasn1_modules
pyasn1_modules.rfc4043: pyasn1_modules
pyasn1_modules.rfc4055: pyasn1_modules
pyasn1_modules.rfc4073: pyasn1_modules
pyasn1_modules.rfc4108: pyasn1_modules
pyasn1_modules.rfc4210: pyasn1_modules
pyasn1_modules.rfc4211: pyasn1_modules
pyasn1_modules.rfc4334: pyasn1_modules
pyasn1_modules.rfc4985: pyasn1_modules
pyasn1_modules.rfc5035: pyasn1_modules
pyasn1_modules.rfc5083: pyasn1_modules
pyasn1_modules.rfc5084: pyasn1_modules
pyasn1_modules.rfc5208: pyasn1_modules
pyasn1_modules.rfc5280: pyasn1_modules
pyasn1_modules.rfc5480: pyasn1_modules
pyasn1_modules.rfc5649: pyasn1_modules
pyasn1_modules.rfc5652: pyasn1_modules
pyasn1_modules.rfc5751: pyasn1_modules
pyasn1_modules.rfc5755: pyasn1_modules
pyasn1_modules.rfc5913: pyasn1_modules
pyasn1_modules.rfc5914: pyasn1_modules
pyasn1_modules.rfc5915: pyasn1_modules
pyasn1_modules.rfc5916: pyasn1_modules
pyasn1_modules.rfc5917: pyasn1_modules
pyasn1_modules.rfc5924: pyasn1_modules
pyasn1_modules.rfc5934: pyasn1_modules
pyasn1_modules.rfc5940: pyasn1_modules
pyasn1_modules.rfc5958: pyasn1_modules
pyasn1_modules.rfc5990: pyasn1_modules
pyasn1_modules.rfc6010: pyasn1_modules
pyasn1_modules.rfc6019: pyasn1_modules
pyasn1_modules.rfc6031: pyasn1_modules
pyasn1_modules.rfc6032: pyasn1_modules
pyasn1_modules.rfc6120: pyasn1_modules
pyasn1_modules.rfc6170: pyasn1_modules
pyasn1_modules.rfc6187: pyasn1_modules
pyasn1_modules.rfc6210: pyasn1_modules
pyasn1_modules.rfc6211: pyasn1_modules
pyasn1_modules.rfc6402: pyasn1_modules
pyasn1_modules.rfc6402-1: pyasn1_modules
pyasn1_modules.rfc6482: pyasn1_modules
pyasn1_modules.rfc6486: pyasn1_modules
pyasn1_modules.rfc6487: pyasn1_modules
pyasn1_modules.rfc6664: pyasn1_modules
pyasn1_modules.rfc6955: pyasn1_modules
pyasn1_modules.rfc6960: pyasn1_modules
pyasn1_modules.rfc7030: pyasn1_modules
pyasn1_modules.rfc7191: pyasn1_modules
pyasn1_modules.rfc7229: pyasn1_modules
pyasn1_modules.rfc7292: pyasn1_modules
pyasn1_modules.rfc7296: pyasn1_modules
pyasn1_modules.rfc7508: pyasn1_modules
pyasn1_modules.rfc7585: pyasn1_modules
pyasn1_modules.rfc7633: pyasn1_modules
pyasn1_modules.rfc7773: pyasn1_modules
pyasn1_modules.rfc7894: pyasn1_modules
pyasn1_modules.rfc7894-1: pyasn1_modules
pyasn1_modules.rfc7906: pyasn1_modules
pyasn1_modules.rfc7914: pyasn1_modules
pyasn1_modules.rfc8017: pyasn1_modules
pyasn1_modules.rfc8018: pyasn1_modules
pyasn1_modules.rfc8103: pyasn1_modules
pyasn1_modules.rfc8209: pyasn1_modules
pyasn1_modules.rfc8226: pyasn1_modules
pyasn1_modules.rfc8358: pyasn1_modules
pyasn1_modules.rfc8360: pyasn1_modules
pyasn1_modules.rfc8398: pyasn1_modules
pyasn1_modules.rfc8410: pyasn1_modules
pyasn1_modules.rfc8418: pyasn1_modules
pyasn1_modules.rfc8419: pyasn1_modules
pyasn1_modules.rfc8479: pyasn1_modules
pyasn1_modules.rfc8494: pyasn1_modules
pyasn1_modules.rfc8520: pyasn1_modules
pyasn1_modules.rfc8619: pyasn1_modules
pyasn1_modules.rfc8649: pyasn1_modules
pyparsing: pyparsing
pyparsing.__init__: pyparsing
pyparsing.actions: pyparsing
pyparsing.common: pyparsing
pyparsing.core: pyparsing
pyparsing.diagram: pyparsing
pyparsing.diagram.__init__: pyparsing
pyparsing.exceptions: pyparsing
pyparsing.helpers: pyparsing
pyparsing.results: pyparsing
pyparsing.testing: pyparsing
pyparsing.unicode: pyparsing
pyparsing.util: pyparsing
requests: requests
requests.__init__: requests
requests.__version__: requests
requests._internal_utils: requests
requests.adapters: requests
requests.api: requests
requests.auth: requests
requests.certs: requests
requests.compat: requests
requests.cookies: requests
requests.exceptions: requests
requests.help: requests
requests.hooks: requests
requests.models: requests
requests.packages: requests
requests.sessions: requests
requests.status_codes: requests
requests.structures: requests
requests.utils: requests
rsa: rsa
rsa.__init__: rsa
rsa._compat: rsa
rsa.asn1: rsa
rsa.cli: rsa
rsa.common: rsa
rsa.core: rsa
rsa.key: rsa
rsa.parallel: rsa
rsa.pem: rsa
rsa.pkcs1: rsa
rsa.pkcs1_v2: rsa
rsa.prime: rsa
rsa.randnum: rsa
rsa.transform: rsa
rsa.util: rsa
samples.generated_samples.cloudresourcemanager_v3_generated_folders_create_folder_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_create_folder_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_delete_folder_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_delete_folder_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_folder_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_folder_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_list_folders_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_list_folders_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_move_folder_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_move_folder_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_search_folders_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_search_folders_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_set_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_set_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_test_iam_permissions_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_test_iam_permissions_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_undelete_folder_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_undelete_folder_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_update_folder_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_folders_update_folder_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_organization_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_organization_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_search_organizations_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_search_organizations_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_set_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_set_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_test_iam_permissions_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_organizations_test_iam_permissions_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_create_project_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_create_project_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_delete_project_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_delete_project_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_project_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_project_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_list_projects_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_list_projects_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_move_project_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_move_project_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_search_projects_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_search_projects_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_set_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_set_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_test_iam_permissions_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_test_iam_permissions_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_undelete_project_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_undelete_project_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_update_project_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_projects_update_project_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_create_tag_binding_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_create_tag_binding_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_delete_tag_binding_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_delete_tag_binding_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_list_tag_bindings_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_list_tag_bindings_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_create_tag_key_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_create_tag_key_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_delete_tag_key_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_delete_tag_key_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_tag_key_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_tag_key_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_list_tag_keys_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_list_tag_keys_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_set_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_set_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_test_iam_permissions_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_test_iam_permissions_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_update_tag_key_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_update_tag_key_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_create_tag_value_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_create_tag_value_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_delete_tag_value_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_delete_tag_value_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_tag_value_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_tag_value_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_list_tag_values_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_list_tag_values_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_set_iam_policy_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_set_iam_policy_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_test_iam_permissions_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_test_iam_permissions_sync: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_update_tag_value_async: google_cloud_resource_manager
samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_update_tag_value_sync: google_cloud_resource_manager
scripts.fixup_resourcemanager_v3_keywords: google_cloud_resource_manager
scripts.readme-gen.readme_gen: google_cloud_resource_manager
six: six
tests: google_cloud_resource_manager
tests.__init__: google_cloud_resource_manager
tests.unit: google_cloud_resource_manager
tests.unit.__init__: google_cloud_resource_manager
tests.unit.gapic: google_cloud_resource_manager
tests.unit.gapic.__init__: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3.__init__: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3.test_folders: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3.test_organizations: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3.test_projects: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3.test_tag_bindings: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3.test_tag_keys: google_cloud_resource_manager
tests.unit.gapic.resourcemanager_v3.test_tag_values: google_cloud_resource_manager
urllib3: urllib3
urllib3.__init__: urllib3
urllib3._collections: urllib3
urllib3._version: urllib3
urllib3.connection: urllib3
urllib3.connectionpool: urllib3
urllib3.contrib: urllib3
urllib3.contrib.__init__: urllib3
urllib3.contrib._appengine_environ: urllib3
urllib3.contrib._securetransport: urllib3
urllib3.contrib._securetransport.__init__: urllib3
urllib3.contrib._securetransport.bindings: urllib3
urllib3.contrib._securetransport.low_level: urllib3
urllib3.contrib.appengine: urllib3
urllib3.contrib.ntlmpool: urllib3
urllib3.contrib.pyopenssl: urllib3
urllib3.contrib.securetransport: urllib3
urllib3.contrib.socks: urllib3
urllib3.exceptions: urllib3
urllib3.fields: urllib3
urllib3.filepost: urllib3
urllib3.packages: urllib3
urllib3.packages.__init__: urllib3
urllib3.packages.backports: urllib3
urllib3.packages.backports.__init__: urllib3
urllib3.packages.backports.makefile: urllib3
urllib3.packages.six: urllib3
urllib3.poolmanager: urllib3
urllib3.request: urllib3
urllib3.response: urllib3
urllib3.util: urllib3
urllib3.util.__init__: urllib3
urllib3.util.connection: urllib3
urllib3.util.proxy: urllib3
urllib3.util.queue: urllib3
urllib3.util.request: urllib3
urllib3.util.response: urllib3
urllib3.util.retry: urllib3
urllib3.util.ssl_: urllib3
urllib3.util.ssl_match_hostname: urllib3
urllib3.util.ssltransport: urllib3
urllib3.util.timeout: urllib3
urllib3.util.url: urllib3
urllib3.util.wait: urllib3
pip_repository:
name: gazelle_python_test
integrity: 32e38932043eca090a64ca741758d8e4a5817c2cd7dc821fc927914c32fb3114
rules_python-0.22.1/gazelle/python/testdata/with_third_party_requirements_from_imports/test.yaml 0000664 0000000 0000000 00000001140 14540404546 0033740 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
rules_python-0.22.1/gazelle/pythonconfig/ 0000775 0000000 0000000 00000000000 14540404546 0020467 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/gazelle/pythonconfig/BUILD.bazel 0000664 0000000 0000000 00000001221 14540404546 0022341 0 ustar 00root root 0000000 0000000 load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "pythonconfig",
srcs = [
"pythonconfig.go",
"types.go",
],
importpath = "github.com/bazelbuild/rules_python/gazelle/pythonconfig",
visibility = ["//visibility:public"],
deps = [
"//manifest",
"@bazel_gazelle//label:go_default_library",
"@com_github_emirpasic_gods//lists/singlylinkedlist",
],
)
go_test(
name = "pythonconfig_test",
srcs = ["pythonconfig_test.go"],
deps = [":pythonconfig"],
)
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//:__pkg__"],
)
rules_python-0.22.1/gazelle/pythonconfig/pythonconfig.go 0000664 0000000 0000000 00000032020 14540404546 0023522 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package pythonconfig
import (
"fmt"
"path/filepath"
"strings"
"github.com/emirpasic/gods/lists/singlylinkedlist"
"github.com/bazelbuild/bazel-gazelle/label"
"github.com/bazelbuild/rules_python/gazelle/manifest"
)
// Directives
const (
// PythonExtensionDirective represents the directive that controls whether
// this Python extension is enabled or not. Sub-packages inherit this value.
// Can be either "enabled" or "disabled". Defaults to "enabled".
PythonExtensionDirective = "python_extension"
// PythonRootDirective represents the directive that sets a Bazel package as
// a Python root. This is used on monorepos with multiple Python projects
// that don't share the top-level of the workspace as the root.
PythonRootDirective = "python_root"
// PythonManifestFileNameDirective represents the directive that overrides
// the default gazelle_python.yaml manifest file name.
PythonManifestFileNameDirective = "python_manifest_file_name"
// IgnoreFilesDirective represents the directive that controls the ignored
// files from the generated targets.
IgnoreFilesDirective = "python_ignore_files"
// IgnoreDependenciesDirective represents the directive that controls the
// ignored dependencies from the generated targets.
IgnoreDependenciesDirective = "python_ignore_dependencies"
// ValidateImportStatementsDirective represents the directive that controls
// whether the Python import statements should be validated.
ValidateImportStatementsDirective = "python_validate_import_statements"
// GenerationMode represents the directive that controls the target generation
// mode. See below for the GenerationModeType constants.
GenerationMode = "python_generation_mode"
// LibraryNamingConvention represents the directive that controls the
// py_library naming convention. It interpolates $package_name$ with the
// Bazel package name. E.g. if the Bazel package name is `foo`, setting this
// to `$package_name$_my_lib` would render to `foo_my_lib`.
LibraryNamingConvention = "python_library_naming_convention"
// BinaryNamingConvention represents the directive that controls the
// py_binary naming convention. See python_library_naming_convention for
// more info on the package name interpolation.
BinaryNamingConvention = "python_binary_naming_convention"
// TestNamingConvention represents the directive that controls the py_test
// naming convention. See python_library_naming_convention for more info on
// the package name interpolation.
TestNamingConvention = "python_test_naming_convention"
)
// GenerationModeType represents one of the generation modes for the Python
// extension.
type GenerationModeType string
// Generation modes
const (
// GenerationModePackage defines the mode in which targets will be generated
// for each __init__.py, or when an existing BUILD or BUILD.bazel file already
// determines a Bazel package.
GenerationModePackage GenerationModeType = "package"
// GenerationModeProject defines the mode in which a coarse-grained target will
// be generated englobing sub-directories containing Python files.
GenerationModeProject GenerationModeType = "project"
)
const (
packageNameNamingConventionSubstitution = "$package_name$"
)
// defaultIgnoreFiles is the list of default values used in the
// python_ignore_files option.
var defaultIgnoreFiles = map[string]struct{}{
"setup.py": {},
}
func SanitizeDistribution(distributionName string) string {
sanitizedDistribution := strings.ToLower(distributionName)
sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, "-", "_")
sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, ".", "_")
return sanitizedDistribution
}
// Configs is an extension of map[string]*Config. It provides finding methods
// on top of the mapping.
type Configs map[string]*Config
// ParentForPackage returns the parent Config for the given Bazel package.
func (c *Configs) ParentForPackage(pkg string) *Config {
dir := filepath.Dir(pkg)
if dir == "." {
dir = ""
}
parent := (map[string]*Config)(*c)[dir]
return parent
}
// Config represents a config extension for a specific Bazel package.
type Config struct {
parent *Config
extensionEnabled bool
repoRoot string
pythonProjectRoot string
gazelleManifest *manifest.Manifest
excludedPatterns *singlylinkedlist.List
ignoreFiles map[string]struct{}
ignoreDependencies map[string]struct{}
validateImportStatements bool
coarseGrainedGeneration bool
libraryNamingConvention string
binaryNamingConvention string
testNamingConvention string
}
// New creates a new Config.
func New(
repoRoot string,
pythonProjectRoot string,
) *Config {
return &Config{
extensionEnabled: true,
repoRoot: repoRoot,
pythonProjectRoot: pythonProjectRoot,
excludedPatterns: singlylinkedlist.New(),
ignoreFiles: make(map[string]struct{}),
ignoreDependencies: make(map[string]struct{}),
validateImportStatements: true,
coarseGrainedGeneration: false,
libraryNamingConvention: packageNameNamingConventionSubstitution,
binaryNamingConvention: fmt.Sprintf("%s_bin", packageNameNamingConventionSubstitution),
testNamingConvention: fmt.Sprintf("%s_test", packageNameNamingConventionSubstitution),
}
}
// Parent returns the parent config.
func (c *Config) Parent() *Config {
return c.parent
}
// NewChild creates a new child Config. It inherits desired values from the
// current Config and sets itself as the parent to the child.
func (c *Config) NewChild() *Config {
return &Config{
parent: c,
extensionEnabled: c.extensionEnabled,
repoRoot: c.repoRoot,
pythonProjectRoot: c.pythonProjectRoot,
excludedPatterns: c.excludedPatterns,
ignoreFiles: make(map[string]struct{}),
ignoreDependencies: make(map[string]struct{}),
validateImportStatements: c.validateImportStatements,
coarseGrainedGeneration: c.coarseGrainedGeneration,
libraryNamingConvention: c.libraryNamingConvention,
binaryNamingConvention: c.binaryNamingConvention,
testNamingConvention: c.testNamingConvention,
}
}
// AddExcludedPattern adds a glob pattern parsed from the standard
// gazelle:exclude directive.
func (c *Config) AddExcludedPattern(pattern string) {
c.excludedPatterns.Add(pattern)
}
// ExcludedPatterns returns the excluded patterns list.
func (c *Config) ExcludedPatterns() *singlylinkedlist.List {
return c.excludedPatterns
}
// SetExtensionEnabled sets whether the extension is enabled or not.
func (c *Config) SetExtensionEnabled(enabled bool) {
c.extensionEnabled = enabled
}
// ExtensionEnabled returns whether the extension is enabled or not.
func (c *Config) ExtensionEnabled() bool {
return c.extensionEnabled
}
// SetPythonProjectRoot sets the Python project root.
func (c *Config) SetPythonProjectRoot(pythonProjectRoot string) {
c.pythonProjectRoot = pythonProjectRoot
}
// PythonProjectRoot returns the Python project root.
func (c *Config) PythonProjectRoot() string {
return c.pythonProjectRoot
}
// SetGazelleManifest sets the Gazelle manifest parsed from the
// gazelle_python.yaml file.
func (c *Config) SetGazelleManifest(gazelleManifest *manifest.Manifest) {
c.gazelleManifest = gazelleManifest
}
// FindThirdPartyDependency scans the gazelle manifests for the current config
// and the parent configs up to the root finding if it can resolve the module
// name.
func (c *Config) FindThirdPartyDependency(modName string) (string, bool) {
for currentCfg := c; currentCfg != nil; currentCfg = currentCfg.parent {
if currentCfg.gazelleManifest != nil {
gazelleManifest := currentCfg.gazelleManifest
if distributionName, ok := gazelleManifest.ModulesMapping[modName]; ok {
var distributionRepositoryName string
if gazelleManifest.PipDepsRepositoryName != "" {
distributionRepositoryName = gazelleManifest.PipDepsRepositoryName
} else if gazelleManifest.PipRepository != nil {
distributionRepositoryName = gazelleManifest.PipRepository.Name
}
sanitizedDistribution := SanitizeDistribution(distributionName)
if gazelleManifest.PipRepository != nil && gazelleManifest.PipRepository.UsePipRepositoryAliases {
// @//
lbl := label.New(distributionRepositoryName, sanitizedDistribution, sanitizedDistribution)
return lbl.String(), true
}
// @_//:pkg
distributionRepositoryName = distributionRepositoryName + "_" + sanitizedDistribution
lbl := label.New(distributionRepositoryName, "", "pkg")
return lbl.String(), true
}
}
}
return "", false
}
// AddIgnoreFile adds a file to the list of ignored files for a given package.
// Adding an ignored file to a package also makes it ignored on a subpackage.
func (c *Config) AddIgnoreFile(file string) {
c.ignoreFiles[strings.TrimSpace(file)] = struct{}{}
}
// IgnoresFile checks if a file is ignored in the given package or in one of the
// parent packages up to the workspace root.
func (c *Config) IgnoresFile(file string) bool {
trimmedFile := strings.TrimSpace(file)
if _, ignores := defaultIgnoreFiles[trimmedFile]; ignores {
return true
}
if _, ignores := c.ignoreFiles[trimmedFile]; ignores {
return true
}
parent := c.parent
for parent != nil {
if _, ignores := parent.ignoreFiles[trimmedFile]; ignores {
return true
}
parent = parent.parent
}
return false
}
// AddIgnoreDependency adds a dependency to the list of ignored dependencies for
// a given package. Adding an ignored dependency to a package also makes it
// ignored on a subpackage.
func (c *Config) AddIgnoreDependency(dep string) {
c.ignoreDependencies[strings.TrimSpace(dep)] = struct{}{}
}
// IgnoresDependency checks if a dependency is ignored in the given package or
// in one of the parent packages up to the workspace root.
func (c *Config) IgnoresDependency(dep string) bool {
trimmedDep := strings.TrimSpace(dep)
if _, ignores := c.ignoreDependencies[trimmedDep]; ignores {
return true
}
parent := c.parent
for parent != nil {
if _, ignores := parent.ignoreDependencies[trimmedDep]; ignores {
return true
}
parent = parent.parent
}
return false
}
// SetValidateImportStatements sets whether Python import statements should be
// validated or not. It throws an error if this is set multiple times, i.e. if
// the directive is specified multiple times in the Bazel workspace.
func (c *Config) SetValidateImportStatements(validate bool) {
c.validateImportStatements = validate
}
// ValidateImportStatements returns whether the Python import statements should
// be validated or not. If this option was not explicitly specified by the user,
// it defaults to true.
func (c *Config) ValidateImportStatements() bool {
return c.validateImportStatements
}
// SetCoarseGrainedGeneration sets whether coarse-grained targets should be
// generated or not.
func (c *Config) SetCoarseGrainedGeneration(coarseGrained bool) {
c.coarseGrainedGeneration = coarseGrained
}
// CoarseGrainedGeneration returns whether coarse-grained targets should be
// generated or not.
func (c *Config) CoarseGrainedGeneration() bool {
return c.coarseGrainedGeneration
}
// SetLibraryNamingConvention sets the py_library target naming convention.
func (c *Config) SetLibraryNamingConvention(libraryNamingConvention string) {
c.libraryNamingConvention = libraryNamingConvention
}
// RenderLibraryName returns the py_library target name by performing all
// substitutions.
func (c *Config) RenderLibraryName(packageName string) string {
return strings.ReplaceAll(c.libraryNamingConvention, packageNameNamingConventionSubstitution, packageName)
}
// SetBinaryNamingConvention sets the py_binary target naming convention.
func (c *Config) SetBinaryNamingConvention(binaryNamingConvention string) {
c.binaryNamingConvention = binaryNamingConvention
}
// RenderBinaryName returns the py_binary target name by performing all
// substitutions.
func (c *Config) RenderBinaryName(packageName string) string {
return strings.ReplaceAll(c.binaryNamingConvention, packageNameNamingConventionSubstitution, packageName)
}
// SetTestNamingConvention sets the py_test target naming convention.
func (c *Config) SetTestNamingConvention(testNamingConvention string) {
c.testNamingConvention = testNamingConvention
}
// RenderTestName returns the py_test target name by performing all
// substitutions.
func (c *Config) RenderTestName(packageName string) string {
return strings.ReplaceAll(c.testNamingConvention, packageNameNamingConventionSubstitution, packageName)
}
rules_python-0.22.1/gazelle/pythonconfig/pythonconfig_test.go 0000664 0000000 0000000 00000001305 14540404546 0024563 0 ustar 00root root 0000000 0000000 package pythonconfig
import (
"testing"
"github.com/bazelbuild/rules_python/gazelle/pythonconfig"
)
func TestDistributionSanitizing(t *testing.T) {
tests := map[string]struct {
input string
want string
}{
"upper case": {input: "DistWithUpperCase", want: "distwithuppercase"},
"dashes": {input: "dist-with-dashes", want: "dist_with_dashes"},
"dots": {input: "dist.with.dots", want: "dist_with_dots"},
"mixed": {input: "To-be.sanitized", want: "to_be_sanitized"},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
got := pythonconfig.SanitizeDistribution(tc.input)
if tc.want != got {
t.Fatalf("expected %q, got %q", tc.want, got)
}
})
}
}
rules_python-0.22.1/gazelle/pythonconfig/types.go 0000664 0000000 0000000 00000006221 14540404546 0022163 0 ustar 00root root 0000000 0000000 // Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package pythonconfig
import (
"fmt"
"sort"
"strings"
)
// StringSet satisfies the flag.Value interface. It constructs a set backed by
// a hashmap by parsing the flag string value using the provided separator.
type StringSet struct {
set map[string]struct{}
separator string
}
// NewStringSet constructs a new StringSet with the given separator.
func NewStringSet(separator string) *StringSet {
return &StringSet{
set: make(map[string]struct{}),
separator: separator,
}
}
// String satisfies flag.Value.String.
func (ss *StringSet) String() string {
keys := make([]string, 0, len(ss.set))
for key := range ss.set {
keys = append(keys, key)
}
return fmt.Sprintf("%v", sort.StringSlice(keys))
}
// Set satisfies flag.Value.Set.
func (ss *StringSet) Set(s string) error {
list := strings.Split(s, ss.separator)
for _, v := range list {
trimmed := strings.TrimSpace(v)
if trimmed == "" {
continue
}
ss.set[trimmed] = struct{}{}
}
return nil
}
// Contains returns whether the StringSet contains the provided element or not.
func (ss *StringSet) Contains(s string) bool {
_, contains := ss.set[s]
return contains
}
// StringMapList satisfies the flag.Value interface. It constructs a string map
// by parsing the flag string value using the provided list and map separators.
type StringMapList struct {
mapping map[string]string
listSeparator string
mapSeparator string
}
// NewStringMapList constructs a new StringMapList with the given separators.
func NewStringMapList(listSeparator, mapSeparator string) *StringMapList {
return &StringMapList{
mapping: make(map[string]string),
listSeparator: listSeparator,
mapSeparator: mapSeparator,
}
}
// String satisfies flag.Value.String.
func (sml *StringMapList) String() string {
return fmt.Sprintf("%v", sml.mapping)
}
// Set satisfies flag.Value.Set.
func (sml *StringMapList) Set(s string) error {
list := strings.Split(s, sml.listSeparator)
for _, v := range list {
trimmed := strings.TrimSpace(v)
if trimmed == "" {
continue
}
mapList := strings.SplitN(trimmed, sml.mapSeparator, 2)
if len(mapList) < 2 {
return fmt.Errorf(
"%q is not a valid map using %q as a separator",
trimmed, sml.mapSeparator,
)
}
key := mapList[0]
if _, exists := sml.mapping[key]; exists {
return fmt.Errorf("key %q already set", key)
}
val := mapList[1]
sml.mapping[key] = val
}
return nil
}
// Get returns the value for the given key.
func (sml *StringMapList) Get(key string) (string, bool) {
val, exists := sml.mapping[key]
return val, exists
} rules_python-0.22.1/internal_deps.bzl 0000664 0000000 0000000 00000017506 14540404546 0017706 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Dependencies that are needed for rules_python tests and tools."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def rules_python_internal_deps():
"""Fetches all required dependencies for rules_python tests and tools."""
# This version is also used in python/tests/toolchains/workspace_template/WORKSPACE.tmpl
# and tests/ignore_root_user_error/WORKSPACE.
# If you update this dependency, please update the tests as well.
maybe(
http_archive,
name = "bazel_skylib",
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
],
)
maybe(
http_archive,
name = "rules_pkg",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
],
sha256 = "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2",
)
maybe(
http_archive,
name = "rules_testing",
sha256 = "0c2abee201f566a088c720e12bc1d968bc56e6a51b692d9c81b1fe861bdf2be2",
strip_prefix = "rules_testing-0.0.5",
url = "https://github.com/bazelbuild/rules_testing/releases/download/v0.0.5/rules_testing-v0.0.5.tar.gz",
)
maybe(
http_archive,
name = "io_bazel_stardoc",
url = "https://github.com/bazelbuild/stardoc/archive/6f274e903009158504a9d9130d7f7d5f3e9421ed.tar.gz",
sha256 = "b5d6891f869d5b5a224316ec4dd9e9d481885a9b1a1c81eb846e20180156f2fa",
strip_prefix = "stardoc-6f274e903009158504a9d9130d7f7d5f3e9421ed",
)
# The below two deps are required for the integration test with bazel
# gazelle. Maybe the test should be moved to the `gazelle` workspace?
maybe(
http_archive,
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
],
)
maybe(
http_archive,
name = "bazel_gazelle",
sha256 = "efbbba6ac1a4fd342d5122cbdfdb82aeb2cf2862e35022c752eaddffada7c3f3",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.27.0/bazel-gazelle-v0.27.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.27.0/bazel-gazelle-v0.27.0.tar.gz",
],
)
# Test data for WHL tool testing.
maybe(
http_file,
name = "futures_2_2_0_whl",
downloaded_file_path = "futures-2.2.0-py2.py3-none-any.whl",
sha256 = "9fd22b354a4c4755ad8c7d161d93f5026aca4cfe999bd2e53168f14765c02cd6",
# From https://pypi.python.org/pypi/futures/2.2.0
urls = [
"https://mirror.bazel.build/pypi.python.org/packages/d7/1d/68874943aa37cf1c483fc61def813188473596043158faa6511c04a038b4/futures-2.2.0-py2.py3-none-any.whl",
"https://pypi.python.org/packages/d7/1d/68874943aa37cf1c483fc61def813188473596043158faa6511c04a038b4/futures-2.2.0-py2.py3-none-any.whl",
],
)
maybe(
http_file,
name = "futures_3_1_1_whl",
downloaded_file_path = "futures-3.1.1-py2-none-any.whl",
sha256 = "c4884a65654a7c45435063e14ae85280eb1f111d94e542396717ba9828c4337f",
# From https://pypi.python.org/pypi/futures
urls = [
"https://mirror.bazel.build/pypi.python.org/packages/a6/1c/72a18c8c7502ee1b38a604a5c5243aa8c2a64f4bba4e6631b1b8972235dd/futures-3.1.1-py2-none-any.whl",
"https://pypi.python.org/packages/a6/1c/72a18c8c7502ee1b38a604a5c5243aa8c2a64f4bba4e6631b1b8972235dd/futures-3.1.1-py2-none-any.whl",
],
)
maybe(
http_file,
name = "google_cloud_language_whl",
downloaded_file_path = "google_cloud_language-0.29.0-py2.py3-none-any.whl",
sha256 = "a2dd34f0a0ebf5705dcbe34bd41199b1d0a55c4597d38ed045bd183361a561e9",
# From https://pypi.python.org/pypi/google-cloud-language
urls = [
"https://mirror.bazel.build/pypi.python.org/packages/6e/86/cae57e4802e72d9e626ee5828ed5a646cf4016b473a4a022f1038dba3460/google_cloud_language-0.29.0-py2.py3-none-any.whl",
"https://pypi.python.org/packages/6e/86/cae57e4802e72d9e626ee5828ed5a646cf4016b473a4a022f1038dba3460/google_cloud_language-0.29.0-py2.py3-none-any.whl",
],
)
maybe(
http_file,
name = "grpc_whl",
downloaded_file_path = "grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl",
sha256 = "c232d6d168cb582e5eba8e1c0da8d64b54b041dd5ea194895a2fe76050916561",
# From https://pypi.python.org/pypi/grpcio/1.6.0
urls = [
"https://mirror.bazel.build/pypi.python.org/packages/c6/28/67651b4eabe616b27472c5518f9b2aa3f63beab8f62100b26f05ac428639/grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl",
"https://pypi.python.org/packages/c6/28/67651b4eabe616b27472c5518f9b2aa3f63beab8f62100b26f05ac428639/grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl",
],
)
maybe(
http_file,
name = "mock_whl",
downloaded_file_path = "mock-2.0.0-py2.py3-none-any.whl",
sha256 = "5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1",
# From https://pypi.python.org/pypi/mock
urls = [
"https://mirror.bazel.build/pypi.python.org/packages/e6/35/f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/mock-2.0.0-py2.py3-none-any.whl",
"https://pypi.python.org/packages/e6/35/f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/mock-2.0.0-py2.py3-none-any.whl",
],
)
maybe(
http_archive,
name = "build_bazel_integration_testing",
urls = [
"https://github.com/bazelbuild/bazel-integration-testing/archive/165440b2dbda885f8d1ccb8d0f417e6cf8c54f17.zip",
],
strip_prefix = "bazel-integration-testing-165440b2dbda885f8d1ccb8d0f417e6cf8c54f17",
sha256 = "2401b1369ef44cc42f91dc94443ef491208dbd06da1e1e10b702d8c189f098e3",
)
maybe(
http_archive,
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)
maybe(
http_archive,
name = "com_google_protobuf",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
urls = [
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
],
)
rules_python-0.22.1/internal_setup.bzl 0000664 0000000 0000000 00000002772 14540404546 0020112 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Setup for rules_python tests and tools."""
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@build_bazel_integration_testing//tools:repositories.bzl", "bazel_binaries")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
def rules_python_internal_setup():
"""Setup for rules_python tests and tools."""
# Because we don't use the pip_install rule, we have to call this to fetch its deps
pip_install_dependencies()
# Depend on the Bazel binaries for running bazel-in-bazel tests
bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS)
bazel_skylib_workspace()
rules_proto_dependencies()
rules_proto_toolchains()
protobuf_deps()
rules_python-0.22.1/proposals/ 0000775 0000000 0000000 00000000000 14540404546 0016357 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/proposals/2018-10-25-selecting-between-python-2-and-3.md 0000664 0000000 0000000 00000036463 14540404546 0025731 0 ustar 00root root 0000000 0000000 ---
title: Selecting Between Python 2 and 3
status: Accepted
created: 2018-10-25
updated: 2019-01-11
authors:
- [brandjon@](https://github.com/brandjon)
reviewers:
- [mrovner@](https://github.com/mrovner)
discussion thread: [bazel #6583](https://github.com/bazelbuild/bazel/issues/6583)
---
# Selecting Between Python 2 and 3
## Abstract
The "Python mode" configuration value controls whether Python 2 or Python 3 is used to run Python targets built by Bazel. This design document reviews the existing mechanisms for setting the Python mode (the "tri-state model") and describes a simplified mechanism that should replace it (the "boolean model").
Links to Github issues are given where applicable. See also [bazel #6444](https://github.com/bazelbuild/bazel/issues/6444) for a tracking list of Python mode issues.
Throughout, when we say `py_binary`, we also mean to include `py_test`.
## Background
The Python mode controls whether a Python 2 or 3 interpreter is used to run a `py_binary` that is built by Bazel.
* When no `py_runtime` is supplied (via `--python_top`), the mode should control whether the command `python2` or `python3` is embedded into the generated wrapper script ([bazel #4815](https://github.com/bazelbuild/bazel/issues/4815)).
* In a future design for a "`py_toolchain`"-type rule, a pair of interpreter targets will be bundled together as a toolchain, and the mode will control which one gets their full path embedded into this script.
The Python mode is also used to help validate that Python source code annotated with `srcs_version` is used appropriately: If a Python target has the `srcs_version` attribute set to `PY2` or `PY3` rather than to `PY2AND3` (the default), it can only be depended on by targets built in Python 2 or Python 3 mode respectively.
Whenever the same Bazel target can be built in multiple configurations within a single build, it is necessary to write the output artifacts of different versions of the target to different paths. Otherwise the build fails with an "action conflict" error -- Bazel's way of avoiding a correctness bug. For Python targets, and more broadly for targets that may transitively depend on Python targets, this means that different output path roots must be used for different Python modes.
## Out-of-scope generalizations
It is possible to imagine extending the Python mode and `srcs_version` so that it can check for compatibility with minor releases (ex: "Python 3.7"), patch releases ("Python 3.7.1"), alternative interpreters ("CPython" or "PyPy"), and exclude known bad releases. We decline to do so because this treads into generalized constraint checking, which may be better handled in the future by the [platforms and toolchain framework](https://docs.bazel.build/versions/master/toolchains.html).
Compared to these other kinds of version checks, Python 2 vs. 3 is a more compelling use case to support with dedicated machinery. The incompatibilities between these versions are more severe. In many code bases there is an ongoing effort to migrate from 2 to 3, while in others there exists Python 2 code that will never be migrated and must be supported indefinitely.
## Tri-state model
Under the existing tri-state model, the Python mode can take on three values: `PY2`, `PY3`, and `null`. The first two modes can be triggered by the `--force_python` flag on the command line or by the `default_python_version` attribute on `py_binary` rules. The `null` mode is the default state when neither the flag nor `default_python_version` is specified. `select()` expressions can distinguish between these states by using `config_setting`s that test the value of `force_python` (where `null` is matched by `//conditions:default`).
The Python mode is "sticky"; once it is set to `PY2` or `PY3`, it stays that way for all subsequent targets. For a `py_binary` target, this means that all transitive dependencies of the target are built with the same mode as the target itself. For the `--force_python` flag, this means that if the flag is given, it applies universally to the entire build invocation, regardless of the `default_python_version` attributes of any Python targets (hence the "default" in the attribute's name).
### Data dependencies
In principle the Python mode needs to propagate to any `py_library` targets that are transitively in the `deps` attribute. Conceptually, this corresponds to enforcing that a Python binary cannot `import` a module written for a different version of Python than the currently running interpreter. But there is no need to propagate the mode across the `data` attribute, which often corresponds to one Python binary calling another as a separate process.
In order to facilitate `PY3` binaries that depend on `PY2` ones and vice versa, the tri-state model needs to be modified so that the mode is reset to `null` for `data` attributes ([bazel #6441](https://github.com/bazelbuild/bazel/issues/6441)). But it's not clear exactly which attributes should trigger a reset. For example, suppose a Python source file is generated by a `genrule`: Then the `genrule` shouldn't propagate any Python mode to any of its attributes, even though it appears in the transitive closure of a `py_binary`'s `deps`. One could imagine resetting the mode across every attribute except those in a small whitelist (`deps` of `py_binary`, `py_test`, and `py_library`), but this would require new functionality in Bazel and possibly interact poorly with Starlark-defined rules.
### Output roots
Since targets that are built for Python 3 produce different results than those built for Python 2, the outputs for these two configurations must be kept separate in order to avoid action conflicts. Therefore, targets built in `PY3` mode get placed under an output root that includes the string "`-py3`".
Currently, targets that are built in the `null` mode default to using Python 2. Counterintuitively, there is a subtle distinction between building a target in `null` mode and `PY2` mode: Even though the same interpreter is used for the top-level target, the target's transitive dependencies may behave differently, for instance if a `select()` on `force_python` is used. This means that using both `PY2` and `null` for the same target can result in action conflicts ([bazel #6501](https://github.com/bazelbuild/bazel/issues/6501)). However, due to a bug it is not yet possible to have both `PY2` and `null` modes within the same build invocation.
Under the tri-state model, the most straightforward solution for these action conflicts is to use a separate "`-py2`" root for `PY2` mode. This would mean that the same target could be built in not two but three different configurations, corresponding to the three different modes, even though there are only two distinct Python versions. A more complicated alternative would be to prohibit `select()` from being able to distinguish `null` from `PY2`, in order to help ensure that building an arbitrary target in both of these modes does not succeed with different results.
### Libraries at the top level
Currently the mode is only changed by `--force_python` and by `py_binary`. This means that when you build a `py_library` at the top level (that is, specifying it directly on the build command line) without a `--force_python` flag, the library gets the `null` mode, which means Python 2 by default. This causes an error if the library has `srcs_python` set to `PY3`. This in turn means you cannot run a flagless build command on a wildcard pattern, such as `bazel build :all` or `bazel build ...`, if any of the targets in the package(s) contains a Python 3-only library target. Worse, if there are both a Python 2-only library and a Python 3-only library, even specifying `--force_python` can't make the wildcard build work.
In the tri-state model, this can be addressed by allowing `py_library` to change the mode from `null` to either `PY2` or `PY3` based on whichever version is compatible with its `srcs_version` attribute. This was a proposed fix for [bazel #1446](https://github.com/bazelbuild/bazel/issues/1446).
## Boolean model
Under the boolean model, `null` is eliminated as a valid value for the Python mode. Instead, the mode will immediately default to either `PY2` or `PY3`. The mode is no longer sticky, but changes as needed whenever a new `py_binary` target is reached.
Since there is no longer a third value corresponding to "uncommitted", a target can no longer tell whether it was set to `PY2` mode explicitly (by a flag or a `py_binary`), or if it was set by default because no mode was specified. The current version will be inspectable using `config_setting` to read a setting whose value is always one of `"PY2"` or `"PY3"`.
### Data dependencies
Since `py_binary` will now change the mode as needed, there is no need to explicitly reset the mode to a particular value (`null`) when crossing `data` attributes. Python 3 targets can freely depend on Python 2 targets and vice versa, so long as the dependency is not via the `deps` attribute in a way that violates `srcs_version` validation (see below).
### Output roots
Since there are only two modes, there need only be two output roots. This avoids action conflicts without resorting to creating a redundant third output root, or trying to coerce two similar-but-distinct modes to map onto the same output root.
Since the mode is not being reset across data dependencies, it is possible that compared to the tri-state model, the boolean model causes some data dependencies to be built in two configurations instead of just one. This is considered to be an acceptable tradeoff of the boolean model. Note that there exist other cases where redundant rebuilding occurs regardless of which model we use.
### Libraries at the top level
We want to be able to build a `py_library` at the top level without having to specify the correct mode. At the same time, we still want `srcs_version` to validate that a `py_binary` only depends on `py_library`s that are compatible with its mode. The way to achieve this is to move validation from within the `py_library` rule up to the `py_binary` rule.
We add two new boolean fields to a provider returned by `py_library`. This bools correspond to whether or not there are any Python 2-only and Python 3-only sources (respectively) in the library's transitive closure. It is easy to compute these bits as boolean ORs as the providers are merged. `py_binary` simply checks these bits against its own Python mode.
It is important that when `py_binary` detects a version conflict, the user is given the label of one or more transitive dependencies that introduced the constraint. There are several ways to implement this, such as:
- additional provider fields to propagate context to the error message
- an aspect that traverses the dependencies of the `py_binary`
- emitting warning messages at conflicting `py_library` targets
The choice of which approach to use is outside the scope of this proposal.
It is possible that a library is only ever used by Python 3 binaries, but when the library is built as part of a `bazel build :all` command it gets the Python 2 mode by default. This happens even if the library is annotated with `srcs_version` set to `PY3`. Generally this should cause no harm aside from some repeated build work. In the future we can add the same version attribute that `py_binary` has to `py_library`, so the target definition can be made unambiguous.
Aside from failures due to validation, there is currently a bug whereby building a `PY2` library in `PY3` mode can invoke a stub wrapper that fails ([bazel #1393](https://github.com/bazelbuild/bazel/issues/1393)). We will remove the stub and the behavior that attempted to call it.
## API changes
The attribute `default_python_version` of `py_binary` is renamed to `python_version`. The flag `--force_python` is renamed to `--python_version`. (An alternative naming scheme would have been to use "python_major_version", but this is more verbose and inconsistent with `srcs_version`.)
The Python mode becomes "non-sticky" and `srcs_version` validation becomes less strict. Building a `py_library` target directly will not trigger validation. Building a `py_binary` that depends on a `py_library` having an incompatible version will only fail if the dependency occurs via transitive `deps`, and not when it occurs via other paths such as a `data` dep or a `genrule` that produces a source file.
The `"py"` provider of Python rules gains two new boolean fields, `has_py2_only_sources` and `has_py3_only_sources`. Existing Python rules are updated to set these fields. Dependencies of Python rules that do not have the `"py"` provider, or those fields on that provider, are treated as if the value of the fields is `False`.
A new `select()`-able target is created at `@bazel_tools//tools/python:python_version` to return the current Python mode. It can be used in the `flag_values` attribute of `config_setting` and always equals either `"PY2"` or `"PY3"`. (In the future this flag may be moved out of `@bazel_tools` and into `bazelbuild/rules_python`. It may also be made into a `build_setting` so that it can replace the native `--python_version` flag.) It is disallowed to use `"python_version"` in a `config_setting`.
The flag `--host_force_python` is unaffected by this doc, except that it becomes illegal to use it in a `config_setting`.
## Migration and compatibility
The rollout and migration of the new features are split into two groups, syntactic and semantic.
For syntax, the new `--python_version` flag and `python_version` attribute are available immediately, and behave exactly the same as the old flag and attribute. When both the new and old flags are present on the command line, or both the new and old attributes are present on the same target, the new one takes precedence and the old is ignored. The `@bazel_tools//tools/python:python_version` target is also available unconditionally.
A migration flag `--incompatible_remove_old_python_version_api` makes unavailable the `--force_python` flag and `default_python_version` attribute, and disallows `select()`-ing on `"force_python"` and `"host_force_python"`.
For semantics, a flag `--incompatible_allow_python_version_transitions` makes Bazel use the new non-sticky version transitions and the deferred `srcs_version` validation. This applies regardless of whether the new or old API is used to specify the Python version. The new `"py"` provider fields are created regardless of which flags are given.
Migrating for `--incompatible_remove_old_python_version_api` guarantees that the Python version only ever has two possible values. Migrating for `--incompatible_allow_python_version_transitions` enables data dependencies across different versions of Python. It is recommended to do the API migration first in order to avoid action conflicts.
Strictly speaking, Python 3 support is currently marked "experimental" in documentation, so in theory we may be able to make these changes without introducing new incompatible and experimental flags. However these changes will likely affect many users of the Python rules, so flags would be more user-friendly. Bazel is also transitioning to a policy wherein all experimental APIs must be flag-guarded, regardless of any disclaimers in their documentation.
## Changelog
Date | Change
------------ | ------
2018-10-25 | Initial version
2018-11-02 | Refine migration path
2018-12-17 | Refine plan for `select()`
2018-12-19 | Refine plan for `select()` again
2019-01-10 | Refine migration path
2019-01-11 | Formal approval and update provider fields
rules_python-0.22.1/proposals/2018-11-08-customizing-the-python-stub-template.md 0000664 0000000 0000000 00000010112 14540404546 0027164 0 ustar 00root root 0000000 0000000 ---
title: Customizing the Python Stub Template
status: Draft, not yet ready for review
created: 2018-11-08
updated: 2018-11-09
authors:
- [brandjon@](https://github.com/brandjon)
reviewers:
- [gpshead@](https://github.com/gpshead)
discussion thread: [bazel #137](https://github.com/bazelbuild/bazel/issues/137)
---
# Customizing the Python Stub Template
## Abstract
This design document proposes a way to use a different Python stub template, so that users can control how the Python interpreter gets invoked to run their targets.
**Open questions:** It is not currently clear whether the use cases warrant this kind of expressivity, or whether users can get by with smaller, more narrowly focused ways of parameterizing the existing stub template. The exact stub API is also to be determined.
## Background
The usual executable artifact of a `py_binary` rule is a Python stub script. This script manipulates the Python environment to set up the module import path and make the runfiles available, before passing control to the underlying user Python program. The stub script is generated from a [stub template](https://github.com/bazelbuild/bazel/blob/ef0024b831a71521390dcb837b24b86485e5998d/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt) by [instantiating some placeholders](https://github.com/bazelbuild/bazel/blob/ef0024b831a71521390dcb837b24b86485e5998d/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java#L152-L159).
Generally the Python stub and user program is executed using the system Python interpreter of the target platform. Although this is non-hermetic, the details of the interpreter can be reified by a [`py_runtime`](https://docs.bazel.build/versions/master/be/python.html#py_runtime) target. In the future this will allow for platform-aware selection of an appropriate Python interpreter using the [toolchain](https://docs.bazel.build/versions/master/toolchains.html) framework.
## Proposal
A new `Label`-valued attribute, `stub_template`, is added to `py_runtime`. This label points to a file; by default it is `//tools/python:python_stub_template.txt`, which is the renamed location of the existing template. The `py_runtime` rule will resolve this label to an `Artifact` and propagate it in a new field of [`BazelPyRuntimeProvider`](https://github.com/bazelbuild/bazel/blob/1f684e1b87cd8881a0a4b33e86ba66743e32d674/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyRuntimeProvider.java). [`BazelPythonSemantics#createExecutable`](https://github.com/bazelbuild/bazel/blob/ef0024b831a71521390dcb837b24b86485e5998d/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java#L130) will refer to this `Artifact` instead of retrieving the template as a Java resource file.
It is not yet decided which template placeholders are specified, or whether the placeholders will remain an experimental API for the moment.
## Original approach
An earlier proposed approach (suggested on the discussion thread, and implemented by [fahhem@](https://github.com/fahhem)) was to add the `stub_template` attribute to `py_binary` rather than to `py_runtime`.
This would make it trivial to customize the stub for an individual Python target without affecting the other targets in the build. This could be useful if there were a one-off target that had special requirements.
However, the author believes that the stub is more naturally tied to the Python interpreter than to an individual target. Putting the attribute on `py_runtime` makes it easy to affect all Python targets that use the same interpreter. It also allows the same Python target to use different stubs depending on which interpreter it is built for -- for instance, the same target can have different stubs on different platforms.
If it is necessary to use a custom stub for a particular target, that could still be achieved by making that one target use a different `py_runtime`. This isn't possible at the moment but will be when a `py_toolchain` rule is added.
## Changelog
Date | Change
------------ | ------
2018-11-08 | Initial version
rules_python-0.22.1/proposals/2019-02-12-design-for-a-python-toolchain.md 0000664 0000000 0000000 00000043776 14540404546 0025522 0 ustar 00root root 0000000 0000000 ---
title: Design for a Python Toolchain
status: Accepted
created: 2019-02-12
updated: 2019-02-21
authors:
- [brandjon@](https://github.com/brandjon)
reviewers:
- [katre@](https://github.com/katre), [mrovner@](https://github.com/mrovner), [nlopezgi@](https://github.com/nlopezgi)
discussion thread: [bazel #7375](https://github.com/bazelbuild/bazel/issues/7375)
---
# Design for a Python Toolchain
## Abstract
This doc outlines the design of a Python toolchain rule and its associated machinery. Essentially a new `py_runtime_pair` toolchain rule is created to wrap two `py_runtime` targets (one for Python 2 and one for Python 3), thereby making runtimes discoverable via [toolchain resolution](https://docs.bazel.build/versions/master/toolchains.html). This replaces the previous mechanism of explicitly specifying a global runtime via `--python_top` or `--python_path`; those flags are now deprecated.
The new toolchain-related definitions are implemented in Starlark. A byproduct of this is that the provider type for `py_runtime` is exposed to Starlark. We also add to `py_runtime` an attribute for declaring whether it represents a Python 2 or Python 3 runtime.
## Motivation
The goal is to make the native Python rules use the toolchain framework to resolve the Python runtime. Advantages include:
* allowing each `py_binary` to use a runtime suitable for its target platform
* allowing Python 2 and Python 3 targets to run in the same build without [hacks](https://github.com/bazelbuild/bazel/issues/4815#issuecomment-460777113)
* making it easier to run Python-related builds under remote execution
* adding support for autodetection of available system Python runtimes, without requiring ad hoc rule logic
* removing `--python_top` and `--python_path`
* bringing Python in line with other rule sets and Bazel's best practices
**Non-goal:** This work does not allow individual `py_binary`s to directly name a Python runtime to use. Instead, this information should be worked into either the configuration or a future toolchain constraint system. See the FAQ, below.
## Design
### New definitions
A new [toolchain type](https://docs.bazel.build/versions/master/toolchains.html#writing-rules-that-use-toolchains) is created at `@bazel_tools//tools/python:toolchain_type`. This is the type for toolchains that provide a way to run Python code.
Toolchain rules of this type are expected to return a [`ToolchainInfo`](https://docs.bazel.build/versions/master/skylark/lib/ToolchainInfo.html) with two fields, `py2_runtime` and `py3_runtime`, each of type `PyRuntimeInfo`. They are used for `PY2` and `PY3` binaries respectively.
```python
def _some_python_toolchain_impl(ctx):
...
return [platform_common.ToolchainInfo(
py2_runtime = PyRuntimeInfo(...),
py3_runtime = PyRuntimeInfo(...))]
```
If either Python 2 or Python 3 is not provided by the toolchain, the corresponding field may be set to `None`. This is strongly discouraged, as it will prevent any target relying on that toolchain from using that version of Python. Toolchains that do use `None` here should be registered with lower priority than other toolchains, so that they are chosen only as a fallback.
`PyRuntimeInfo` is the newly-exposed Starlark name of the native provider returned by the [`py_runtime`](https://docs.bazel.build/versions/master/be/python.html#py_runtime) rule. Like `PyInfo`, it is a top-level built-in name. Also like `PyInfo` and the native Python rules, it will eventually be migrated to Starlark and moved out of the Bazel repository.
A `PyRuntimeInfo` describes either a *platform runtime* or an *in-build runtime*. A platform runtime accesses a system-installed interpreter at a known path, whereas an in-build runtime points to a build target that acts as the interpreter. In both cases, an "interpreter" is really any executable binary or wrapper script that is capable of running a Python script passed on the command line, following the same conventions as the standard CPython interpreter. Note that any platform runtime imposes a requirement on the target platform. Therefore, any toolchain returning such a `PyRuntimeInfo` should include a corresponding target platform constraint, to ensure it cannot be selected for a platform that does not have the interpreter at that path. Even an in-build runtime can require platform constraints, for instance in the case of a wrapper script that invokes the system interpreter.
We provide two [`constraint_setting`](https://docs.bazel.build/versions/master/be/platform.html#constraint_setting)s to act as a standardized namespace for this kind of platform constraint: `@bazel_tools//tools/python:py2_interpreter_path` and `@bazel_tools//tools/python:py3_interpreter_path`. This doc does not mandate any particular structure for the names of [`constraint_value`](https://docs.bazel.build/versions/master/be/platform.html#constraint_value)s associated with these settings. If a platform does not provide a Python 2 runtime, it should have no constraint value associated with `py2_interpreter_path`, and similarly for Python 3.
`PyRuntimeInfo` has the following fields, each of which corresponds to an attribute on `py_runtime`. (The last one, `python_version`, is newly added in this doc.)
* `interpreter_path`: If this is a platform runtime, this field is the absolute filesystem path to the interpreter on the target platform. Otherwise, this is `None`.
* `interpreter`: If this is an in-build runtime, this field is a `File` representing the interpreter. Otherwise, this is `None`.
* `files`: If this is an in-build runtime, this field is a depset of `File`s that need to be added to the runfiles of an executable target that uses this toolchain. The value of `interpreter` need not be included in this field. If this is a platform runtime then this field is `None`.
* `python_version`: Either the string `"PY2"` or `"PY3"`, indicating which version of Python the interpreter referenced by `interpreter_path` or `interpreter` is.
The constructor of `PyRuntimeInfo` takes each of these fields as keyword arguments. The constructor enforces the invariants about which combinations of fields may be `None`. Fields that are not meaningful may be omitted; e.g. when `interpreter_path` is given, `interpreter` and `files` may be omitted instead of passing `None`.
It is not possible to directly specify a system command (e.g. `"python"`) in `interpreter_path`. However, this can be done indirectly by creating a wrapper script that invokes the system command, and referencing that script from the `interpreter` field.
Finally, we define a standard Python toolchain rule implementing the new toolchain type. The rule's name is `py_runtime_pair` and it can be loaded from `@bazel_tools//tools/python:toolchain.bzl`. It has two label-valued attributes, `py2_runtime` and `py3_runtime`, that refer to `py_runtime` targets.
### Changes to the native Python rules
The executable Python rules [`py_binary`](https://docs.bazel.build/versions/master/be/python.html#py_binary) and [`py_test`](https://docs.bazel.build/versions/master/be/python.html#py_test) are modified to require the new toolchain type. The Python runtime information is obtained by retrieving a `PyRuntimeInfo` from either the `py2_runtime` or `py3_runtime` field of the toolchain, rather than from `--python_top`. The `python_version` field of the `PyRuntimeInfo` is also checked to ensure that a `py_runtime` didn't accidentally end up in the wrong place.
Since `--python_top` is no longer read, it is deprecated. Since `--python_path` was only read when no runtime information is available, but the toolchain must always be present, it too is deprecated.
Implementation wise, the native `PyRuntimeProvider` is turned into the user-visible `PyRuntimeInfo` by adding Starlark API annotations in the usual way (`@SkylarkCallable`, etc.). A previous version of this proposal suggested defining `PyRuntimeInfo` in Starlark underneath `@bazel_tools` and accessing it from the native rules, but this is technically difficult to implement.
A `python_version` attribute is added to `py_runtime`. It is mandatory and accepts values `"PY2"` and `"PY3"` only.
As a drive-by cleanup (and non-breaking change), the `files` attribute of `py_runtime` is made optional. For the non-hermetic case, specifying `files` is nonsensical and it is even an error to give it a non-empty value. For the hermetic case, `files` can be useful but is by no means necessary if the interpreter requires no additional in-repo inputs (such as when the "interpreter" is just a wrapper script that dispatches to the platform's system interpreter).
### Default toolchain
For convenience, we supply a predefined [toolchain](https://docs.bazel.build/versions/master/be/platform.html#toolchain) of last resort, `@bazel_tools//tools/python:autodetecting_python_toolchain`. This toolchain is registered with lower priority than any user-registered Python toolchain. It simply dispatches to a wrapper script that tries to locate a suitable interpreter from `PATH` at runtime, on a best-effort basis. It has no platform constraints.
## Example
Here is a minimal example that defines a platform whose Python interpreters are located under a non-standard path. The example also defines a Python toolchain to accompany this platform.
```python
# //platform_defs:BUILD
load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")
# Constraint values that represent that the system's "python2" and "python3"
# executables are located under /usr/weirdpath.
constraint_value(
name = "usr_weirdpath_python2",
constraint_setting = "@bazel_tools//tools/python:py2_interpreter_path",
)
constraint_value(
name = "usr_weirdpath_python3",
constraint_setting = "@bazel_tools//tools/python:py3_interpreter_path",
)
# A definition of a platform whose Python interpreters are under these paths.
platform(
name = "my_platform",
constraint_values = [
":usr_weirdpath_python2",
":usr_weirdpath_python3",
],
)
# Python runtime definitions that reify these system paths as BUILD targets.
py_runtime(
name = "my_platform_py2_runtime",
interpreter_path = "/usr/weirdpath/python2",
)
py_runtime(
name = "my_platform_py3_runtime",
interpreter_path = "/usr/weirdpath/python3",
)
py_runtime_pair(
name = "my_platform_runtimes",
py2_runtime = ":my_platform_py2_runtime",
py3_runtime = ":my_platform_py3_runtime",
)
# A toolchain definition to expose these runtimes to toolchain resolution.
toolchain(
name = "my_platform_python_toolchain",
# Since the Python interpreter is invoked at runtime on the target
# platform, there's no need to specify execution platform constraints here.
target_compatible_with = [
# Make sure this toolchain is only selected for a target platform that
# advertises that it has interpreters available under /usr/weirdpath.
":usr_weirdpath_python2",
":usr_weirdpath_python3",
],
toolchain = ":my_platform_runtimes",
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
)
```
```python
# //pkg:BUILD
# An ordinary Python target to build.
py_binary(
name = "my_pybin",
srcs = ["my_pybin.py"],
python_version = "PY3",
)
```
```python
# WORKSPACE
# Register the custom Python toolchain so it can be chosen for my_platform.
register_toolchains(
"//platform_defs:my_platform_python_toolchain",
)
```
We can then build with
```
bazel build //pkg:my_pybin --platforms=//platform_defs:my_platform
```
and thanks to toolchain resolution, the resulting executable will automatically know to use the interpreter located at `/usr/weirdpath/python3`.
If we had not defined a custom toolchain, then we'd be stuck with `autodetecting_python_toolchain`, which would fail at execution time if `/usr/weirdpath` were not on `PATH`. (It would also be slightly slower since it requires an extra invocation of the interpreter at execution time to confirm its version.)
## Backward compatibility
The new `@bazel_tools` definitions and the `PyRuntimeInfo` provider are made available immediately. A new flag, `--incompatible_use_python_toolchains`, is created to assist migration. When the flag is enabled, `py_binary` and `py_test` will use the `PyRuntimeInfo` obtained from the toolchain, instead of the one obtained from `--python_top` or the default information in `--python_path`. In addition, when `--incompatible_use_python_toolchains` is enabled it is an error to set the following flags: `--python_top`, `--python_path`, `--python2_path`, `--python3_path`. (The latter two were already deprecated.) These flags will be deleted when the incompatible flag is removed.
Because of how the toolchain framework is implemented, it is not possible to gate whether a rule requires a toolchain type based on a flag. Therefore `py_binary` and `py_test` are made to require `@bazel_tools//tools/python:toolchain_type` immediately and unconditionally. This may impact how toolchain resolution determines the toolchains and execution platforms for a given build, but should not otherwise cause problems so long as the build uses constraints correctly.
The new `python_version` attribute is added to `py_runtime` immediately. Its default value is the same as the `python_version` attribute for `py_binary`, i.e. `PY3` if `--incompatible_py3_is_default` is true and `PY2` otherwise. When `--incompatible_use_python_toolchains` is enabled this attribute becomes mandatory.
## FAQ
#### How can I force a `py_binary` to use a given runtime, say for a particular minor version of Python?
This is not directly addressed by this doc. Note that such a system could be used not just for controlling the minor version of the interpreter, but also to choose between different Python implementations (CPython vs PyPy), compilation modes (optimized, debug), an interpreter linked with a pre-selected set of extensions, etc.
There are two possible designs.
The first design is to put this information in the configuration, and have the toolchain read the configuration to decide which `PyRuntimeInfo` to return. We'd use Starlark Build Configurations to define a flag to represent the Python minor version, and transition the `py_binary` target's configuration to use this version. This configuration would be inherited by the resolved toolchain just like any other dependency inherits its parents configuration. The toolchain could then use a `select()` on the minor version flag to choose which `py_runtime` to depend on.
There's one problem: Currently all toolchains are analyzed in the host configuration. It is expected that this will be addressed soon.
We could even migrate the Python major version to use this approach. Instead of having two different `ToolchainInfo` fields, `py2_runtime` and `py3_runtime`, we'd have a single `py_runtime` field that would be populated with one or the other based on the configuration. (It's still a good idea to keep them as separate attributes in the user-facing toolchain rule, i.e. `py_runtime_pair`, because it's a very common use case to require both major versions of Python in a build. But note that this causes both runtimes to be analyzed as dependencies, even if the whole build uses only one or the other.)
The second design for controlling what runtime is chosen is to introduce additional constraints on the toolchain, and let toolchain resolution solve the problem. However, currently toolchains only support constraints on the target and execution platforms, and this is not a platform-related constraint. What would be needed is a per-target semantic-level constraint system.
The second approach has the advantage of allowing individual runtimes to be registered independently, without having to combine them into a massive `select()`. But the first approach is much more feasible to implement in the short-term.
#### Why `py_runtime_pair` as opposed to some other way of organizing multiple Python runtimes?
Alternatives might include a dictionary mapping from version identifiers to runtimes, or a list of runtimes paired with additional metadata.
The `PY2`/`PY3` dichotomy is already baked into the Python rule set and indeed the Python ecosystem at large. Keeping this concept in the toolchain rule serves to complement, rather than complicate, Bazel's existing Python support.
It will always be possible to add new toolchains, first by extending the schema of the `ToolchainInfo` accepted by the Python rules, and then by defining new user-facing toolchain rules that serve as front-ends for this provider.
#### Why not split Python 2 and Python 3 into two separate toolchain types?
The general pattern for rule sets seems to be to have a single toolchain type representing all of a language's concerns. Case in point: The naming convention for toolchain types is to literally name the target "toolchain_type", and let the package path distinguish its label.
If the way of categorizing Python runtimes changes in the future, it will probably be easier to migrate rules to use a new provider schema than to use a new set of toolchain types.
#### How does the introduction of new symbols to `@bazel_tools` affect the eventual plan to migrate the Python rules to `bazelbuild/rules_python`?
The new `PyRuntimeInfo` provider and `py_runtime_pair` rule would have forwarding aliases set up, so they could be accessed both from `@bazel_tools` and `rules_python` during a future migration window.
Forwarding aliases would also be defined for the toolchain type and the two `constraint_setting`s. Note that aliasing `toolchain_type`s is currently broken ([#7404](https://github.com/bazelbuild/bazel/issues/7404)).
In the initial implementation of this proposal, the predefined `autodetecting_python_toolchain` will be automatically registered in the user's workspace by Bazel. This follows precedent for other languages with built-in support in Bazel. Once the rules are migrated to `rules_python`, registration will not be automatic; the user will have to explicitly call a configuration helper defined in `rules_python` from their own `WORKSPACE` file.
## Changelog
Date | Change
------------ | ------
2019-02-12 | Initial version
2019-02-14 | Make `PyRuntimeInfo` natively defined
2019-02-15 | Clarify platform runtime vs in-build runtime
2019-02-21 | Formal approval
rules_python-0.22.1/proposals/README.md 0000664 0000000 0000000 00000002276 14540404546 0017645 0 ustar 00root root 0000000 0000000 # Python Rules Proposals
This is an index of all design documents and proposals for Python rules, both in native code (the Bazel binary) and in Starlark (the rules_python repository). Some of these proposals are also hosted in this directory.
Proposals that impact native code are also indexed by [bazelbuild/proposals](https://github.com/bazelbuild/proposals), and subject to the [Bazel design process](https://bazel.build/designs/index.html).
Last updated | Status | Title | Author(s)
------------ | ------------- | ------| ---------
2019-02-21 | Accepted | [Design for a Python Toolchain](https://github.com/bazelbuild/rules_python/blob/master/proposals/2019-02-12-design-for-a-python-toolchain.md) | [brandjon@](https://github.com/brandjon)
2018-11-09 | Draft | [Customizing the Python Stub Template](https://github.com/bazelbuild/rules_python/blob/master/proposals/2018-11-08-customizing-the-python-stub-template.md) | [brandjon@](https://github.com/brandjon)
2019-01-11 | Accepted | [Selecting Between Python 2 and 3](https://github.com/bazelbuild/rules_python/blob/master/proposals/2018-10-25-selecting-between-python-2-and-3.md) | [brandjon@](https://github.com/brandjon)
rules_python-0.22.1/python/ 0000775 0000000 0000000 00000000000 14540404546 0015656 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/BUILD.bazel 0000664 0000000 0000000 00000014421 14540404546 0017536 0 ustar 00root root 0000000 0000000 # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This package contains two sets of rules:
1) the "core" Python rules, which were historically bundled with Bazel and
are now either re-exported or copied into this repository; and
2) the packaging rules, which were historically simply known as
rules_python.
In an ideal renaming, we'd move the packaging rules to a different package so
that @rules_python//python is only concerned with the core rules.
"""
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":current_py_toolchain.bzl", "current_py_toolchain")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
filegroup(
name = "distribution",
srcs = glob(["**"]) + [
"//python/config_settings:distribution",
"//python/constraints:distribution",
"//python/private:distribution",
"//python/runfiles:distribution",
],
visibility = ["//:__pkg__"],
)
# ========= bzl_library targets end =========
bzl_library(
name = "current_py_toolchain_bzl",
srcs = ["current_py_toolchain.bzl"],
)
bzl_library(
name = "defs_bzl",
srcs = [
"defs.bzl",
],
visibility = ["//visibility:public"],
deps = [
":current_py_toolchain_bzl",
":py_binary_bzl",
":py_import_bzl",
":py_info_bzl",
":py_library_bzl",
":py_runtime_bzl",
":py_runtime_info_bzl",
":py_runtime_pair_bzl",
":py_test_bzl",
"//python/private:bazel_tools_bzl",
],
)
bzl_library(
name = "proto_bzl",
srcs = [
"proto.bzl",
],
visibility = ["//visibility:public"],
deps = [
"//python/private/proto:py_proto_library_bzl",
],
)
bzl_library(
name = "py_binary_bzl",
srcs = ["py_binary.bzl"],
deps = ["//python/private:util_bzl"],
)
bzl_library(
name = "py_cc_link_params_info_bzl",
srcs = ["py_cc_link_params_info.bzl"],
)
bzl_library(
name = "py_import_bzl",
srcs = ["py_import.bzl"],
deps = [":py_info_bzl"],
)
bzl_library(
name = "py_info_bzl",
srcs = ["py_info.bzl"],
deps = ["//python/private:reexports_bzl"],
)
bzl_library(
name = "py_library_bzl",
srcs = ["py_library.bzl"],
deps = ["//python/private:util_bzl"],
)
bzl_library(
name = "py_runtime_bzl",
srcs = ["py_runtime.bzl"],
deps = ["//python/private:util_bzl"],
)
bzl_library(
name = "py_runtime_pair_bzl",
srcs = ["py_runtime_pair.bzl"],
deps = ["//python/private:bazel_tools_bzl"],
)
bzl_library(
name = "py_runtime_info_bzl",
srcs = ["py_runtime_info.bzl"],
deps = ["//python/private:reexports_bzl"],
)
bzl_library(
name = "py_test_bzl",
srcs = ["py_test.bzl"],
deps = ["//python/private:util_bzl"],
)
# NOTE: Remember to add bzl_library targets to //tests:bzl_libraries
# ========= bzl_library targets end =========
# Filegroup of bzl files that can be used by downstream rules for documentation generation
filegroup(
name = "bzl",
srcs = [
"defs.bzl",
"packaging.bzl",
"pip.bzl",
"repositories.bzl",
"versions.bzl",
"//python/pip_install:bzl",
"//python/private:bzl",
],
visibility = ["//visibility:public"],
)
# ========= Core rules =========
exports_files([
"defs.bzl",
"python.bzl", # Deprecated, please use defs.bzl
])
# This target can be used to inspect the current Python major version. To use,
# put it in the `flag_values` attribute of a `config_setting` and test it
# against the values "PY2" or "PY3". It will always match one or the other.
#
# If you do not need to test any other flags in combination with the Python
# version, then as a convenience you may use the predefined `config_setting`s
# `@rules_python//python:PY2` and `@rules_python//python:PY3`.
#
# Example usage:
#
# config_setting(
# name = "py3_on_arm",
# values = {"cpu": "arm"},
# flag_values = {"@rules_python//python:python_version": "PY3"},
# )
#
# my_target(
# ...
# some_attr = select({
# ":py3_on_arm": ...,
# ...
# }),
# ...
# )
#
# Caution: Do not `select()` on the built-in command-line flags `--force_python`
# or `--python_version`, as they do not always reflect the true Python version
# of the current target. `select()`-ing on them can lead to action conflicts and
# will be disallowed.
alias(
name = "python_version",
actual = "@bazel_tools//tools/python:python_version",
)
alias(
name = "PY2",
actual = "@bazel_tools//tools/python:PY2",
)
alias(
name = "PY3",
actual = "@bazel_tools//tools/python:PY3",
)
# The toolchain type for Python rules. Provides a Python 2 and/or Python 3
# runtime.
alias(
name = "toolchain_type",
actual = "@bazel_tools//tools/python:toolchain_type",
)
# Definitions for a Python toolchain that, at execution time, attempts to detect
# a platform runtime having the appropriate major Python version. Consider this
# a toolchain of last resort.
#
# The non-strict version allows using a Python 2 interpreter for PY3 targets,
# and vice versa. The only reason to use this is if you're working around
# spurious failures due to PY2 vs PY3 validation. Even then, using this is only
# safe if you know for a fact that your build is completely compatible with the
# version of the `python` command installed on the target platform.
alias(
name = "autodetecting_toolchain",
actual = "@bazel_tools//tools/python:autodetecting_toolchain",
)
alias(
name = "autodetecting_toolchain_nonstrict",
actual = "@bazel_tools//tools/python:autodetecting_toolchain_nonstrict",
)
# ========= Packaging rules =========
exports_files([
"packaging.bzl",
"pip.bzl",
])
current_py_toolchain(
name = "current_py_toolchain",
)
rules_python-0.22.1/python/config_settings/ 0000775 0000000 0000000 00000000000 14540404546 0021043 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/config_settings/BUILD.bazel 0000664 0000000 0000000 00000000471 14540404546 0022723 0 ustar 00root root 0000000 0000000 load("//python:versions.bzl", "TOOL_VERSIONS")
load(":config_settings.bzl", "construct_config_settings")
filegroup(
name = "distribution",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
],
visibility = ["//python:__pkg__"],
)
construct_config_settings(python_versions = TOOL_VERSIONS.keys())
rules_python-0.22.1/python/config_settings/config_settings.bzl 0000664 0000000 0000000 00000002757 14540404546 0024754 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module is used to construct the config settings in the BUILD file in this same package.
"""
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
# buildifier: disable=unnamed-macro
def construct_config_settings(python_versions):
"""Constructs a set of configs for all Python versions.
Args:
python_versions: The Python versions supported by rules_python.
"""
string_flag(
name = "python_version",
build_setting_default = python_versions[0],
values = python_versions,
visibility = ["//visibility:public"],
)
for python_version in python_versions:
python_version_constraint_setting = "is_python_" + python_version
native.config_setting(
name = python_version_constraint_setting,
flag_values = {":python_version": python_version},
visibility = ["//visibility:public"],
)
rules_python-0.22.1/python/config_settings/transition.bzl 0000664 0000000 0000000 00000020214 14540404546 0023745 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The transition module contains the rule definitions to wrap py_binary and py_test and transition
them to the desired target platform.
"""
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("//python:defs.bzl", _py_binary = "py_binary", _py_test = "py_test")
def _transition_python_version_impl(_, attr):
return {"//python/config_settings:python_version": str(attr.python_version)}
_transition_python_version = transition(
implementation = _transition_python_version_impl,
inputs = [],
outputs = ["//python/config_settings:python_version"],
)
def _transition_py_impl(ctx):
target = ctx.attr.target
windows_constraint = ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]
target_is_windows = ctx.target_platform_has_constraint(windows_constraint)
executable = ctx.actions.declare_file(ctx.attr.name + (".exe" if target_is_windows else ""))
ctx.actions.symlink(
is_executable = True,
output = executable,
target_file = target[DefaultInfo].files_to_run.executable,
)
zipfile_symlink = None
if target_is_windows:
# Under Windows, the expected ".zip" does not exist, so we have to
# create the symlink ourselves to achieve the same behaviour as in macOS
# and Linux.
zipfile = None
expected_target_path = target[DefaultInfo].files_to_run.executable.short_path[:-4] + ".zip"
for file in target[DefaultInfo].default_runfiles.files.to_list():
if file.short_path == expected_target_path:
zipfile = file
zipfile_symlink = ctx.actions.declare_file(ctx.attr.name + ".zip")
ctx.actions.symlink(
is_executable = True,
output = zipfile_symlink,
target_file = zipfile,
)
env = {}
for k, v in ctx.attr.env.items():
env[k] = ctx.expand_location(v)
providers = [
DefaultInfo(
executable = executable,
files = depset([zipfile_symlink] if zipfile_symlink else [], transitive = [target[DefaultInfo].files]),
runfiles = ctx.runfiles([zipfile_symlink] if zipfile_symlink else []).merge(target[DefaultInfo].default_runfiles),
),
target[PyInfo],
target[PyRuntimeInfo],
# Ensure that the binary we're wrapping is included in code coverage.
coverage_common.instrumented_files_info(
ctx,
dependency_attributes = ["target"],
),
target[OutputGroupInfo],
# TODO(f0rmiga): testing.TestEnvironment is deprecated in favour of RunEnvironmentInfo but
# RunEnvironmentInfo is not exposed in Bazel < 5.3.
# https://github.com/bazelbuild/rules_python/issues/901
# https://github.com/bazelbuild/bazel/commit/dbdfa07e92f99497be9c14265611ad2920161483
testing.TestEnvironment(env),
]
return providers
_COMMON_ATTRS = {
"deps": attr.label_list(
mandatory = False,
),
"env": attr.string_dict(
mandatory = False,
),
"python_version": attr.string(
mandatory = True,
),
"srcs": attr.label_list(
allow_files = True,
mandatory = False,
),
"target": attr.label(
executable = True,
cfg = "target",
mandatory = True,
providers = [PyInfo],
),
# "tools" is a hack here. It should be "data" but "data" is not included by default in the
# location expansion in the same way it is in the native Python rules. The difference on how
# the Bazel deals with those special attributes differ on the LocationExpander, e.g.:
# https://github.com/bazelbuild/bazel/blob/ce611646/src/main/java/com/google/devtools/build/lib/analysis/LocationExpander.java#L415-L429
#
# Since the default LocationExpander used by ctx.expand_location is not the same as the native
# rules (it doesn't set "allowDataAttributeEntriesInLabel"), we use "tools" temporarily while a
# proper fix in Bazel happens.
#
# A fix for this was proposed in https://github.com/bazelbuild/bazel/pull/16381.
"tools": attr.label_list(
allow_files = True,
mandatory = False,
),
# Required to Opt-in to the transitions feature.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
"_windows_constraint": attr.label(
default = "@platforms//os:windows",
),
}
_transition_py_binary = rule(
_transition_py_impl,
attrs = _COMMON_ATTRS,
cfg = _transition_python_version,
executable = True,
)
_transition_py_test = rule(
_transition_py_impl,
attrs = _COMMON_ATTRS,
cfg = _transition_python_version,
test = True,
)
def _py_rule(rule_impl, transition_rule, name, python_version, **kwargs):
args = kwargs.pop("args", None)
data = kwargs.pop("data", None)
env = kwargs.pop("env", None)
srcs = kwargs.pop("srcs", None)
deps = kwargs.pop("deps", None)
# Attributes common to all build rules.
# https://bazel.build/reference/be/common-definitions#common-attributes
compatible_with = kwargs.pop("compatible_with", None)
deprecation = kwargs.pop("deprecation", None)
distribs = kwargs.pop("distribs", None)
exec_compatible_with = kwargs.pop("exec_compatible_with", None)
exec_properties = kwargs.pop("exec_properties", None)
features = kwargs.pop("features", None)
restricted_to = kwargs.pop("restricted_to", None)
tags = kwargs.pop("tags", None)
target_compatible_with = kwargs.pop("target_compatible_with", None)
testonly = kwargs.pop("testonly", None)
toolchains = kwargs.pop("toolchains", None)
visibility = kwargs.pop("visibility", None)
common_attrs = {
"compatible_with": compatible_with,
"deprecation": deprecation,
"distribs": distribs,
"exec_compatible_with": exec_compatible_with,
"exec_properties": exec_properties,
"features": features,
"restricted_to": restricted_to,
"target_compatible_with": target_compatible_with,
"testonly": testonly,
"toolchains": toolchains,
}
# Test-specific extra attributes.
if "env_inherit" in kwargs:
common_attrs["env_inherit"] = kwargs.pop("env_inherit")
if "size" in kwargs:
common_attrs["size"] = kwargs.pop("size")
if "timeout" in kwargs:
common_attrs["timeout"] = kwargs.pop("timeout")
if "flaky" in kwargs:
common_attrs["flaky"] = kwargs.pop("flaky")
if "shard_count" in kwargs:
common_attrs["shard_count"] = kwargs.pop("shard_count")
if "local" in kwargs:
common_attrs["local"] = kwargs.pop("local")
# Binary-specific extra attributes.
if "output_licenses" in kwargs:
common_attrs["output_licenses"] = kwargs.pop("output_licenses")
rule_impl(
name = "_" + name,
args = args,
data = data,
deps = deps,
env = env,
srcs = srcs,
tags = ["manual"] + (tags if tags else []),
visibility = ["//visibility:private"],
**dicts.add(common_attrs, kwargs)
)
return transition_rule(
name = name,
args = args,
deps = deps,
env = env,
python_version = python_version,
srcs = srcs,
tags = tags,
target = ":_" + name,
tools = data,
visibility = visibility,
**common_attrs
)
def py_binary(name, python_version, **kwargs):
return _py_rule(_py_binary, _transition_py_binary, name, python_version, **kwargs)
def py_test(name, python_version, **kwargs):
return _py_rule(_py_test, _transition_py_test, name, python_version, **kwargs)
rules_python-0.22.1/python/constraints/ 0000775 0000000 0000000 00000000000 14540404546 0020225 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/constraints/BUILD.bazel 0000664 0000000 0000000 00000002336 14540404546 0022107 0 ustar 00root root 0000000 0000000 # Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)
# A constraint_setting to use for constraints related to the location of the
# system Python 2 interpreter on a platform.
alias(
name = "py2_interpreter_path",
actual = "@bazel_tools//tools/python:py2_interpreter_path",
)
# A constraint_setting to use for constraints related to the location of the
# system Python 3 interpreter on a platform.
alias(
name = "py3_interpreter_path",
actual = "@bazel_tools//tools/python:py3_interpreter_path",
)
rules_python-0.22.1/python/current_py_toolchain.bzl 0000664 0000000 0000000 00000004276 14540404546 0022632 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for current_py_toolchain rule."""
def _current_py_toolchain_impl(ctx):
toolchain = ctx.toolchains[ctx.attr._toolchain]
direct = []
transitive = []
vars = {}
if toolchain.py3_runtime and toolchain.py3_runtime.interpreter:
direct.append(toolchain.py3_runtime.interpreter)
transitive.append(toolchain.py3_runtime.files)
vars["PYTHON3"] = toolchain.py3_runtime.interpreter.path
if toolchain.py2_runtime and toolchain.py2_runtime.interpreter:
direct.append(toolchain.py2_runtime.interpreter)
transitive.append(toolchain.py2_runtime.files)
vars["PYTHON2"] = toolchain.py2_runtime.interpreter.path
files = depset(direct, transitive = transitive)
return [
toolchain,
platform_common.TemplateVariableInfo(vars),
DefaultInfo(
runfiles = ctx.runfiles(transitive_files = files),
files = files,
),
]
current_py_toolchain = rule(
doc = """
This rule exists so that the current python toolchain can be used in the `toolchains` attribute of
other rules, such as genrule. It allows exposing a python toolchain after toolchain resolution has
happened, to a rule which expects a concrete implementation of a toolchain, rather than a
toolchain_type which could be resolved to that toolchain.
""",
implementation = _current_py_toolchain_impl,
attrs = {
"_toolchain": attr.string(default = str(Label("@bazel_tools//tools/python:toolchain_type"))),
},
toolchains = [
str(Label("@bazel_tools//tools/python:toolchain_type")),
],
)
rules_python-0.22.1/python/defs.bzl 0000664 0000000 0000000 00000003307 14540404546 0017313 0 ustar 00root root 0000000 0000000 # Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Core rules for building Python projects."""
load("@bazel_tools//tools/python:srcs_version.bzl", _find_requirements = "find_requirements")
load("//python:py_binary.bzl", _py_binary = "py_binary")
load("//python:py_info.bzl", internal_PyInfo = "PyInfo")
load("//python:py_library.bzl", _py_library = "py_library")
load("//python:py_runtime.bzl", _py_runtime = "py_runtime")
load("//python:py_runtime_info.bzl", internal_PyRuntimeInfo = "PyRuntimeInfo")
load("//python:py_runtime_pair.bzl", _py_runtime_pair = "py_runtime_pair")
load("//python:py_test.bzl", _py_test = "py_test")
load(":current_py_toolchain.bzl", _current_py_toolchain = "current_py_toolchain")
load(":py_import.bzl", _py_import = "py_import")
# Exports of native-defined providers.
PyInfo = internal_PyInfo
PyRuntimeInfo = internal_PyRuntimeInfo
current_py_toolchain = _current_py_toolchain
py_import = _py_import
# Re-exports of Starlark-defined symbols in @bazel_tools//tools/python.
py_runtime_pair = _py_runtime_pair
find_requirements = _find_requirements
py_library = _py_library
py_binary = _py_binary
py_test = _py_test
py_runtime = _py_runtime
rules_python-0.22.1/python/extensions/ 0000775 0000000 0000000 00000000000 14540404546 0020055 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/extensions/BUILD.bazel 0000664 0000000 0000000 00000001424 14540404546 0021734 0 ustar 00root root 0000000 0000000 # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//extensions:__pkg__"],
)
rules_python-0.22.1/python/extensions/interpreter.bzl 0000664 0000000 0000000 00000005213 14540404546 0023132 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Module extension that finds the current toolchain Python binary and creates a symlink to it."
load("@pythons_hub//:interpreters.bzl", "INTERPRETER_LABELS")
def _interpreter_impl(mctx):
for mod in mctx.modules:
for install_attr in mod.tags.install:
_interpreter_repo(
name = install_attr.name,
python_name = install_attr.python_name,
)
interpreter = module_extension(
doc = """\
This extension is used to expose the underlying platform-specific
interpreter registered as a toolchain. It is used by users to get
a label to the interpreter for use with pip.parse
in the MODULES.bazel file.
""",
implementation = _interpreter_impl,
tag_classes = {
"install": tag_class(
attrs = {
"name": attr.string(
doc = "Name of the interpreter, we use this name to set the interpreter for pip.parse",
mandatory = True,
),
"python_name": attr.string(
doc = "The name set in the previous python.toolchain call.",
mandatory = True,
),
},
),
},
)
def _interpreter_repo_impl(rctx):
rctx.file("BUILD.bazel", "")
actual_interpreter_label = INTERPRETER_LABELS.get(rctx.attr.python_name)
if actual_interpreter_label == None:
fail("Unable to find interpreter with name {}".format(rctx.attr.python_name))
rctx.symlink(actual_interpreter_label, "python")
_interpreter_repo = repository_rule(
doc = """\
Load the INTERPRETER_LABELS map. This map contain of all of the Python binaries
by name and a label the points to the interpreter binary. The
binaries are downloaded as part of the python toolchain setup.
The rule finds the label and creates a symlink named "python" to that
label. This symlink is then used by pip.
""",
implementation = _interpreter_repo_impl,
attrs = {
"python_name": attr.string(
mandatory = True,
doc = "Name of the Python toolchain",
),
},
)
rules_python-0.22.1/python/extensions/pip.bzl 0000664 0000000 0000000 00000007212 14540404546 0021360 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"pip module extension for use with bzlmod"
load("@rules_python//python/pip_install:pip_repository.bzl", "locked_requirements_label", "pip_repository_attrs", "pip_repository_bzlmod", "use_isolated", "whl_library")
load("@rules_python//python/pip_install:requirements_parser.bzl", parse_requirements = "parse")
def _pip_impl(module_ctx):
for mod in module_ctx.modules:
for attr in mod.tags.parse:
requrements_lock = locked_requirements_label(module_ctx, attr)
# Parse the requirements file directly in starlark to get the information
# needed for the whl_libary declarations below. This is needed to contain
# the pip_repository logic to a single module extension.
requirements_lock_content = module_ctx.read(requrements_lock)
parse_result = parse_requirements(requirements_lock_content)
requirements = parse_result.requirements
extra_pip_args = attr.extra_pip_args + parse_result.options
# Create the repository where users load the `requirement` macro. Under bzlmod
# this does not create the install_deps() macro.
pip_repository_bzlmod(
name = attr.name,
repo_name = attr.name,
requirements_lock = attr.requirements_lock,
incompatible_generate_aliases = attr.incompatible_generate_aliases,
)
for name, requirement_line in requirements:
whl_library(
name = "%s_%s" % (attr.name, _sanitize_name(name)),
requirement = requirement_line,
repo = attr.name,
repo_prefix = attr.name + "_",
annotation = attr.annotations.get(name),
python_interpreter = attr.python_interpreter,
python_interpreter_target = attr.python_interpreter_target,
quiet = attr.quiet,
timeout = attr.timeout,
isolated = use_isolated(module_ctx, attr),
extra_pip_args = extra_pip_args,
download_only = attr.download_only,
pip_data_exclude = attr.pip_data_exclude,
enable_implicit_namespace_pkgs = attr.enable_implicit_namespace_pkgs,
environment = attr.environment,
)
# Keep in sync with python/pip_install/tools/bazel.py
def _sanitize_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def _pip_parse_ext_attrs():
attrs = dict({
"name": attr.string(mandatory = True),
}, **pip_repository_attrs)
# Like the pip_repository rule, we end up setting this manually so
# don't allow users to override it.
attrs.pop("repo_prefix")
return attrs
pip = module_extension(
doc = """\
This extension is used to create a pip respository and create the various wheel libaries if
provided in a requirements file.
""",
implementation = _pip_impl,
tag_classes = {
"parse": tag_class(attrs = _pip_parse_ext_attrs()),
},
)
rules_python-0.22.1/python/extensions/private/ 0000775 0000000 0000000 00000000000 14540404546 0021527 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/extensions/private/BUILD.bazel 0000664 0000000 0000000 00000001444 14540404546 0023410 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/extensions/private:__pkg__"],
)
rules_python-0.22.1/python/extensions/private/internal_deps.bzl 0000664 0000000 0000000 00000001675 14540404546 0025100 0 ustar 00root root 0000000 0000000 # http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Python toolchain module extension for internal rule use"
load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("@rules_python//python/private:coverage_deps.bzl", "install_coverage_deps")
# buildifier: disable=unused-variable
def _internal_deps_impl(module_ctx):
pip_install_dependencies()
install_coverage_deps()
internal_deps = module_extension(
doc = "This extension to register internal rules_python dependecies.",
implementation = _internal_deps_impl,
tag_classes = {
"install": tag_class(attrs = dict()),
},
)
rules_python-0.22.1/python/extensions/private/interpreter_hub.bzl 0000664 0000000 0000000 00000003630 14540404546 0025443 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Repo rule used by bzlmod extension to create a repo that has a map of Python interpreters and their labels"
load("//python:versions.bzl", "WINDOWS_NAME")
load("//python/private:toolchains_repo.bzl", "get_host_os_arch", "get_host_platform")
_build_file_for_hub_template = """
INTERPRETER_LABELS = {{
{lines}
}}
"""
_line_for_hub_template = """\
"{name}": Label("@{name}_{platform}//:{path}"),
"""
def _hub_repo_impl(rctx):
(os, arch) = get_host_os_arch(rctx)
platform = get_host_platform(os, arch)
rctx.file("BUILD.bazel", "")
is_windows = (os == WINDOWS_NAME)
path = "python.exe" if is_windows else "bin/python3"
lines = "\n".join([_line_for_hub_template.format(
name = name,
platform = platform,
path = path,
) for name in rctx.attr.toolchains])
rctx.file("interpreters.bzl", _build_file_for_hub_template.format(lines = lines))
hub_repo = repository_rule(
doc = """\
This private rule create a repo with a BUILD file that contains a map of interpreter names
and the labels to said interpreters. This map is used to by the interpreter hub extension.
""",
implementation = _hub_repo_impl,
attrs = {
"toolchains": attr.string_list(
doc = "List of the base names the toolchain repo defines.",
mandatory = True,
),
},
)
rules_python-0.22.1/python/extensions/python.bzl 0000664 0000000 0000000 00000005025 14540404546 0022111 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Python toolchain module extensions for use with bzlmod"
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
load("@rules_python//python/extensions/private:interpreter_hub.bzl", "hub_repo")
def _python_impl(module_ctx):
toolchains = []
for mod in module_ctx.modules:
for toolchain_attr in mod.tags.toolchain:
python_register_toolchains(
name = toolchain_attr.name,
python_version = toolchain_attr.python_version,
bzlmod = True,
# Toolchain registration in bzlmod is done in MODULE file
register_toolchains = False,
register_coverage_tool = toolchain_attr.configure_coverage_tool,
ignore_root_user_error = toolchain_attr.ignore_root_user_error,
)
# We collect all of the toolchain names to create
# the INTERPRETER_LABELS map. This is used
# by interpreter_extensions.bzl
toolchains.append(toolchain_attr.name)
hub_repo(
name = "pythons_hub",
toolchains = toolchains,
)
python = module_extension(
doc = "Bzlmod extension that is used to register a Python toolchain.",
implementation = _python_impl,
tag_classes = {
"toolchain": tag_class(
attrs = {
"configure_coverage_tool": attr.bool(
mandatory = False,
doc = "Whether or not to configure the default coverage tool for the toolchains.",
),
"ignore_root_user_error": attr.bool(
default = False,
doc = "Whether the check for root should be ignored or not. This causes cache misses with .pyc files.",
mandatory = False,
),
"name": attr.string(mandatory = True),
"python_version": attr.string(mandatory = True),
},
),
},
)
rules_python-0.22.1/python/packaging.bzl 0000664 0000000 0000000 00000014115 14540404546 0020315 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public API for for building wheels."""
load("//python/private:py_package.bzl", "py_package_lib")
load("//python/private:py_wheel.bzl", _PyWheelInfo = "PyWheelInfo", _py_wheel = "py_wheel")
load("//python/private:util.bzl", "copy_propagating_kwargs")
# Re-export as public API
PyWheelInfo = _PyWheelInfo
py_package = rule(
implementation = py_package_lib.implementation,
doc = """\
A rule to select all files in transitive dependencies of deps which
belong to given set of Python packages.
This rule is intended to be used as data dependency to py_wheel rule.
""",
attrs = py_package_lib.attrs,
)
# Based on https://github.com/aspect-build/bazel-lib/tree/main/lib/private/copy_to_directory.bzl
# Avoiding a bazelbuild -> aspect-build dependency :(
def _py_wheel_dist_impl(ctx):
dir = ctx.actions.declare_directory(ctx.attr.out)
name_file = ctx.attr.wheel[PyWheelInfo].name_file
cmds = [
"mkdir -p \"%s\"" % dir.path,
"""cp "{}" "{}/$(cat "{}")" """.format(ctx.files.wheel[0].path, dir.path, name_file.path),
]
ctx.actions.run_shell(
inputs = ctx.files.wheel + [name_file],
outputs = [dir],
command = "\n".join(cmds),
mnemonic = "CopyToDirectory",
progress_message = "Copying files to directory",
use_default_shell_env = True,
)
return [
DefaultInfo(files = depset([dir])),
]
py_wheel_dist = rule(
doc = """\
Prepare a dist/ folder, following Python's packaging standard practice.
See https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives
which recommends a dist/ folder containing the wheel file(s), source distributions, etc.
This also has the advantage that stamping information is included in the wheel's filename.
""",
implementation = _py_wheel_dist_impl,
attrs = {
"out": attr.string(doc = "name of the resulting directory", mandatory = True),
"wheel": attr.label(doc = "a [py_wheel rule](/docs/packaging.md#py_wheel_rule)", providers = [PyWheelInfo]),
},
)
def py_wheel(name, twine = None, **kwargs):
"""Builds a Python Wheel.
Wheels are Python distribution format defined in https://www.python.org/dev/peps/pep-0427/.
This macro packages a set of targets into a single wheel.
It wraps the [py_wheel rule](#py_wheel_rule).
Currently only pure-python wheels are supported.
Examples:
```python
# Package some specific py_library targets, without their dependencies
py_wheel(
name = "minimal_with_py_library",
# Package data. We're building "example_minimal_library-0.0.1-py3-none-any.whl"
distribution = "example_minimal_library",
python_tag = "py3",
version = "0.0.1",
deps = [
"//examples/wheel/lib:module_with_data",
"//examples/wheel/lib:simple_module",
],
)
# Use py_package to collect all transitive dependencies of a target,
# selecting just the files within a specific python package.
py_package(
name = "example_pkg",
# Only include these Python packages.
packages = ["examples.wheel"],
deps = [":main"],
)
py_wheel(
name = "minimal_with_py_package",
# Package data. We're building "example_minimal_package-0.0.1-py3-none-any.whl"
distribution = "example_minimal_package",
python_tag = "py3",
version = "0.0.1",
deps = [":example_pkg"],
)
```
To publish the wheel to Pypi, the twine package is required.
rules_python doesn't provide twine itself, see https://github.com/bazelbuild/rules_python/issues/1016
However you can install it with pip_parse, just like we do in the WORKSPACE file in rules_python.
Once you've installed twine, you can pass its label to the `twine` attribute of this macro,
to get a "[name].publish" target.
Example:
```python
py_wheel(
name = "my_wheel",
twine = "@publish_deps_twine//:pkg",
...
)
```
Now you can run a command like the following, which publishes to https://test.pypi.org/
```sh
% TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-*** \\
bazel run --stamp --embed_label=1.2.4 -- \\
//path/to:my_wheel.publish --repository testpypi
```
Args:
name: A unique name for this target.
twine: A label of the external location of the py_library target for twine
**kwargs: other named parameters passed to the underlying [py_wheel rule](#py_wheel_rule)
"""
_dist_target = "{}.dist".format(name)
py_wheel_dist(
name = _dist_target,
wheel = name,
out = kwargs.pop("dist_folder", "{}_dist".format(name)),
**copy_propagating_kwargs(kwargs)
)
_py_wheel(name = name, **kwargs)
if twine:
if not twine.endswith(":pkg"):
fail("twine label should look like @my_twine_repo//:pkg")
twine_main = twine.replace(":pkg", ":rules_python_wheel_entry_point_twine.py")
# TODO: use py_binary from //python:defs.bzl after our stardoc setup is less brittle
# buildifier: disable=native-py
native.py_binary(
name = "{}.publish".format(name),
srcs = [twine_main],
args = [
"upload",
"$(rootpath :{})/*".format(_dist_target),
],
data = [_dist_target],
imports = ["."],
main = twine_main,
deps = [twine],
visibility = kwargs.get("visibility"),
)
py_wheel_rule = _py_wheel
rules_python-0.22.1/python/pip.bzl 0000664 0000000 0000000 00000033111 14540404546 0017156 0 ustar 00root root 0000000 0000000 # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Import pip requirements into Bazel."""
load("//python/pip_install:pip_repository.bzl", "pip_repository", _package_annotation = "package_annotation")
load("//python/pip_install:repositories.bzl", "pip_install_dependencies")
load("//python/pip_install:requirements.bzl", _compile_pip_requirements = "compile_pip_requirements")
load(":versions.bzl", "MINOR_MAPPING")
compile_pip_requirements = _compile_pip_requirements
package_annotation = _package_annotation
def pip_install(requirements = None, name = "pip", **kwargs):
"""Accepts a locked/compiled requirements file and installs the dependencies listed within.
```python
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
name = "pip_deps",
requirements = ":requirements.txt",
)
load("@pip_deps//:requirements.bzl", "install_deps")
install_deps()
```
Args:
requirements (Label): A 'requirements.txt' pip requirements file.
name (str, optional): A unique name for the created external repository (default 'pip').
**kwargs (dict): Additional arguments to the [`pip_repository`](./pip_repository.md) repository rule.
"""
# buildifier: disable=print
print("pip_install is deprecated. Please switch to pip_parse. pip_install will be removed in a future release.")
pip_parse(requirements = requirements, name = name, **kwargs)
def pip_parse(requirements = None, requirements_lock = None, name = "pip_parsed_deps", **kwargs):
"""Accepts a locked/compiled requirements file and installs the dependencies listed within.
Those dependencies become available in a generated `requirements.bzl` file.
You can instead check this `requirements.bzl` file into your repo, see the "vendoring" section below.
This macro wraps the [`pip_repository`](./pip_repository.md) rule that invokes `pip`.
In your WORKSPACE file:
```python
load("@rules_python//python:pip.bzl", "pip_parse")
pip_parse(
name = "pip_deps",
requirements_lock = ":requirements.txt",
)
load("@pip_deps//:requirements.bzl", "install_deps")
install_deps()
```
You can then reference installed dependencies from a `BUILD` file with:
```python
load("@pip_deps//:requirements.bzl", "requirement")
py_library(
name = "bar",
...
deps = [
"//my/other:dep",
requirement("requests"),
requirement("numpy"),
],
)
```
In addition to the `requirement` macro, which is used to access the generated `py_library`
target generated from a package's wheel, The generated `requirements.bzl` file contains
functionality for exposing [entry points][whl_ep] as `py_binary` targets as well.
[whl_ep]: https://packaging.python.org/specifications/entry-points/
```python
load("@pip_deps//:requirements.bzl", "entry_point")
alias(
name = "pip-compile",
actual = entry_point(
pkg = "pip-tools",
script = "pip-compile",
),
)
```
Note that for packages whose name and script are the same, only the name of the package
is needed when calling the `entry_point` macro.
```python
load("@pip_deps//:requirements.bzl", "entry_point")
alias(
name = "flake8",
actual = entry_point("flake8"),
)
```
## Vendoring the requirements.bzl file
In some cases you may not want to generate the requirements.bzl file as a repository rule
while Bazel is fetching dependencies. For example, if you produce a reusable Bazel module
such as a ruleset, you may want to include the requirements.bzl file rather than make your users
install the WORKSPACE setup to generate it.
See https://github.com/bazelbuild/rules_python/issues/608
This is the same workflow as Gazelle, which creates `go_repository` rules with
[`update-repos`](https://github.com/bazelbuild/bazel-gazelle#update-repos)
To do this, use the "write to source file" pattern documented in
https://blog.aspect.dev/bazel-can-write-to-the-source-folder
to put a copy of the generated requirements.bzl into your project.
Then load the requirements.bzl file directly rather than from the generated repository.
See the example in rules_python/examples/pip_parse_vendored.
Args:
requirements_lock (Label): A fully resolved 'requirements.txt' pip requirement file
containing the transitive set of your dependencies. If this file is passed instead
of 'requirements' no resolve will take place and pip_repository will create
individual repositories for each of your dependencies so that wheels are
fetched/built only for the targets specified by 'build/run/test'.
Note that if your lockfile is platform-dependent, you can use the `requirements_[platform]`
attributes.
requirements (Label): Deprecated. See requirements_lock.
name (str, optional): The name of the generated repository. The generated repositories
containing each requirement will be of the form `_`.
**kwargs (dict): Additional arguments to the [`pip_repository`](./pip_repository.md) repository rule.
"""
pip_install_dependencies()
# Temporary compatibility shim.
# pip_install was previously document to use requirements while pip_parse was using requirements_lock.
# We would prefer everyone move to using requirements_lock, but we maintain a temporary shim.
reqs_to_use = requirements_lock if requirements_lock else requirements
pip_repository(
name = name,
requirements_lock = reqs_to_use,
**kwargs
)
def _multi_pip_parse_impl(rctx):
rules_python = rctx.attr._rules_python_workspace.workspace_name
load_statements = []
install_deps_calls = []
process_requirements_calls = []
for python_version, pypi_repository in rctx.attr.pip_parses.items():
sanitized_python_version = python_version.replace(".", "_")
load_statement = """\
load(
"@{pypi_repository}//:requirements.bzl",
_{sanitized_python_version}_install_deps = "install_deps",
_{sanitized_python_version}_all_requirements = "all_requirements",
)""".format(
pypi_repository = pypi_repository,
sanitized_python_version = sanitized_python_version,
)
load_statements.append(load_statement)
process_requirements_call = """\
_process_requirements(
pkg_labels = _{sanitized_python_version}_all_requirements,
python_version = "{python_version}",
repo_prefix = "{pypi_repository}_",
)""".format(
pypi_repository = pypi_repository,
python_version = python_version,
sanitized_python_version = sanitized_python_version,
)
process_requirements_calls.append(process_requirements_call)
install_deps_call = """ _{sanitized_python_version}_install_deps(**whl_library_kwargs)""".format(
sanitized_python_version = sanitized_python_version,
)
install_deps_calls.append(install_deps_call)
requirements_bzl = """\
# Generated by python/pip.bzl
load("@{rules_python}//python:pip.bzl", "whl_library_alias")
{load_statements}
_wheel_names = []
_version_map = dict()
def _process_requirements(pkg_labels, python_version, repo_prefix):
for pkg_label in pkg_labels:
workspace_name = Label(pkg_label).workspace_name
wheel_name = workspace_name[len(repo_prefix):]
_wheel_names.append(wheel_name)
if not wheel_name in _version_map:
_version_map[wheel_name] = dict()
_version_map[wheel_name][python_version] = repo_prefix
{process_requirements_calls}
def _clean_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def requirement(name):
return "@{name}_" + _clean_name(name) + "//:pkg"
def whl_requirement(name):
return "@{name}_" + _clean_name(name) + "//:whl"
def data_requirement(name):
return "@{name}_" + _clean_name(name) + "//:data"
def dist_info_requirement(name):
return "@{name}_" + _clean_name(name) + "//:dist_info"
def entry_point(pkg, script = None):
fail("Not implemented yet")
def install_deps(**whl_library_kwargs):
{install_deps_calls}
for wheel_name in _wheel_names:
whl_library_alias(
name = "{name}_" + wheel_name,
wheel_name = wheel_name,
default_version = "{default_version}",
version_map = _version_map[wheel_name],
)
""".format(
name = rctx.attr.name,
install_deps_calls = "\n".join(install_deps_calls),
load_statements = "\n".join(load_statements),
process_requirements_calls = "\n".join(process_requirements_calls),
rules_python = rules_python,
default_version = rctx.attr.default_version,
)
rctx.file("requirements.bzl", requirements_bzl)
rctx.file("BUILD.bazel", "exports_files(['requirements.bzl'])")
_multi_pip_parse = repository_rule(
_multi_pip_parse_impl,
attrs = {
"default_version": attr.string(),
"pip_parses": attr.string_dict(),
"_rules_python_workspace": attr.label(default = Label("//:WORKSPACE")),
},
)
def _whl_library_alias_impl(rctx):
rules_python = rctx.attr._rules_python_workspace.workspace_name
default_repo_prefix = rctx.attr.version_map[rctx.attr.default_version]
version_map = rctx.attr.version_map.items()
build_content = ["# Generated by python/pip.bzl"]
for alias_name in ["pkg", "whl", "data", "dist_info"]:
build_content.append(_whl_library_render_alias_target(
alias_name = alias_name,
default_repo_prefix = default_repo_prefix,
rules_python = rules_python,
version_map = version_map,
wheel_name = rctx.attr.wheel_name,
))
rctx.file("BUILD.bazel", "\n".join(build_content))
def _whl_library_render_alias_target(
alias_name,
default_repo_prefix,
rules_python,
version_map,
wheel_name):
alias = ["""\
alias(
name = "{alias_name}",
actual = select({{""".format(alias_name = alias_name)]
for [python_version, repo_prefix] in version_map:
alias.append("""\
"@{rules_python}//python/config_settings:is_python_{full_python_version}": "{actual}",""".format(
full_python_version = MINOR_MAPPING[python_version] if python_version in MINOR_MAPPING else python_version,
actual = "@{repo_prefix}{wheel_name}//:{alias_name}".format(
repo_prefix = repo_prefix,
wheel_name = wheel_name,
alias_name = alias_name,
),
rules_python = rules_python,
))
alias.append("""\
"//conditions:default": "{default_actual}",
}}),
visibility = ["//visibility:public"],
)""".format(
default_actual = "@{repo_prefix}{wheel_name}//:{alias_name}".format(
repo_prefix = default_repo_prefix,
wheel_name = wheel_name,
alias_name = alias_name,
),
))
return "\n".join(alias)
whl_library_alias = repository_rule(
_whl_library_alias_impl,
attrs = {
"default_version": attr.string(mandatory = True),
"version_map": attr.string_dict(mandatory = True),
"wheel_name": attr.string(mandatory = True),
"_rules_python_workspace": attr.label(default = Label("//:WORKSPACE")),
},
)
def multi_pip_parse(name, default_version, python_versions, python_interpreter_target, requirements_lock, **kwargs):
"""NOT INTENDED FOR DIRECT USE!
This is intended to be used by the multi_pip_parse implementation in the template of the
multi_toolchain_aliases repository rule.
Args:
name: the name of the multi_pip_parse repository.
default_version: the default Python version.
python_versions: all Python toolchain versions currently registered.
python_interpreter_target: a dictionary which keys are Python versions and values are resolved host interpreters.
requirements_lock: a dictionary which keys are Python versions and values are locked requirements files.
**kwargs: extra arguments passed to all wrapped pip_parse.
Returns:
The internal implementation of multi_pip_parse repository rule.
"""
pip_parses = {}
for python_version in python_versions:
if not python_version in python_interpreter_target:
fail("Missing python_interpreter_target for Python version %s in '%s'" % (python_version, name))
if not python_version in requirements_lock:
fail("Missing requirements_lock for Python version %s in '%s'" % (python_version, name))
pip_parse_name = name + "_" + python_version.replace(".", "_")
pip_parse(
name = pip_parse_name,
python_interpreter_target = python_interpreter_target[python_version],
requirements_lock = requirements_lock[python_version],
**kwargs
)
pip_parses[python_version] = pip_parse_name
return _multi_pip_parse(
name = name,
default_version = default_version,
pip_parses = pip_parses,
)
rules_python-0.22.1/python/pip_install/ 0000775 0000000 0000000 00000000000 14540404546 0020174 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/pip_install/.gitignore 0000664 0000000 0000000 00000003455 14540404546 0022173 0 ustar 00root root 0000000 0000000 # Intellij
.ijwb/
.idea/
# Bazel
bazel-*
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
rules_python-0.22.1/python/pip_install/BUILD.bazel 0000664 0000000 0000000 00000001615 14540404546 0022055 0 ustar 00root root 0000000 0000000 filegroup(
name = "distribution",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
"//python/pip_install/private:distribution",
"//python/pip_install/tools/dependency_resolver:distribution",
"//python/pip_install/tools/lib:distribution",
"//python/pip_install/tools/wheel_installer:distribution",
],
visibility = ["//:__pkg__"],
)
filegroup(
name = "bzl",
srcs = glob(["*.bzl"]) + [
"//python/pip_install/private:bzl_srcs",
],
visibility = ["//:__subpackages__"],
)
filegroup(
name = "py_srcs",
srcs = [
"//python/pip_install/tools/dependency_resolver:py_srcs",
"//python/pip_install/tools/lib:py_srcs",
"//python/pip_install/tools/wheel_installer:py_srcs",
],
visibility = ["//python/pip_install/private:__pkg__"],
)
exports_files(
glob(["*.bzl"]),
visibility = ["//docs:__pkg__"],
)
rules_python-0.22.1/python/pip_install/pip_repository.bzl 0000664 0000000 0000000 00000065720 14540404546 0024006 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""
load("//python:repositories.bzl", "get_interpreter_dirname", "is_standalone_interpreter")
load("//python/pip_install:repositories.bzl", "all_requirements")
load("//python/pip_install:requirements_parser.bzl", parse_requirements = "parse")
load("//python/pip_install/private:srcs.bzl", "PIP_INSTALL_PY_SRCS")
CPPFLAGS = "CPPFLAGS"
COMMAND_LINE_TOOLS_PATH_SLUG = "commandlinetools"
def _construct_pypath(rctx):
"""Helper function to construct a PYTHONPATH.
Contains entries for code in this repo as well as packages downloaded from //python/pip_install:repositories.bzl.
This allows us to run python code inside repository rule implementations.
Args:
rctx: Handle to the repository_context.
Returns: String of the PYTHONPATH.
"""
# Get the root directory of these rules
rules_root = rctx.path(Label("//:BUILD.bazel")).dirname
thirdparty_roots = [
# Includes all the external dependencies from repositories.bzl
rctx.path(Label("@" + repo + "//:BUILD.bazel")).dirname
for repo in all_requirements
]
separator = ":" if not "windows" in rctx.os.name.lower() else ";"
pypath = separator.join([str(p) for p in [rules_root] + thirdparty_roots])
return pypath
def _get_python_interpreter_attr(rctx):
"""A helper function for getting the `python_interpreter` attribute or it's default
Args:
rctx (repository_ctx): Handle to the rule repository context.
Returns:
str: The attribute value or it's default
"""
if rctx.attr.python_interpreter:
return rctx.attr.python_interpreter
if "win" in rctx.os.name:
return "python.exe"
else:
return "python3"
def _resolve_python_interpreter(rctx):
"""Helper function to find the python interpreter from the common attributes
Args:
rctx: Handle to the rule repository context.
Returns: Python interpreter path.
"""
python_interpreter = _get_python_interpreter_attr(rctx)
if rctx.attr.python_interpreter_target != None:
target = rctx.attr.python_interpreter_target
python_interpreter = rctx.path(target)
elif "/" not in python_interpreter:
found_python_interpreter = rctx.which(python_interpreter)
if not found_python_interpreter:
fail("python interpreter `{}` not found in PATH".format(python_interpreter))
python_interpreter = found_python_interpreter
return python_interpreter
def _get_xcode_location_cflags(rctx):
"""Query the xcode sdk location to update cflags
Figure out if this interpreter target comes from rules_python, and patch the xcode sdk location if so.
Pip won't be able to compile c extensions from sdists with the pre built python distributions from indygreg
otherwise. See https://github.com/indygreg/python-build-standalone/issues/103
"""
# Only run on MacOS hosts
if not rctx.os.name.lower().startswith("mac os"):
return []
# Locate xcode-select
xcode_select = rctx.which("xcode-select")
xcode_sdk_location = rctx.execute([xcode_select, "--print-path"])
if xcode_sdk_location.return_code != 0:
return []
xcode_root = xcode_sdk_location.stdout.strip()
if COMMAND_LINE_TOOLS_PATH_SLUG not in xcode_root.lower():
# This is a full xcode installation somewhere like /Applications/Xcode13.0.app/Contents/Developer
# so we need to change the path to to the macos specific tools which are in a different relative
# path than xcode installed command line tools.
xcode_root = "{}/Platforms/MacOSX.platform/Developer".format(xcode_root)
return [
"-isysroot {}/SDKs/MacOSX.sdk".format(xcode_root),
]
def _get_toolchain_unix_cflags(rctx):
"""Gather cflags from a standalone toolchain for unix systems.
Pip won't be able to compile c extensions from sdists with the pre built python distributions from indygreg
otherwise. See https://github.com/indygreg/python-build-standalone/issues/103
"""
# Only run on Unix systems
if not rctx.os.name.lower().startswith(("mac os", "linux")):
return []
# Only update the location when using a standalone toolchain.
if not is_standalone_interpreter(rctx, rctx.attr.python_interpreter_target):
return []
er = rctx.execute([
rctx.path(rctx.attr.python_interpreter_target).realpath,
"-c",
"import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}', end='')",
])
if er.return_code != 0:
fail("could not get python version from interpreter (status {}): {}".format(er.return_code, er.stderr))
_python_version = er.stdout
include_path = "{}/include/python{}".format(
get_interpreter_dirname(rctx, rctx.attr.python_interpreter_target),
_python_version,
)
return ["-isystem {}".format(include_path)]
def use_isolated(ctx, attr):
"""Determine whether or not to pass the pip `--isolated` flag to the pip invocation.
Args:
ctx: repository or module context
attr: attributes for the repo rule or tag extension
Returns:
True if --isolated should be passed
"""
use_isolated = attr.isolated
# The environment variable will take precedence over the attribute
isolated_env = ctx.os.environ.get("RULES_PYTHON_PIP_ISOLATED", None)
if isolated_env != None:
if isolated_env.lower() in ("0", "false"):
use_isolated = False
else:
use_isolated = True
return use_isolated
def _parse_optional_attrs(rctx, args):
"""Helper function to parse common attributes of pip_repository and whl_library repository rules.
This function also serializes the structured arguments as JSON
so they can be passed on the command line to subprocesses.
Args:
rctx: Handle to the rule repository context.
args: A list of parsed args for the rule.
Returns: Augmented args list.
"""
if use_isolated(rctx, rctx.attr):
args.append("--isolated")
# Check for None so we use empty default types from our attrs.
# Some args want to be list, and some want to be dict.
if rctx.attr.extra_pip_args != None:
args += [
"--extra_pip_args",
json.encode(struct(arg = rctx.attr.extra_pip_args)),
]
if rctx.attr.download_only:
args.append("--download_only")
if rctx.attr.pip_data_exclude != None:
args += [
"--pip_data_exclude",
json.encode(struct(arg = rctx.attr.pip_data_exclude)),
]
if rctx.attr.enable_implicit_namespace_pkgs:
args.append("--enable_implicit_namespace_pkgs")
if rctx.attr.environment != None:
args += [
"--environment",
json.encode(struct(arg = rctx.attr.environment)),
]
return args
def _create_repository_execution_environment(rctx):
"""Create a environment dictionary for processes we spawn with rctx.execute.
Args:
rctx: The repository context.
Returns:
Dictionary of environment variable suitable to pass to rctx.execute.
"""
# Gather any available CPPFLAGS values
cppflags = []
cppflags.extend(_get_xcode_location_cflags(rctx))
cppflags.extend(_get_toolchain_unix_cflags(rctx))
env = {
"PYTHONPATH": _construct_pypath(rctx),
CPPFLAGS: " ".join(cppflags),
}
return env
_BUILD_FILE_CONTENTS = """\
package(default_visibility = ["//visibility:public"])
# Ensure the `requirements.bzl` source can be accessed by stardoc, since users load() from it
exports_files(["requirements.bzl"])
"""
def locked_requirements_label(ctx, attr):
"""Get the preferred label for a locked requirements file based on platform.
Args:
ctx: repository or module context
attr: attributes for the repo rule or tag extension
Returns:
Label
"""
os = ctx.os.name.lower()
requirements_txt = attr.requirements_lock
if os.startswith("mac os") and attr.requirements_darwin != None:
requirements_txt = attr.requirements_darwin
elif os.startswith("linux") and attr.requirements_linux != None:
requirements_txt = attr.requirements_linux
elif "win" in os and attr.requirements_windows != None:
requirements_txt = attr.requirements_windows
if not requirements_txt:
fail("""\
A requirements_lock attribute must be specified, or a platform-specific lockfile using one of the requirements_* attributes.
""")
return requirements_txt
# Keep in sync with `_clean_pkg_name` in generated bzlmod requirements.bzl
def _clean_pkg_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def _pkg_aliases(rctx, repo_name, bzl_packages):
"""Create alias declarations for each python dependency.
The aliases should be appended to the pip_repository BUILD.bazel file. These aliases
allow users to use requirement() without needed a corresponding `use_repo()` for each dep
when using bzlmod.
Args:
rctx: the repository context.
repo_name: the repository name of the parent that is visible to the users.
bzl_packages: the list of packages to setup.
"""
for name in bzl_packages:
build_content = """package(default_visibility = ["//visibility:public"])
alias(
name = "{name}",
actual = "@{repo_name}_{dep}//:pkg",
)
alias(
name = "pkg",
actual = "@{repo_name}_{dep}//:pkg",
)
alias(
name = "whl",
actual = "@{repo_name}_{dep}//:whl",
)
alias(
name = "data",
actual = "@{repo_name}_{dep}//:data",
)
alias(
name = "dist_info",
actual = "@{repo_name}_{dep}//:dist_info",
)
""".format(
name = name,
repo_name = repo_name,
dep = name,
)
rctx.file("{}/BUILD.bazel".format(name), build_content)
def _bzlmod_pkg_aliases(repo_name, bzl_packages):
"""Create alias declarations for each python dependency.
The aliases should be appended to the pip_repository BUILD.bazel file. These aliases
allow users to use requirement() without needed a corresponding `use_repo()` for each dep
when using bzlmod.
Args:
repo_name: the repository name of the parent that is visible to the users.
bzl_packages: the list of packages to setup.
"""
build_content = ""
for name in bzl_packages:
build_content += """\
alias(
name = "{name}_pkg",
actual = "@{repo_name}_{dep}//:pkg",
)
alias(
name = "{name}_whl",
actual = "@{repo_name}_{dep}//:whl",
)
alias(
name = "{name}_data",
actual = "@{repo_name}_{dep}//:data",
)
alias(
name = "{name}_dist_info",
actual = "@{repo_name}_{dep}//:dist_info",
)
""".format(
name = name,
repo_name = repo_name,
dep = name,
)
return build_content
def _pip_repository_bzlmod_impl(rctx):
requirements_txt = locked_requirements_label(rctx, rctx.attr)
content = rctx.read(requirements_txt)
parsed_requirements_txt = parse_requirements(content)
packages = [(_clean_pkg_name(name), requirement) for name, requirement in parsed_requirements_txt.requirements]
bzl_packages = sorted([name for name, _ in packages])
repo_name = rctx.attr.repo_name
build_contents = _BUILD_FILE_CONTENTS
if rctx.attr.incompatible_generate_aliases:
_pkg_aliases(rctx, repo_name, bzl_packages)
else:
build_contents += _bzlmod_pkg_aliases(repo_name, bzl_packages)
# NOTE: we are using the canonical name with the double '@' in order to
# always uniquely identify a repository, as the labels are being passed as
# a string and the resolution of the label happens at the call-site of the
# `requirement`, et al. macros.
if rctx.attr.incompatible_generate_aliases:
macro_tmpl = "@@{name}//{{}}:{{}}".format(name = rctx.attr.name)
else:
macro_tmpl = "@@{name}//:{{}}_{{}}".format(name = rctx.attr.name)
rctx.file("BUILD.bazel", build_contents)
rctx.template("requirements.bzl", rctx.attr._template, substitutions = {
"%%ALL_REQUIREMENTS%%": _format_repr_list([
macro_tmpl.format(p, p) if rctx.attr.incompatible_generate_aliases else macro_tmpl.format(p, "pkg")
for p in bzl_packages
]),
"%%ALL_WHL_REQUIREMENTS%%": _format_repr_list([
macro_tmpl.format(p, "whl")
for p in bzl_packages
]),
"%%MACRO_TMPL%%": macro_tmpl,
"%%NAME%%": rctx.attr.name,
"%%REQUIREMENTS_LOCK%%": str(requirements_txt),
})
pip_repository_bzlmod_attrs = {
"incompatible_generate_aliases": attr.bool(
default = False,
doc = "Allow generating aliases in '@pip//:' -> '@pip_//:pkg'. This replaces the aliases generated by the `bzlmod` tooling.",
),
"repo_name": attr.string(
mandatory = True,
doc = "The apparent name of the repo. This is needed because in bzlmod, the name attribute becomes the canonical name",
),
"requirements_darwin": attr.label(
allow_single_file = True,
doc = "Override the requirements_lock attribute when the host platform is Mac OS",
),
"requirements_linux": attr.label(
allow_single_file = True,
doc = "Override the requirements_lock attribute when the host platform is Linux",
),
"requirements_lock": attr.label(
allow_single_file = True,
doc = """
A fully resolved 'requirements.txt' pip requirement file containing the transitive set of your dependencies. If this file is passed instead
of 'requirements' no resolve will take place and pip_repository will create individual repositories for each of your dependencies so that
wheels are fetched/built only for the targets specified by 'build/run/test'.
""",
),
"requirements_windows": attr.label(
allow_single_file = True,
doc = "Override the requirements_lock attribute when the host platform is Windows",
),
"_template": attr.label(
default = ":pip_repository_requirements_bzlmod.bzl.tmpl",
),
}
pip_repository_bzlmod = repository_rule(
attrs = pip_repository_bzlmod_attrs,
doc = """A rule for bzlmod pip_repository creation. Intended for private use only.""",
implementation = _pip_repository_bzlmod_impl,
)
def _pip_repository_impl(rctx):
requirements_txt = locked_requirements_label(rctx, rctx.attr)
content = rctx.read(requirements_txt)
parsed_requirements_txt = parse_requirements(content)
packages = [(_clean_pkg_name(name), requirement) for name, requirement in parsed_requirements_txt.requirements]
bzl_packages = sorted([name for name, _ in packages])
imports = [
'load("@rules_python//python/pip_install:pip_repository.bzl", "whl_library")',
]
annotations = {}
for pkg, annotation in rctx.attr.annotations.items():
filename = "{}.annotation.json".format(_clean_pkg_name(pkg))
rctx.file(filename, json.encode_indent(json.decode(annotation)))
annotations[pkg] = "@{name}//:{filename}".format(name = rctx.attr.name, filename = filename)
tokenized_options = []
for opt in parsed_requirements_txt.options:
for p in opt.split(" "):
tokenized_options.append(p)
options = tokenized_options + rctx.attr.extra_pip_args
config = {
"download_only": rctx.attr.download_only,
"enable_implicit_namespace_pkgs": rctx.attr.enable_implicit_namespace_pkgs,
"environment": rctx.attr.environment,
"extra_pip_args": options,
"isolated": use_isolated(rctx, rctx.attr),
"pip_data_exclude": rctx.attr.pip_data_exclude,
"python_interpreter": _get_python_interpreter_attr(rctx),
"quiet": rctx.attr.quiet,
"repo": rctx.attr.name,
"repo_prefix": "{}_".format(rctx.attr.name),
"timeout": rctx.attr.timeout,
}
if rctx.attr.python_interpreter_target:
config["python_interpreter_target"] = str(rctx.attr.python_interpreter_target)
if rctx.attr.incompatible_generate_aliases:
_pkg_aliases(rctx, rctx.attr.name, bzl_packages)
rctx.file("BUILD.bazel", _BUILD_FILE_CONTENTS)
rctx.template("requirements.bzl", rctx.attr._template, substitutions = {
"%%ALL_REQUIREMENTS%%": _format_repr_list([
"@{}//{}".format(rctx.attr.name, p) if rctx.attr.incompatible_generate_aliases else "@{}_{}//:pkg".format(rctx.attr.name, p)
for p in bzl_packages
]),
"%%ALL_WHL_REQUIREMENTS%%": _format_repr_list([
"@{}//{}:whl".format(rctx.attr.name, p) if rctx.attr.incompatible_generate_aliases else "@{}_{}//:whl".format(rctx.attr.name, p)
for p in bzl_packages
]),
"%%ANNOTATIONS%%": _format_dict(_repr_dict(annotations)),
"%%CONFIG%%": _format_dict(_repr_dict(config)),
"%%EXTRA_PIP_ARGS%%": json.encode(options),
"%%IMPORTS%%": "\n".join(sorted(imports)),
"%%NAME%%": rctx.attr.name,
"%%PACKAGES%%": _format_repr_list(
[
("{}_{}".format(rctx.attr.name, p), r)
for p, r in packages
],
),
"%%REQUIREMENTS_LOCK%%": str(requirements_txt),
})
return
common_env = [
"RULES_PYTHON_PIP_ISOLATED",
]
common_attrs = {
"download_only": attr.bool(
doc = """
Whether to use "pip download" instead of "pip wheel". Disables building wheels from source, but allows use of
--platform, --python-version, --implementation, and --abi in --extra_pip_args to download wheels for a different
platform from the host platform.
""",
),
"enable_implicit_namespace_pkgs": attr.bool(
default = False,
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.
""",
),
"environment": attr.string_dict(
doc = """
Environment variables to set in the pip subprocess.
Can be used to set common variables such as `http_proxy`, `https_proxy` and `no_proxy`
Note that pip is run with "--isolated" on the CLI so `PIP__`
style env vars are ignored, but env vars that control requests and urllib3
can be passed.
""",
default = {},
),
"extra_pip_args": attr.string_list(
doc = "Extra arguments to pass on to pip. Must not contain spaces.",
),
"isolated": attr.bool(
doc = """\
Whether or not to pass the [--isolated](https://pip.pypa.io/en/stable/cli/pip/#cmdoption-isolated) flag to
the underlying pip command. Alternatively, the `RULES_PYTHON_PIP_ISOLATED` environment variable can be used
to control this flag.
""",
default = True,
),
"pip_data_exclude": attr.string_list(
doc = "Additional data exclusion parameters to add to the pip packages BUILD file.",
),
"python_interpreter": attr.string(
doc = """\
The python interpreter to use. This can either be an absolute path or the name
of a binary found on the host's `PATH` environment variable. If no value is set
`python3` is defaulted for Unix systems and `python.exe` for Windows.
""",
# NOTE: This attribute should not have a default. See `_get_python_interpreter_attr`
# default = "python3"
),
"python_interpreter_target": attr.label(
allow_single_file = True,
doc = """
If you are using a custom python interpreter built by another repository rule,
use this attribute to specify its BUILD target. This allows pip_repository to invoke
pip using the same interpreter as your toolchain. If set, takes precedence over
python_interpreter. An example value: "@python3_x86_64-unknown-linux-gnu//:python".
""",
),
"quiet": attr.bool(
default = True,
doc = "If True, suppress printing stdout and stderr output to the terminal.",
),
"repo_prefix": attr.string(
doc = """
Prefix for the generated packages will be of the form `@//...`
""",
),
# 600 is documented as default here: https://docs.bazel.build/versions/master/skylark/lib/repository_ctx.html#execute
"timeout": attr.int(
default = 600,
doc = "Timeout (in seconds) on the rule's execution duration.",
),
"_py_srcs": attr.label_list(
doc = "Python sources used in the repository rule",
allow_files = True,
default = PIP_INSTALL_PY_SRCS,
),
}
pip_repository_attrs = {
"annotations": attr.string_dict(
doc = "Optional annotations to apply to packages",
),
"incompatible_generate_aliases": attr.bool(
default = False,
doc = "Allow generating aliases '@pip//' -> '@pip_//:pkg'.",
),
"requirements_darwin": attr.label(
allow_single_file = True,
doc = "Override the requirements_lock attribute when the host platform is Mac OS",
),
"requirements_linux": attr.label(
allow_single_file = True,
doc = "Override the requirements_lock attribute when the host platform is Linux",
),
"requirements_lock": attr.label(
allow_single_file = True,
doc = """
A fully resolved 'requirements.txt' pip requirement file containing the transitive set of your dependencies. If this file is passed instead
of 'requirements' no resolve will take place and pip_repository will create individual repositories for each of your dependencies so that
wheels are fetched/built only for the targets specified by 'build/run/test'.
""",
),
"requirements_windows": attr.label(
allow_single_file = True,
doc = "Override the requirements_lock attribute when the host platform is Windows",
),
"_template": attr.label(
default = ":pip_repository_requirements.bzl.tmpl",
),
}
pip_repository_attrs.update(**common_attrs)
pip_repository = repository_rule(
attrs = pip_repository_attrs,
doc = """A rule for importing `requirements.txt` dependencies into Bazel.
This rule imports a `requirements.txt` file and generates a new
`requirements.bzl` file. This is used via the `WORKSPACE` pattern:
```python
pip_repository(
name = "foo",
requirements = ":requirements.txt",
)
```
You can then reference imported dependencies from your `BUILD` file with:
```python
load("@foo//:requirements.bzl", "requirement")
py_library(
name = "bar",
...
deps = [
"//my/other:dep",
requirement("requests"),
requirement("numpy"),
],
)
```
Or alternatively:
```python
load("@foo//:requirements.bzl", "all_requirements")
py_binary(
name = "baz",
...
deps = [
":foo",
] + all_requirements,
)
```
""",
implementation = _pip_repository_impl,
environ = common_env,
)
def _whl_library_impl(rctx):
python_interpreter = _resolve_python_interpreter(rctx)
args = [
python_interpreter,
"-m",
"python.pip_install.tools.wheel_installer.wheel_installer",
"--requirement",
rctx.attr.requirement,
"--repo",
rctx.attr.repo,
"--repo-prefix",
rctx.attr.repo_prefix,
]
if rctx.attr.annotation:
args.extend([
"--annotation",
rctx.path(rctx.attr.annotation),
])
args = _parse_optional_attrs(rctx, args)
result = rctx.execute(
args,
# Manually construct the PYTHONPATH since we cannot use the toolchain here
environment = _create_repository_execution_environment(rctx),
quiet = rctx.attr.quiet,
timeout = rctx.attr.timeout,
)
if result.return_code:
fail("whl_library %s failed: %s (%s)" % (rctx.attr.name, result.stdout, result.stderr))
return
whl_library_attrs = {
"annotation": attr.label(
doc = (
"Optional json encoded file containing annotation to apply to the extracted wheel. " +
"See `package_annotation`"
),
allow_files = True,
),
"repo": attr.string(
mandatory = True,
doc = "Pointer to parent repo name. Used to make these rules rerun if the parent repo changes.",
),
"requirement": attr.string(
mandatory = True,
doc = "Python requirement string describing the package to make available",
),
}
whl_library_attrs.update(**common_attrs)
whl_library = repository_rule(
attrs = whl_library_attrs,
doc = """
Download and extracts a single wheel based into a bazel repo based on the requirement string passed in.
Instantiated from pip_repository and inherits config options from there.""",
implementation = _whl_library_impl,
environ = common_env,
)
def package_annotation(
additive_build_content = None,
copy_files = {},
copy_executables = {},
data = [],
data_exclude_glob = [],
srcs_exclude_glob = []):
"""Annotations to apply to the BUILD file content from package generated from a `pip_repository` rule.
[cf]: https://github.com/bazelbuild/bazel-skylib/blob/main/docs/copy_file_doc.md
Args:
additive_build_content (str, optional): Raw text to add to the generated `BUILD` file of a package.
copy_files (dict, optional): A mapping of `src` and `out` files for [@bazel_skylib//rules:copy_file.bzl][cf]
copy_executables (dict, optional): A mapping of `src` and `out` files for
[@bazel_skylib//rules:copy_file.bzl][cf]. Targets generated here will also be flagged as
executable.
data (list, optional): A list of labels to add as `data` dependencies to the generated `py_library` target.
data_exclude_glob (list, optional): A list of exclude glob patterns to add as `data` to the generated
`py_library` target.
srcs_exclude_glob (list, optional): A list of labels to add as `srcs` to the generated `py_library` target.
Returns:
str: A json encoded string of the provided content.
"""
return json.encode(struct(
additive_build_content = additive_build_content,
copy_files = copy_files,
copy_executables = copy_executables,
data = data,
data_exclude_glob = data_exclude_glob,
srcs_exclude_glob = srcs_exclude_glob,
))
# pip_repository implementation
def _format_list(items):
return "[{}]".format(", ".join(items))
def _format_repr_list(strings):
return _format_list(
[repr(s) for s in strings],
)
def _repr_dict(items):
return {k: repr(v) for k, v in items.items()}
def _format_dict(items):
return "{{{}}}".format(", ".join(sorted(['"{}": {}'.format(k, v) for k, v in items.items()])))
rules_python-0.22.1/python/pip_install/pip_repository_requirements.bzl.tmpl 0000664 0000000 0000000 00000002777 14540404546 0027567 0 ustar 00root root 0000000 0000000 """Starlark representation of locked requirements.
@generated by rules_python pip_parse repository rule
from %%REQUIREMENTS_LOCK%%
"""
%%IMPORTS%%
all_requirements = %%ALL_REQUIREMENTS%%
all_whl_requirements = %%ALL_WHL_REQUIREMENTS%%
_packages = %%PACKAGES%%
_config = %%CONFIG%%
_annotations = %%ANNOTATIONS%%
def _clean_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:pkg"
def whl_requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:whl"
def data_requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:data"
def dist_info_requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:dist_info"
def entry_point(pkg, script = None):
if not script:
script = pkg
return "@%%NAME%%_" + _clean_name(pkg) + "//:rules_python_wheel_entry_point_" + script
def _get_annotation(requirement):
# This expects to parse `setuptools==58.2.0 --hash=sha256:2551203ae6955b9876741a26ab3e767bb3242dafe86a32a749ea0d78b6792f11`
# down to `setuptools`.
name = requirement.split(" ")[0].split("=")[0].split("[")[0]
return _annotations.get(name)
def install_deps(**whl_library_kwargs):
whl_config = dict(_config)
whl_config.update(whl_library_kwargs)
for name, requirement in _packages:
whl_library(
name = name,
requirement = requirement,
annotation = _get_annotation(requirement),
**whl_config
)
rules_python-0.22.1/python/pip_install/pip_repository_requirements_bzlmod.bzl.tmpl 0000664 0000000 0000000 00000001664 14540404546 0031130 0 ustar 00root root 0000000 0000000 """Starlark representation of locked requirements.
@generated by rules_python pip_parse repository rule
from %%REQUIREMENTS_LOCK%%.
"""
all_requirements = %%ALL_REQUIREMENTS%%
all_whl_requirements = %%ALL_WHL_REQUIREMENTS%%
def _clean_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def requirement(name):
return "%%MACRO_TMPL%%".format(_clean_name(name), "pkg")
def whl_requirement(name):
return "%%MACRO_TMPL%%".format(_clean_name(name), "whl")
def data_requirement(name):
return "%%MACRO_TMPL%%".format(_clean_name(name), "data")
def dist_info_requirement(name):
return "%%MACRO_TMPL%%".format(_clean_name(name), "dist_info")
def entry_point(pkg, script = None):
"""entry_point returns the target of the canonical label of the package entrypoints.
"""
if not script:
script = pkg
return "@@%%NAME%%_{}//:rules_python_wheel_entry_point_{}".format(_clean_name(pkg), script)
rules_python-0.22.1/python/pip_install/private/ 0000775 0000000 0000000 00000000000 14540404546 0021646 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/pip_install/private/BUILD.bazel 0000664 0000000 0000000 00000000662 14540404546 0023530 0 ustar 00root root 0000000 0000000 load(":pip_install_utils.bzl", "srcs_module")
package(default_visibility = ["//:__subpackages__"])
exports_files([
"srcs.bzl",
])
filegroup(
name = "distribution",
srcs = glob(["*"]),
visibility = ["//python/pip_install:__subpackages__"],
)
filegroup(
name = "bzl_srcs",
srcs = glob(["*.bzl"]),
)
srcs_module(
name = "srcs_module",
srcs = "//python/pip_install:py_srcs",
dest = ":srcs.bzl",
)
rules_python-0.22.1/python/pip_install/private/pip_install_utils.bzl 0000664 0000000 0000000 00000007354 14540404546 0026126 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utilities for `rules_python` pip rules"""
_SRCS_TEMPLATE = """\
\"\"\"A generated file containing all source files used for `@rules_python//python/pip_install:pip_repository.bzl` rules
This file is auto-generated from the `@rules_python//python/pip_install/private:srcs_module.update` target. Please
`bazel run` this target to apply any updates. Note that doing so will discard any local modifications.
"\"\"
# Each source file is tracked as a target so `pip_repository` rules will know to automatically rebuild if any of the
# sources changed.
PIP_INSTALL_PY_SRCS = [
{srcs}
]
"""
def _src_label(file):
dir_path, file_name = file.short_path.rsplit("/", 1)
return "@rules_python//{}:{}".format(
dir_path,
file_name,
)
def _srcs_module_impl(ctx):
srcs = [_src_label(src) for src in ctx.files.srcs]
if not srcs:
fail("`srcs` cannot be empty")
output = ctx.actions.declare_file(ctx.label.name)
ctx.actions.write(
output = output,
content = _SRCS_TEMPLATE.format(
srcs = "\n ".join(["\"{}\",".format(src) for src in srcs]),
),
)
return DefaultInfo(
files = depset([output]),
)
_srcs_module = rule(
doc = "A rule for writing a list of sources to a templated file",
implementation = _srcs_module_impl,
attrs = {
"srcs": attr.label(
doc = "A filegroup of source files",
allow_files = True,
),
},
)
_INSTALLER_TEMPLATE = """\
#!/bin/bash
set -euo pipefail
cp -f "{path}" "${{BUILD_WORKSPACE_DIRECTORY}}/{dest}"
"""
def _srcs_updater_impl(ctx):
output = ctx.actions.declare_file(ctx.label.name + ".sh")
target_file = ctx.file.input
dest = ctx.file.dest.short_path
ctx.actions.write(
output = output,
content = _INSTALLER_TEMPLATE.format(
path = target_file.short_path,
dest = dest,
),
is_executable = True,
)
return DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles(files = [target_file]),
executable = output,
)
_srcs_updater = rule(
doc = "A rule for writing a `srcs.bzl` file back to the repository",
implementation = _srcs_updater_impl,
attrs = {
"dest": attr.label(
doc = "The target file to write the new `input` to.",
allow_single_file = ["srcs.bzl"],
mandatory = True,
),
"input": attr.label(
doc = "The file to write back to the repository",
allow_single_file = True,
mandatory = True,
),
},
executable = True,
)
def srcs_module(name, dest, **kwargs):
"""A helper rule to ensure `pip_repository` rules are always up to date
Args:
name (str): The name of the sources module
dest (str): The filename the module should be written as in the current package.
**kwargs (dict): Additional keyword arguments
"""
tags = kwargs.pop("tags", [])
_srcs_module(
name = name,
tags = tags,
**kwargs
)
_srcs_updater(
name = name + ".update",
input = name,
dest = dest,
tags = tags,
)
rules_python-0.22.1/python/pip_install/private/srcs.bzl 0000664 0000000 0000000 00000002210 14540404546 0023324 0 ustar 00root root 0000000 0000000 """A generated file containing all source files used for `@rules_python//python/pip_install:pip_repository.bzl` rules
This file is auto-generated from the `@rules_python//python/pip_install/private:srcs_module.update` target. Please
`bazel run` this target to apply any updates. Note that doing so will discard any local modifications.
"""
# Each source file is tracked as a target so `pip_repository` rules will know to automatically rebuild if any of the
# sources changed.
PIP_INSTALL_PY_SRCS = [
"@rules_python//python/pip_install/tools/dependency_resolver:__init__.py",
"@rules_python//python/pip_install/tools/dependency_resolver:dependency_resolver.py",
"@rules_python//python/pip_install/tools/lib:__init__.py",
"@rules_python//python/pip_install/tools/lib:annotation.py",
"@rules_python//python/pip_install/tools/lib:arguments.py",
"@rules_python//python/pip_install/tools/lib:bazel.py",
"@rules_python//python/pip_install/tools/wheel_installer:namespace_pkgs.py",
"@rules_python//python/pip_install/tools/wheel_installer:wheel.py",
"@rules_python//python/pip_install/tools/wheel_installer:wheel_installer.py",
]
rules_python-0.22.1/python/pip_install/private/test/ 0000775 0000000 0000000 00000000000 14540404546 0022625 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/pip_install/private/test/BUILD.bazel 0000664 0000000 0000000 00000001421 14540404546 0024501 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load(":requirements_parser_tests.bzl", parse_requirements_tests = "parse_tests")
diff_test(
name = "srcs_diff_test",
failure_message = (
"Please run 'bazel run //python/pip_install/private:srcs_module.update' " +
"to update the 'srcs.bzl' module found in the same package."
),
file1 = "//python/pip_install/private:srcs_module",
file2 = "//python/pip_install/private:srcs.bzl",
# TODO: The diff_test here fails on Windows. As does the
# install script. This should be fixed.
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
)
parse_requirements_tests(name = "test_parse_requirements")
rules_python-0.22.1/python/pip_install/private/test/requirements_parser_tests.bzl 0000664 0000000 0000000 00000037612 14540404546 0030670 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Unit tests for yaml.bzl"
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
load("//python/pip_install:requirements_parser.bzl", "parse")
def _parse_basic_test_impl(ctx):
env = unittest.begin(ctx)
# Base cases
asserts.equals(env, [], parse("").requirements)
asserts.equals(env, [], parse("\n").requirements)
# Various requirement specifiers (https://pip.pypa.io/en/stable/reference/requirement-specifiers/#requirement-specifiers)
asserts.equals(env, [("SomeProject", "SomeProject")], parse("SomeProject\n").requirements)
asserts.equals(env, [("SomeProject", "SomeProject == 1.3")], parse("SomeProject == 1.3\n").requirements)
asserts.equals(env, [("SomeProject", "SomeProject >= 1.2, < 2.0")], parse("SomeProject >= 1.2, < 2.0\n").requirements)
asserts.equals(env, [("SomeProject", "SomeProject[foo, bar]")], parse("SomeProject[foo, bar]\n").requirements)
asserts.equals(env, [("SomeProject", "SomeProject ~= 1.4.2")], parse("SomeProject ~= 1.4.2\n").requirements)
asserts.equals(env, [("SomeProject", "SomeProject == 5.4 ; python_version < '3.8'")], parse("SomeProject == 5.4 ; python_version < '3.8'\n").requirements)
asserts.equals(env, [("SomeProject", "SomeProject ; sys_platform == 'win32'")], parse("SomeProject ; sys_platform == 'win32'\n").requirements)
asserts.equals(env, [("requests", "requests [security] >= 2.8.1, == 2.8.* ; python_version < 2.7")], parse("requests [security] >= 2.8.1, == 2.8.* ; python_version < 2.7\n").requirements)
# Multiple requirements
asserts.equals(env, [("FooProject", "FooProject==1.0.0"), ("BarProject", "BarProject==2.0.0")], parse("""\
FooProject==1.0.0
BarProject==2.0.0
""").requirements)
asserts.equals(env, [("FooProject", "FooProject==1.0.0"), ("BarProject", "BarProject==2.0.0")], parse("""\
FooProject==1.0.0
BarProject==2.0.0
""").requirements)
# Comments
asserts.equals(env, [("SomeProject", "SomeProject")], parse("""\
# This is a comment
SomeProject
""").requirements)
asserts.equals(env, [("SomeProject", "SomeProject")], parse("""\
SomeProject
# This is a comment
""").requirements)
asserts.equals(env, [("SomeProject", "SomeProject == 1.3")], parse("""\
SomeProject == 1.3 # This is a comment
""").requirements)
asserts.equals(env, [("FooProject", "FooProject==1.0.0"), ("BarProject", "BarProject==2.0.0")], parse("""\
FooProject==1.0.0
# Comment
BarProject==2.0.0 #Comment
""").requirements)
asserts.equals(env, [("requests", "requests @ https://github.com/psf/requests/releases/download/v2.29.0/requests-2.29.0.tar.gz#sha1=3897c249b51a1a405d615a8c9cb92e5fdbf0dd49")], parse("""\
requests @ https://github.com/psf/requests/releases/download/v2.29.0/requests-2.29.0.tar.gz#sha1=3897c249b51a1a405d615a8c9cb92e5fdbf0dd49
""").requirements)
# Multiline
asserts.equals(env, [("certifi", "certifi==2021.10.8 --hash=sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872 --hash=sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569")], parse("""\
certifi==2021.10.8 \
--hash=sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872 \
--hash=sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569
# via requests
""").requirements)
asserts.equals(env, [("requests", "requests @ https://github.com/psf/requests/releases/download/v2.29.0/requests-2.29.0.tar.gz#sha1=3897c249b51a1a405d615a8c9cb92e5fdbf0dd49 --hash=sha256:eca58eb564b134e4ff521a02aa6f566c653835753e1fc8a50a20cb6bee4673cd")], parse("""\
requests @ https://github.com/psf/requests/releases/download/v2.29.0/requests-2.29.0.tar.gz#sha1=3897c249b51a1a405d615a8c9cb92e5fdbf0dd49 \
--hash=sha256:eca58eb564b134e4ff521a02aa6f566c653835753e1fc8a50a20cb6bee4673cd
# via requirements.txt
""").requirements)
# Options
asserts.equals(env, ["--pre"], parse("--pre\n").options)
asserts.equals(env, ["--find-links", "/my/local/archives"], parse("--find-links /my/local/archives\n").options)
asserts.equals(env, ["--pre", "--find-links", "/my/local/archives"], parse("""\
--pre
--find-links /my/local/archives
""").options)
asserts.equals(env, ["--pre", "--find-links", "/my/local/archives"], parse("""\
--pre # Comment
--find-links /my/local/archives
""").options)
asserts.equals(env, struct(requirements = [("FooProject", "FooProject==1.0.0")], options = ["--pre", "--find-links", "/my/local/archives"]), parse("""\
--pre # Comment
FooProject==1.0.0
--find-links /my/local/archives
"""))
return unittest.end(env)
def _parse_requirements_lockfile_test_impl(ctx):
env = unittest.begin(ctx)
asserts.equals(env, [
("certifi", "certifi==2021.10.8 --hash=sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872 --hash=sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"),
("chardet", "chardet==4.0.0 --hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa --hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"),
("idna", "idna==2.10 --hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 --hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"),
("pathspec", "pathspec==0.9.0 --hash=sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a --hash=sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"),
("python-dateutil", "python-dateutil==2.8.2 --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"),
("python-magic", "python-magic==0.4.24 --hash=sha256:4fec8ee805fea30c07afccd1592c0f17977089895bdfaae5fec870a84e997626 --hash=sha256:de800df9fb50f8ec5974761054a708af6e4246b03b4bdaee993f948947b0ebcf"),
("pyyaml", "pyyaml==6.0 --hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 --hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b --hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 --hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b --hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 --hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 --hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba --hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 --hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 --hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 --hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 --hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 --hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 --hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f --hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 --hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc --hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c --hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 --hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 --hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c --hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 --hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b --hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c --hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb --hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 --hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 --hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d --hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 --hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 --hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 --hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a --hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 --hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"),
("requests", "requests==2.25.1 --hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 --hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"),
("s3cmd", "s3cmd==2.1.0 --hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa --hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03"),
("six", "six==1.16.0 --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"),
("urllib3", "urllib3==1.26.7 --hash=sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece --hash=sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"),
("yamllint", "yamllint==1.26.3 --hash=sha256:3934dcde484374596d6b52d8db412929a169f6d9e52e20f9ade5bf3523d9b96e"),
("setuptools", "setuptools==59.6.0 --hash=sha256:22c7348c6d2976a52632c67f7ab0cdf40147db7789f9aed18734643fe9cf3373 --hash=sha256:4ce92f1e1f8f01233ee9952c04f6b81d1e02939d6e1b488428154974a4d0783e"),
], parse("""\
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# bazel run //:requirements.update
#
certifi==2021.10.8 \
--hash=sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872 \
--hash=sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569
# via requests
chardet==4.0.0 \
--hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \
--hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5
# via requests
idna==2.10 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
# via requests
pathspec==0.9.0 \
--hash=sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a \
--hash=sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1
# via yamllint
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via s3cmd
python-magic==0.4.24 \
--hash=sha256:4fec8ee805fea30c07afccd1592c0f17977089895bdfaae5fec870a84e997626 \
--hash=sha256:de800df9fb50f8ec5974761054a708af6e4246b03b4bdaee993f948947b0ebcf
# via s3cmd
pyyaml==6.0 \
--hash=sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293 \
--hash=sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b \
--hash=sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57 \
--hash=sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b \
--hash=sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4 \
--hash=sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07 \
--hash=sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba \
--hash=sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9 \
--hash=sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287 \
--hash=sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513 \
--hash=sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0 \
--hash=sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0 \
--hash=sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92 \
--hash=sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f \
--hash=sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2 \
--hash=sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc \
--hash=sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c \
--hash=sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86 \
--hash=sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4 \
--hash=sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c \
--hash=sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34 \
--hash=sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b \
--hash=sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c \
--hash=sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb \
--hash=sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737 \
--hash=sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3 \
--hash=sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d \
--hash=sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53 \
--hash=sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78 \
--hash=sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803 \
--hash=sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a \
--hash=sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174 \
--hash=sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5
# via yamllint
requests==2.25.1 \
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e
# via -r requirements.in
s3cmd==2.1.0 \
--hash=sha256:49cd23d516b17974b22b611a95ce4d93fe326feaa07320bd1d234fed68cbccfa \
--hash=sha256:966b0a494a916fc3b4324de38f089c86c70ee90e8e1cae6d59102103a4c0cc03
# via -r requirements.in
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via python-dateutil
urllib3==1.26.7 \
--hash=sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece \
--hash=sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844
# via requests
yamllint==1.26.3 \
--hash=sha256:3934dcde484374596d6b52d8db412929a169f6d9e52e20f9ade5bf3523d9b96e
# via -r requirements.in
# The following packages are considered to be unsafe in a requirements file:
setuptools==59.6.0 \
--hash=sha256:22c7348c6d2976a52632c67f7ab0cdf40147db7789f9aed18734643fe9cf3373 \
--hash=sha256:4ce92f1e1f8f01233ee9952c04f6b81d1e02939d6e1b488428154974a4d0783e
# via yamllint
""").requirements)
return unittest.end(env)
parse_basic_test = unittest.make(
_parse_basic_test_impl,
attrs = {},
)
parse_requirements_lockfile_test = unittest.make(
_parse_requirements_lockfile_test_impl,
attrs = {},
)
def parse_tests(name):
unittest.suite(name, parse_basic_test, parse_requirements_lockfile_test)
rules_python-0.22.1/python/pip_install/repositories.bzl 0000664 0000000 0000000 00000014264 14540404546 0023443 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""
load("@bazel_skylib//lib:versions.bzl", "versions")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//:version.bzl", "MINIMUM_BAZEL_VERSION")
_RULE_DEPS = [
(
"pypi__build",
"https://files.pythonhosted.org/packages/03/97/f58c723ff036a8d8b4d3115377c0a37ed05c1f68dd9a0d66dab5e82c5c1c/build-0.9.0-py3-none-any.whl",
"38a7a2b7a0bdc61a42a0a67509d88c71ecfc37b393baba770fae34e20929ff69",
),
(
"pypi__click",
"https://files.pythonhosted.org/packages/76/0a/b6c5f311e32aeb3b406e03c079ade51e905ea630fc19d1262a46249c1c86/click-8.0.1-py3-none-any.whl",
"fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6",
),
(
"pypi__colorama",
"https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl",
"4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6",
),
(
"pypi__installer",
"https://files.pythonhosted.org/packages/e5/ca/1172b6638d52f2d6caa2dd262ec4c811ba59eee96d54a7701930726bce18/installer-0.7.0-py3-none-any.whl",
"05d1933f0a5ba7d8d6296bb6d5018e7c94fa473ceb10cf198a92ccea19c27b53",
),
(
"pypi__packaging",
"https://files.pythonhosted.org/packages/8f/7b/42582927d281d7cb035609cd3a543ffac89b74f3f4ee8e1c50914bcb57eb/packaging-22.0-py3-none-any.whl",
"957e2148ba0e1a3b282772e791ef1d8083648bc131c8ab0c1feba110ce1146c3",
),
(
"pypi__pep517",
"https://files.pythonhosted.org/packages/ee/2f/ef63e64e9429111e73d3d6cbee80591672d16f2725e648ebc52096f3d323/pep517-0.13.0-py3-none-any.whl",
"4ba4446d80aed5b5eac6509ade100bff3e7943a8489de249654a5ae9b33ee35b",
),
(
"pypi__pip",
"https://files.pythonhosted.org/packages/09/bd/2410905c76ee14c62baf69e3f4aa780226c1bbfc9485731ad018e35b0cb5/pip-22.3.1-py3-none-any.whl",
"908c78e6bc29b676ede1c4d57981d490cb892eb45cd8c214ab6298125119e077",
),
(
"pypi__pip_tools",
"https://files.pythonhosted.org/packages/5e/e8/f6d7d1847c7351048da870417724ace5c4506e816b38db02f4d7c675c189/pip_tools-6.12.1-py3-none-any.whl",
"f0c0c0ec57b58250afce458e2e6058b1f30a4263db895b7d72fd6311bf1dc6f7",
),
(
"pypi__setuptools",
"https://files.pythonhosted.org/packages/7c/5b/3d92b9f0f7ca1645cba48c080b54fe7d8b1033a4e5720091d1631c4266db/setuptools-60.10.0-py3-none-any.whl",
"782ef48d58982ddb49920c11a0c5c9c0b02e7d7d1c2ad0aa44e1a1e133051c96",
),
(
"pypi__tomli",
"https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl",
"939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc",
),
(
"pypi__wheel",
"https://files.pythonhosted.org/packages/bd/7c/d38a0b30ce22fc26ed7dbc087c6d00851fb3395e9d0dac40bec1f905030c/wheel-0.38.4-py3-none-any.whl",
"b60533f3f5d530e971d6737ca6d58681ee434818fab630c83a734bb10c083ce8",
),
(
"pypi__importlib_metadata",
"https://files.pythonhosted.org/packages/d7/31/74dcb59a601b95fce3b0334e8fc9db758f78e43075f22aeb3677dfb19f4c/importlib_metadata-1.4.0-py2.py3-none-any.whl",
"bdd9b7c397c273bcc9a11d6629a38487cd07154fa255a467bf704cd2c258e359",
),
(
"pypi__zipp",
"https://files.pythonhosted.org/packages/f4/50/cc72c5bcd48f6e98219fc4a88a5227e9e28b81637a99c49feba1d51f4d50/zipp-1.0.0-py2.py3-none-any.whl",
"8dda78f06bd1674bd8720df8a50bb47b6e1233c503a4eed8e7810686bde37656",
),
(
"pypi__more_itertools",
"https://files.pythonhosted.org/packages/bd/3f/c4b3dbd315e248f84c388bd4a72b131a29f123ecacc37ffb2b3834546e42/more_itertools-8.13.0-py3-none-any.whl",
"c5122bffc5f104d37c1626b8615b511f3427aa5389b94d61e5ef8236bfbc3ddb",
),
]
_GENERIC_WHEEL = """\
package(default_visibility = ["//visibility:public"])
load("@rules_python//python:defs.bzl", "py_library")
py_library(
name = "lib",
srcs = glob(["**/*.py"]),
data = glob(["**/*"], exclude=[
# These entries include those put into user-installed dependencies by
# data_exclude in /python/pip_install/tools/bazel.py
# to avoid non-determinism following pip install's behavior.
"**/*.py",
"**/*.pyc",
"**/* *",
"**/*.dist-info/RECORD",
"BUILD",
"WORKSPACE",
]),
# This makes this directory a top-level in the python import
# search path for anything that depends on this.
imports = ["."],
)
"""
# Collate all the repository names so they can be easily consumed
all_requirements = [name for (name, _, _) in _RULE_DEPS]
def requirement(pkg):
return Label("@pypi__" + pkg + "//:lib")
def pip_install_dependencies():
"""
Fetch dependencies these rules depend on. Workspaces that use the pip_install rule can call this.
(However we call it from pip_install, making it optional for users to do so.)
"""
# We only support Bazel LTS and rolling releases.
# Give the user an obvious error to upgrade rather than some obscure missing symbol later.
# It's not guaranteed that users call this function, but it's used by all the pip fetch
# repository rules so it's likely that most users get the right error.
versions.check(MINIMUM_BAZEL_VERSION)
for (name, url, sha256) in _RULE_DEPS:
maybe(
http_archive,
name,
url = url,
sha256 = sha256,
type = "zip",
build_file_content = _GENERIC_WHEEL,
)
rules_python-0.22.1/python/pip_install/requirements.bzl 0000664 0000000 0000000 00000012427 14540404546 0023436 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Rules to verify and update pip-compile locked requirements.txt"""
load("//python:defs.bzl", _py_binary = "py_binary", _py_test = "py_test")
load("//python/pip_install:repositories.bzl", "requirement")
def compile_pip_requirements(
name,
extra_args = [],
extra_deps = [],
py_binary = _py_binary,
py_test = _py_test,
requirements_in = None,
requirements_txt = None,
requirements_darwin = None,
requirements_linux = None,
requirements_windows = None,
visibility = ["//visibility:private"],
tags = None,
**kwargs):
"""Generates targets for managing pip dependencies with pip-compile.
By default this rules generates a filegroup named "[name]" which can be included in the data
of some other compile_pip_requirements rule that references these requirements
(e.g. with `-r ../other/requirements.txt`).
It also generates two targets for running pip-compile:
- validate with `bazel test [name]_test`
- update with `bazel run [name].update`
Args:
name: base name for generated targets, typically "requirements".
extra_args: passed to pip-compile.
extra_deps: extra dependencies passed to pip-compile.
py_binary: the py_binary rule to be used.
py_test: the py_test rule to be used.
requirements_in: file expressing desired dependencies.
requirements_txt: result of "compiling" the requirements.in file.
requirements_linux: File of linux specific resolve output to check validate if requirement.in has changes.
requirements_darwin: File of darwin specific resolve output to check validate if requirement.in has changes.
requirements_windows: File of windows specific resolve output to check validate if requirement.in has changes.
tags: tagging attribute common to all build rules, passed to both the _test and .update rules.
visibility: passed to both the _test and .update rules.
**kwargs: other bazel attributes passed to the "_test" rule.
"""
requirements_in = name + ".in" if requirements_in == None else requirements_in
requirements_txt = name + ".txt" if requirements_txt == None else requirements_txt
# "Default" target produced by this macro
# Allow a compile_pip_requirements rule to include another one in the data
# for a requirements file that does `-r ../other/requirements.txt`
native.filegroup(
name = name,
srcs = kwargs.pop("data", []) + [requirements_txt],
visibility = visibility,
)
data = [name, requirements_in, requirements_txt] + [f for f in (requirements_linux, requirements_darwin, requirements_windows) if f != None]
# Use the Label constructor so this is expanded in the context of the file
# where it appears, which is to say, in @rules_python
pip_compile = Label("//python/pip_install/tools/dependency_resolver:dependency_resolver.py")
loc = "$(rlocationpath {})"
args = [
loc.format(requirements_in),
loc.format(requirements_txt),
# String None is a placeholder for argv ordering.
loc.format(requirements_linux) if requirements_linux else "None",
loc.format(requirements_darwin) if requirements_darwin else "None",
loc.format(requirements_windows) if requirements_windows else "None",
"//%s:%s.update" % (native.package_name(), name),
] + extra_args
deps = [
requirement("build"),
requirement("click"),
requirement("colorama"),
requirement("pep517"),
requirement("pip"),
requirement("pip_tools"),
requirement("setuptools"),
requirement("tomli"),
requirement("importlib_metadata"),
requirement("zipp"),
requirement("more_itertools"),
Label("//python/runfiles:runfiles"),
] + extra_deps
tags = tags or []
tags.append("requires-network")
tags.append("no-remote-exec")
tags.append("no-sandbox")
attrs = {
"args": args,
"data": data,
"deps": deps,
"main": pip_compile,
"srcs": [pip_compile],
"tags": tags,
"visibility": visibility,
}
# cheap way to detect the bazel version
_bazel_version_4_or_greater = "propeller_optimize" in dir(native)
# Bazel 4.0 added the "env" attribute to py_test/py_binary
if _bazel_version_4_or_greater:
attrs["env"] = kwargs.pop("env", {})
py_binary(
name = name + ".update",
**attrs
)
timeout = kwargs.pop("timeout", "short")
py_test(
name = name + "_test",
timeout = timeout,
# kwargs could contain test-specific attributes like size or timeout
**dict(attrs, **kwargs)
)
rules_python-0.22.1/python/pip_install/requirements_parser.bzl 0000664 0000000 0000000 00000011122 14540404546 0025001 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Pip requirements parser for Starlark"
_STATE = struct(
# Consume extraneous whitespace
ConsumeSpace = 0,
# Consume a comment
ConsumeComment = 1,
# Parse the name of a pip package
ParseDependency = 2,
# Parse a full requirement line
ParseRequirement = 3,
# Parse a pip option
ParseOption = 4,
)
EOF = {}
def parse(content):
"""A simplistic (and incomplete) pip requirements lockfile parser.
Parses package names and their full requirement lines, as well pip
options.
Args:
content: lockfile content as a string
Returns:
Struct with fields `requirements` and `options`.
requirements: List of requirements, where each requirement is a 2-element
tuple containing the package name and the requirement line.
E.g., [(certifi', 'certifi==2021.10.8 --hash=sha256:7888...'), ...]
options: List of pip option lines
"""
content = content.replace("\r", "")
result = struct(
requirements = [],
options = [],
)
state = _STATE.ConsumeSpace
buffer = ""
inputs = content.elems()[:]
inputs.append(EOF)
for input in inputs:
if state == _STATE.ConsumeSpace:
(state, buffer) = _handleConsumeSpace(input)
elif state == _STATE.ConsumeComment:
(state, buffer) = _handleConsumeComment(input, buffer, result)
elif state == _STATE.ParseDependency:
(state, buffer) = _handleParseDependency(input, buffer, result)
elif state == _STATE.ParseOption:
(state, buffer) = _handleParseOption(input, buffer, result)
elif state == _STATE.ParseRequirement:
(state, buffer) = _handleParseRequirement(input, buffer, result)
else:
fail("Unknown state %d" % state)
return result
def _handleConsumeSpace(input):
if input == EOF:
return (_STATE.ConsumeSpace, "")
if input.isspace():
return (_STATE.ConsumeSpace, "")
elif input == "#":
return (_STATE.ConsumeComment, "")
elif input == "-":
return (_STATE.ParseOption, input)
return (_STATE.ParseDependency, input)
def _handleConsumeComment(input, buffer, result):
if input == "\n":
if len(result.requirements) > 0 and len(result.requirements[-1]) == 1:
result.requirements[-1] = (result.requirements[-1][0], buffer.rstrip(" \n"))
return (_STATE.ConsumeSpace, "")
elif len(buffer) > 0:
result.options.append(buffer.rstrip(" \n"))
return (_STATE.ConsumeSpace, "")
return (_STATE.ConsumeSpace, "")
return (_STATE.ConsumeComment, buffer)
def _handleParseDependency(input, buffer, result):
if input == EOF:
fail("Enountered unexpected end of file while parsing requirement")
elif input.isspace() or input in [">", "<", "~", "=", ";", "["]:
result.requirements.append((buffer,))
return (_STATE.ParseRequirement, buffer + input)
return (_STATE.ParseDependency, buffer + input)
def _handleParseOption(input, buffer, result):
if input == "\n" and buffer.endswith("\\"):
return (_STATE.ParseOption, buffer[0:-1])
elif input == " ":
result.options.append(buffer.rstrip("\n"))
return (_STATE.ParseOption, "")
elif input == "\n" or input == EOF:
result.options.append(buffer.rstrip("\n"))
return (_STATE.ConsumeSpace, "")
elif input == "#" and (len(buffer) == 0 or buffer[-1].isspace()):
return (_STATE.ConsumeComment, buffer)
return (_STATE.ParseOption, buffer + input)
def _handleParseRequirement(input, buffer, result):
if input == "\n" and buffer.endswith("\\"):
return (_STATE.ParseRequirement, buffer[0:-1])
elif input == "\n" or input == EOF:
result.requirements[-1] = (result.requirements[-1][0], buffer.rstrip(" \n"))
return (_STATE.ConsumeSpace, "")
elif input == "#" and (len(buffer) == 0 or buffer[-1].isspace()):
return (_STATE.ConsumeComment, buffer)
return (_STATE.ParseRequirement, buffer + input)
rules_python-0.22.1/python/pip_install/tools/ 0000775 0000000 0000000 00000000000 14540404546 0021334 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/pip_install/tools/dependency_resolver/ 0000775 0000000 0000000 00000000000 14540404546 0025373 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/pip_install/tools/dependency_resolver/BUILD.bazel 0000664 0000000 0000000 00000000620 14540404546 0027247 0 ustar 00root root 0000000 0000000 exports_files(["dependency_resolver.py"])
filegroup(
name = "distribution",
srcs = glob(
["*"],
exclude = ["*_test.py"],
),
visibility = ["//python/pip_install:__subpackages__"],
)
filegroup(
name = "py_srcs",
srcs = glob(
include = ["**/*.py"],
exclude = ["**/*_test.py"],
),
visibility = ["//python/pip_install:__subpackages__"],
)
rules_python-0.22.1/python/pip_install/tools/dependency_resolver/__init__.py 0000664 0000000 0000000 00000001134 14540404546 0027503 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rules_python-0.22.1/python/pip_install/tools/dependency_resolver/dependency_resolver.py 0000664 0000000 0000000 00000021674 14540404546 0032016 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Set defaults for the pip-compile command to run it under Bazel"
import atexit
import os
import shutil
import sys
from pathlib import Path
import piptools.writer as piptools_writer
from piptools.scripts.compile import cli
from python.runfiles import runfiles
# Replace the os.replace function with shutil.copy to work around os.replace not being able to
# replace or move files across filesystems.
os.replace = shutil.copy
# Next, we override the annotation_style_split and annotation_style_line functions to replace the
# backslashes in the paths with forward slashes. This is so that we can have the same requirements
# file on Windows and Unix-like.
original_annotation_style_split = piptools_writer.annotation_style_split
original_annotation_style_line = piptools_writer.annotation_style_line
def annotation_style_split(required_by) -> str:
required_by = set([v.replace("\\", "/") for v in required_by])
return original_annotation_style_split(required_by)
def annotation_style_line(required_by) -> str:
required_by = set([v.replace("\\", "/") for v in required_by])
return original_annotation_style_line(required_by)
piptools_writer.annotation_style_split = annotation_style_split
piptools_writer.annotation_style_line = annotation_style_line
def _select_golden_requirements_file(
requirements_txt, requirements_linux, requirements_darwin, requirements_windows
):
"""Switch the golden requirements file, used to validate if updates are needed,
to a specified platform specific one. Fallback on the platform independent one.
"""
plat = sys.platform
if plat == "linux" and requirements_linux is not None:
return requirements_linux
elif plat == "darwin" and requirements_darwin is not None:
return requirements_darwin
elif plat == "win32" and requirements_windows is not None:
return requirements_windows
else:
return requirements_txt
def _locate(bazel_runfiles, file):
"""Look up the file via Rlocation"""
if not file:
return file
return bazel_runfiles.Rlocation(file)
if __name__ == "__main__":
if len(sys.argv) < 4:
print(
"Expected at least two arguments: requirements_in requirements_out",
file=sys.stderr,
)
sys.exit(1)
parse_str_none = lambda s: None if s == "None" else s
bazel_runfiles = runfiles.Create()
requirements_in = sys.argv.pop(1)
requirements_txt = sys.argv.pop(1)
requirements_linux = parse_str_none(sys.argv.pop(1))
requirements_darwin = parse_str_none(sys.argv.pop(1))
requirements_windows = parse_str_none(sys.argv.pop(1))
update_target_label = sys.argv.pop(1)
resolved_requirements_in = _locate(bazel_runfiles, requirements_in)
resolved_requirements_txt = _locate(bazel_runfiles, requirements_txt)
# Files in the runfiles directory has the following naming schema:
# Main repo: __main__/
# External repo: /
# We want to strip both __main__ and from the absolute prefix
# to keep the requirements lock file agnostic.
repository_prefix = requirements_txt[: requirements_txt.index("/") + 1]
absolute_path_prefix = resolved_requirements_txt[
: -(len(requirements_txt) - len(repository_prefix))
]
# As requirements_in might contain references to generated files we want to
# use the runfiles file first. Thus, we need to compute the relative path
# from the execution root.
# Note: Windows cannot reference generated files without runfiles support enabled.
requirements_in_relative = requirements_in[len(repository_prefix) :]
requirements_txt_relative = requirements_txt[len(repository_prefix) :]
# Before loading click, set the locale for its parser.
# If it leaks through to the system setting, it may fail:
# RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII
# as encoding for the environment. Consult https://click.palletsprojects.com/python3/ for
# mitigation steps.
os.environ["LC_ALL"] = "C.UTF-8"
os.environ["LANG"] = "C.UTF-8"
UPDATE = True
# Detect if we are running under `bazel test`.
if "TEST_TMPDIR" in os.environ:
UPDATE = False
# pip-compile wants the cache files to be writeable, but if we point
# to the real user cache, Bazel sandboxing makes the file read-only
# and we fail.
# In theory this makes the test more hermetic as well.
sys.argv.append("--cache-dir")
sys.argv.append(os.environ["TEST_TMPDIR"])
# Make a copy for pip-compile to read and mutate.
requirements_out = os.path.join(
os.environ["TEST_TMPDIR"], os.path.basename(requirements_txt) + ".out"
)
# Those two files won't necessarily be on the same filesystem, so we can't use os.replace
# or shutil.copyfile, as they will fail with OSError: [Errno 18] Invalid cross-device link.
shutil.copy(resolved_requirements_txt, requirements_out)
update_command = os.getenv("CUSTOM_COMPILE_COMMAND") or "bazel run %s" % (
update_target_label,
)
os.environ["CUSTOM_COMPILE_COMMAND"] = update_command
os.environ["PIP_CONFIG_FILE"] = os.getenv("PIP_CONFIG_FILE") or os.devnull
sys.argv.append("--generate-hashes")
sys.argv.append("--output-file")
sys.argv.append(requirements_txt_relative if UPDATE else requirements_out)
sys.argv.append(
requirements_in_relative
if Path(requirements_in_relative).exists()
else resolved_requirements_in
)
print(sys.argv)
if UPDATE:
print("Updating " + requirements_txt_relative)
if "BUILD_WORKSPACE_DIRECTORY" in os.environ:
workspace = os.environ["BUILD_WORKSPACE_DIRECTORY"]
requirements_txt_tree = os.path.join(workspace, requirements_txt_relative)
# In most cases, requirements_txt will be a symlink to the real file in the source tree.
# If symlinks are not enabled (e.g. on Windows), then requirements_txt will be a copy,
# and we should copy the updated requirements back to the source tree.
if not os.path.samefile(resolved_requirements_txt, requirements_txt_tree):
atexit.register(
lambda: shutil.copy(
resolved_requirements_txt, requirements_txt_tree
)
)
cli()
requirements_txt_relative_path = Path(requirements_txt_relative)
content = requirements_txt_relative_path.read_text()
content = content.replace(absolute_path_prefix, "")
requirements_txt_relative_path.write_text(content)
else:
# cli will exit(0) on success
try:
print("Checking " + requirements_txt)
cli()
print("cli() should exit", file=sys.stderr)
sys.exit(1)
except SystemExit as e:
if e.code == 2:
print(
"pip-compile exited with code 2. This means that pip-compile found "
"incompatible requirements or could not find a version that matches "
f"the install requirement in {requirements_in_relative}.",
file=sys.stderr,
)
sys.exit(1)
elif e.code == 0:
golden_filename = _select_golden_requirements_file(
requirements_txt,
requirements_linux,
requirements_darwin,
requirements_windows,
)
golden = open(_locate(bazel_runfiles, golden_filename)).readlines()
out = open(requirements_out).readlines()
out = [line.replace(absolute_path_prefix, "") for line in out]
if golden != out:
import difflib
print("".join(difflib.unified_diff(golden, out)), file=sys.stderr)
print(
"Lock file out of date. Run '"
+ update_command
+ "' to update.",
file=sys.stderr,
)
sys.exit(1)
sys.exit(0)
else:
print(
f"pip-compile unexpectedly exited with code {e.code}.",
file=sys.stderr,
)
sys.exit(1)
rules_python-0.22.1/python/pip_install/tools/lib/ 0000775 0000000 0000000 00000000000 14540404546 0022102 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/pip_install/tools/lib/BUILD.bazel 0000664 0000000 0000000 00000003551 14540404546 0023764 0 ustar 00root root 0000000 0000000 load("//python:defs.bzl", "py_library", "py_test")
load(":annotations_test_helpers.bzl", "package_annotation", "package_annotations_file")
py_library(
name = "lib",
srcs = [
"annotation.py",
"arguments.py",
"bazel.py",
],
visibility = ["//python/pip_install:__subpackages__"],
)
package_annotations_file(
name = "mock_annotations",
annotations = {
"pkg_a": package_annotation(),
"pkg_b": package_annotation(
data_exclude_glob = [
"*.foo",
"*.bar",
],
),
"pkg_c": package_annotation(
# The `join` and `strip` here accounts for potential differences
# in new lines between unix and windows hosts.
additive_build_content = "\n".join([line.strip() for line in """\
cc_library(
name = "my_target",
hdrs = glob(["**/*.h"]),
srcs = glob(["**/*.cc"]),
)
""".splitlines()]),
data = [":my_target"],
),
"pkg_d": package_annotation(
srcs_exclude_glob = ["pkg_d/tests/**"],
),
},
tags = ["manual"],
)
py_test(
name = "annotations_test",
size = "small",
srcs = ["annotations_test.py"],
data = [":mock_annotations"],
env = {"MOCK_ANNOTATIONS": "$(rootpath :mock_annotations)"},
deps = [
":lib",
"//python/runfiles",
],
)
py_test(
name = "arguments_test",
size = "small",
srcs = [
"arguments_test.py",
],
deps = [
":lib",
],
)
filegroup(
name = "distribution",
srcs = glob(
["*"],
exclude = ["*_test.py"],
),
visibility = ["//python/pip_install:__subpackages__"],
)
filegroup(
name = "py_srcs",
srcs = glob(
include = ["**/*.py"],
exclude = ["**/*_test.py"],
),
visibility = ["//python/pip_install:__subpackages__"],
)
rules_python-0.22.1/python/pip_install/tools/lib/__init__.py 0000664 0000000 0000000 00000001134 14540404546 0024212 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
rules_python-0.22.1/python/pip_install/tools/lib/annotation.py 0000664 0000000 0000000 00000007232 14540404546 0024632 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import logging
from collections import OrderedDict
from pathlib import Path
from typing import Any, Dict, List
class Annotation(OrderedDict):
"""A python representation of `@rules_python//python:pip.bzl%package_annotation`"""
def __init__(self, content: Dict[str, Any]) -> None:
missing = []
ordered_content = OrderedDict()
for field in (
"additive_build_content",
"copy_executables",
"copy_files",
"data",
"data_exclude_glob",
"srcs_exclude_glob",
):
if field not in content:
missing.append(field)
continue
ordered_content.update({field: content.pop(field)})
if missing:
raise ValueError("Data missing from initial annotation: {}".format(missing))
if content:
raise ValueError(
"Unexpected data passed to annotations: {}".format(
sorted(list(content.keys()))
)
)
return OrderedDict.__init__(self, ordered_content)
@property
def additive_build_content(self) -> str:
return self["additive_build_content"]
@property
def copy_executables(self) -> Dict[str, str]:
return self["copy_executables"]
@property
def copy_files(self) -> Dict[str, str]:
return self["copy_files"]
@property
def data(self) -> List[str]:
return self["data"]
@property
def data_exclude_glob(self) -> List[str]:
return self["data_exclude_glob"]
@property
def srcs_exclude_glob(self) -> List[str]:
return self["srcs_exclude_glob"]
class AnnotationsMap:
"""A mapping of python package names to [Annotation]"""
def __init__(self, json_file: Path):
content = json.loads(json_file.read_text())
self._annotations = {pkg: Annotation(data) for (pkg, data) in content.items()}
@property
def annotations(self) -> Dict[str, Annotation]:
return self._annotations
def collect(self, requirements: List[str]) -> Dict[str, Annotation]:
unused = self.annotations
collection = {}
for pkg in requirements:
if pkg in unused:
collection.update({pkg: unused.pop(pkg)})
if unused:
logging.warning(
"Unused annotations: {}".format(sorted(list(unused.keys())))
)
return collection
def annotation_from_str_path(path: str) -> Annotation:
"""Load an annotation from a json encoded file
Args:
path (str): The path to a json encoded file
Returns:
Annotation: The deserialized annotations
"""
json_file = Path(path)
content = json.loads(json_file.read_text())
return Annotation(content)
def annotations_map_from_str_path(path: str) -> AnnotationsMap:
"""Load an annotations map from a json encoded file
Args:
path (str): The path to a json encoded file
Returns:
AnnotationsMap: The deserialized annotations map
"""
return AnnotationsMap(Path(path))
rules_python-0.22.1/python/pip_install/tools/lib/annotations_test.py 0000664 0000000 0000000 00000007361 14540404546 0026057 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python3
# Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import textwrap
import unittest
from pathlib import Path
from python.pip_install.tools.lib.annotation import Annotation, AnnotationsMap
from python.runfiles import runfiles
class AnnotationsTestCase(unittest.TestCase):
maxDiff = None
def test_annotations_constructor(self) -> None:
annotations_env = os.environ.get("MOCK_ANNOTATIONS")
self.assertIsNotNone(annotations_env)
r = runfiles.Create()
annotations_path = Path(r.Rlocation("rules_python/{}".format(annotations_env)))
self.assertTrue(annotations_path.exists())
annotations_map = AnnotationsMap(annotations_path)
self.assertListEqual(
list(annotations_map.annotations.keys()),
["pkg_a", "pkg_b", "pkg_c", "pkg_d"],
)
collection = annotations_map.collect(["pkg_a", "pkg_b", "pkg_c", "pkg_d"])
self.assertEqual(
collection["pkg_a"],
Annotation(
{
"additive_build_content": None,
"copy_executables": {},
"copy_files": {},
"data": [],
"data_exclude_glob": [],
"srcs_exclude_glob": [],
}
),
)
self.assertEqual(
collection["pkg_b"],
Annotation(
{
"additive_build_content": None,
"copy_executables": {},
"copy_files": {},
"data": [],
"data_exclude_glob": ["*.foo", "*.bar"],
"srcs_exclude_glob": [],
}
),
)
self.assertEqual(
collection["pkg_c"],
Annotation(
{
# The `join` and `strip` here accounts for potential
# differences in new lines between unix and windows
# hosts.
"additive_build_content": "\n".join(
[
line.strip()
for line in textwrap.dedent(
"""\
cc_library(
name = "my_target",
hdrs = glob(["**/*.h"]),
srcs = glob(["**/*.cc"]),
)
"""
).splitlines()
]
),
"copy_executables": {},
"copy_files": {},
"data": [":my_target"],
"data_exclude_glob": [],
"srcs_exclude_glob": [],
}
),
)
self.assertEqual(
collection["pkg_d"],
Annotation(
{
"additive_build_content": None,
"copy_executables": {},
"copy_files": {},
"data": [],
"data_exclude_glob": [],
"srcs_exclude_glob": ["pkg_d/tests/**"],
}
),
)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/python/pip_install/tools/lib/annotations_test_helpers.bzl 0000664 0000000 0000000 00000003214 14540404546 0027731 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Helper macros and rules for testing the `annotations` module of `tools`"""
load("//python:pip.bzl", _package_annotation = "package_annotation")
package_annotation = _package_annotation
def _package_annotations_file_impl(ctx):
output = ctx.actions.declare_file(ctx.label.name + ".annotations.json")
annotations = {package: json.decode(data) for (package, data) in ctx.attr.annotations.items()}
ctx.actions.write(
output = output,
content = json.encode_indent(annotations, indent = " " * 4),
)
return DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles(files = [output]),
)
package_annotations_file = rule(
implementation = _package_annotations_file_impl,
doc = (
"Consumes `package_annotation` definitions in the same way " +
"`pip_repository` rules do to produce an annotations file."
),
attrs = {
"annotations": attr.string_dict(
doc = "See `@rules_python//python:pip.bzl%package_annotation",
mandatory = True,
),
},
)
rules_python-0.22.1/python/pip_install/tools/lib/arguments.py 0000664 0000000 0000000 00000005103 14540404546 0024460 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from argparse import ArgumentParser
def parse_common_args(parser: ArgumentParser) -> ArgumentParser:
parser.add_argument(
"--repo",
action="store",
required=True,
help="The external repo name to install dependencies. In the format '@{REPO_NAME}'",
)
parser.add_argument(
"--isolated",
action="store_true",
help="Whether or not to include the `--isolated` pip flag.",
)
parser.add_argument(
"--extra_pip_args",
action="store",
help="Extra arguments to pass down to pip.",
)
parser.add_argument(
"--pip_data_exclude",
action="store",
help="Additional data exclusion parameters to add to the pip packages BUILD file.",
)
parser.add_argument(
"--enable_implicit_namespace_pkgs",
action="store_true",
help="Disables conversion of implicit namespace packages into pkg-util style packages.",
)
parser.add_argument(
"--environment",
action="store",
help="Extra environment variables to set on the pip environment.",
)
parser.add_argument(
"--repo-prefix",
required=True,
help="Prefix to prepend to packages",
)
parser.add_argument(
"--download_only",
action="store_true",
help="Use 'pip download' instead of 'pip wheel'. Disables building wheels from source, but allows use of "
"--platform, --python-version, --implementation, and --abi in --extra_pip_args.",
)
return parser
def deserialize_structured_args(args):
"""Deserialize structured arguments passed from the starlark rules.
Args:
args: dict of parsed command line arguments
"""
structured_args = ("extra_pip_args", "pip_data_exclude", "environment")
for arg_name in structured_args:
if args.get(arg_name) is not None:
args[arg_name] = json.loads(args[arg_name])["arg"]
else:
args[arg_name] = []
return args
rules_python-0.22.1/python/pip_install/tools/lib/arguments_test.py 0000664 0000000 0000000 00000004527 14540404546 0025530 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import json
import unittest
from python.pip_install.tools.lib import arguments
class ArgumentsTestCase(unittest.TestCase):
def test_arguments(self) -> None:
parser = argparse.ArgumentParser()
parser = arguments.parse_common_args(parser)
repo_name = "foo"
repo_prefix = "pypi_"
index_url = "--index_url=pypi.org/simple"
extra_pip_args = [index_url]
args_dict = vars(
parser.parse_args(
args=[
"--repo",
repo_name,
f"--extra_pip_args={json.dumps({'arg': extra_pip_args})}",
"--repo-prefix",
repo_prefix,
]
)
)
args_dict = arguments.deserialize_structured_args(args_dict)
self.assertIn("repo", args_dict)
self.assertIn("extra_pip_args", args_dict)
self.assertEqual(args_dict["pip_data_exclude"], [])
self.assertEqual(args_dict["enable_implicit_namespace_pkgs"], False)
self.assertEqual(args_dict["repo"], repo_name)
self.assertEqual(args_dict["repo_prefix"], repo_prefix)
self.assertEqual(args_dict["extra_pip_args"], extra_pip_args)
def test_deserialize_structured_args(self) -> None:
serialized_args = {
"pip_data_exclude": json.dumps({"arg": ["**.foo"]}),
"environment": json.dumps({"arg": {"PIP_DO_SOMETHING": "True"}}),
}
args = arguments.deserialize_structured_args(serialized_args)
self.assertEqual(args["pip_data_exclude"], ["**.foo"])
self.assertEqual(args["environment"], {"PIP_DO_SOMETHING": "True"})
self.assertEqual(args["extra_pip_args"], [])
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/python/pip_install/tools/lib/bazel.py 0000664 0000000 0000000 00000004301 14540404546 0023547 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
WHEEL_FILE_LABEL = "whl"
PY_LIBRARY_LABEL = "pkg"
DATA_LABEL = "data"
DIST_INFO_LABEL = "dist_info"
WHEEL_ENTRY_POINT_PREFIX = "rules_python_wheel_entry_point"
def sanitise_name(name: str, prefix: str) -> str:
"""Sanitises the name to be compatible with Bazel labels.
There are certain requirements around Bazel labels that we need to consider. From the Bazel docs:
Package names must be composed entirely of characters drawn from the set A-Z, aβz, 0β9, '/', '-', '.', and '_',
and cannot start with a slash.
Due to restrictions on Bazel labels we also cannot allow hyphens. See
https://github.com/bazelbuild/bazel/issues/6841
Further, rules-python automatically adds the repository root to the PYTHONPATH, meaning a package that has the same
name as a module is picked up. We workaround this by prefixing with `pypi__`. Alternatively we could require
`--noexperimental_python_import_all_repositories` be set, however this breaks rules_docker.
See: https://github.com/bazelbuild/bazel/issues/2636
"""
return prefix + name.replace("-", "_").replace(".", "_").lower()
def _whl_name_to_repo_root(whl_name: str, repo_prefix: str) -> str:
return "@{}//".format(sanitise_name(whl_name, prefix=repo_prefix))
def sanitised_repo_library_label(whl_name: str, repo_prefix: str) -> str:
return '"{}:{}"'.format(
_whl_name_to_repo_root(whl_name, repo_prefix), PY_LIBRARY_LABEL
)
def sanitised_repo_file_label(whl_name: str, repo_prefix: str) -> str:
return '"{}:{}"'.format(
_whl_name_to_repo_root(whl_name, repo_prefix), WHEEL_FILE_LABEL
)
rules_python-0.22.1/python/pip_install/tools/wheel_installer/ 0000775 0000000 0000000 00000000000 14540404546 0024515 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/pip_install/tools/wheel_installer/BUILD.bazel 0000664 0000000 0000000 00000002354 14540404546 0026377 0 ustar 00root root 0000000 0000000 load("//python:defs.bzl", "py_binary", "py_library", "py_test")
load("//python/pip_install:repositories.bzl", "requirement")
py_library(
name = "lib",
srcs = [
"namespace_pkgs.py",
"wheel.py",
"wheel_installer.py",
],
deps = [
"//python/pip_install/tools/lib",
requirement("installer"),
requirement("pip"),
requirement("setuptools"),
],
)
py_binary(
name = "wheel_installer",
srcs = [
"wheel_installer.py",
],
deps = [":lib"],
)
py_test(
name = "namespace_pkgs_test",
size = "small",
srcs = [
"namespace_pkgs_test.py",
],
deps = [
":lib",
],
)
py_test(
name = "wheel_installer_test",
size = "small",
srcs = [
"wheel_installer_test.py",
],
data = ["//examples/wheel:minimal_with_py_package"],
deps = [
":lib",
],
)
filegroup(
name = "distribution",
srcs = glob(
["*"],
exclude = ["*_test.py"],
),
visibility = ["//python/pip_install:__subpackages__"],
)
filegroup(
name = "py_srcs",
srcs = glob(
include = ["**/*.py"],
exclude = ["**/*_test.py"],
),
visibility = ["//python/pip_install:__subpackages__"],
)
rules_python-0.22.1/python/pip_install/tools/wheel_installer/namespace_pkgs.py 0000664 0000000 0000000 00000011621 14540404546 0030050 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utility functions to discover python package types"""
import os
import textwrap
from pathlib import Path # supported in >= 3.4
from typing import List, Optional, Set
def implicit_namespace_packages(
directory: str, ignored_dirnames: Optional[List[str]] = None
) -> Set[Path]:
"""Discovers namespace packages implemented using the 'native namespace packages' method.
AKA 'implicit namespace packages', which has been supported since Python 3.3.
See: https://packaging.python.org/guides/packaging-namespace-packages/#native-namespace-packages
Args:
directory: The root directory to recursively find packages in.
ignored_dirnames: A list of directories to exclude from the search
Returns:
The set of directories found under root to be packages using the native namespace method.
"""
namespace_pkg_dirs: Set[Path] = set()
standard_pkg_dirs: Set[Path] = set()
directory_path = Path(directory)
ignored_dirname_paths: List[Path] = [Path(p) for p in ignored_dirnames or ()]
# Traverse bottom-up because a directory can be a namespace pkg because its child contains module files.
for dirpath, dirnames, filenames in map(
lambda t: (Path(t[0]), *t[1:]), os.walk(directory_path, topdown=False)
):
if "__init__.py" in filenames:
standard_pkg_dirs.add(dirpath)
continue
elif ignored_dirname_paths:
is_ignored_dir = dirpath in ignored_dirname_paths
child_of_ignored_dir = any(
d in dirpath.parents for d in ignored_dirname_paths
)
if is_ignored_dir or child_of_ignored_dir:
continue
dir_includes_py_modules = _includes_python_modules(filenames)
parent_of_namespace_pkg = any(
Path(dirpath, d) in namespace_pkg_dirs for d in dirnames
)
parent_of_standard_pkg = any(
Path(dirpath, d) in standard_pkg_dirs for d in dirnames
)
parent_of_pkg = parent_of_namespace_pkg or parent_of_standard_pkg
if (
(dir_includes_py_modules or parent_of_pkg)
and
# The root of the directory should never be an implicit namespace
dirpath != directory_path
):
namespace_pkg_dirs.add(dirpath)
return namespace_pkg_dirs
def add_pkgutil_style_namespace_pkg_init(dir_path: Path) -> None:
"""Adds 'pkgutil-style namespace packages' init file to the given directory
See: https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages
Args:
dir_path: The directory to create an __init__.py for.
Raises:
ValueError: If the directory already contains an __init__.py file
"""
ns_pkg_init_filepath = os.path.join(dir_path, "__init__.py")
if os.path.isfile(ns_pkg_init_filepath):
raise ValueError("%s already contains an __init__.py file." % dir_path)
with open(ns_pkg_init_filepath, "w") as ns_pkg_init_f:
# See https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages
ns_pkg_init_f.write(
textwrap.dedent(
"""\
# __path__ manipulation added by bazelbuild/rules_python to support namespace pkgs.
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
"""
)
)
def _includes_python_modules(files: List[str]) -> bool:
"""
In order to only transform directories that Python actually considers namespace pkgs
we need to detect if a directory includes Python modules.
Which files are loadable as modules is extension based, and the particular set of extensions
varies by platform.
See:
1. https://github.com/python/cpython/blob/7d9d25dbedfffce61fc76bc7ccbfa9ae901bf56f/Lib/importlib/machinery.py#L19
2. PEP 420 -- Implicit Namespace Packages, Specification - https://www.python.org/dev/peps/pep-0420/#specification
3. dynload_shlib.c and dynload_win.c in python/cpython.
"""
module_suffixes = {
".py", # Source modules
".pyc", # Compiled bytecode modules
".so", # Unix extension modules
".pyd", # https://docs.python.org/3/faq/windows.html#is-a-pyd-file-the-same-as-a-dll
}
return any(Path(f).suffix in module_suffixes for f in files)
rules_python-0.22.1/python/pip_install/tools/wheel_installer/namespace_pkgs_test.py 0000664 0000000 0000000 00000015103 14540404546 0031106 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pathlib
import shutil
import tempfile
import unittest
from typing import Optional, Set
from python.pip_install.tools.wheel_installer import namespace_pkgs
class TempDir:
def __init__(self) -> None:
self.dir = tempfile.mkdtemp()
def root(self) -> str:
return self.dir
def add_dir(self, rel_path: str) -> None:
d = pathlib.Path(self.dir, rel_path)
d.mkdir(parents=True)
def add_file(self, rel_path: str, contents: Optional[str] = None) -> None:
f = pathlib.Path(self.dir, rel_path)
f.parent.mkdir(parents=True, exist_ok=True)
if contents:
with open(str(f), "w") as writeable_f:
writeable_f.write(contents)
else:
f.touch()
def remove(self) -> None:
shutil.rmtree(self.dir)
class TestImplicitNamespacePackages(unittest.TestCase):
def assertPathsEqual(self, actual: Set[pathlib.Path], expected: Set[str]) -> None:
self.assertEqual(actual, {pathlib.Path(p) for p in expected})
def test_in_current_directory(self) -> None:
directory = TempDir()
directory.add_file("foo/bar/biz.py")
directory.add_file("foo/bee/boo.py")
directory.add_file("foo/buu/__init__.py")
directory.add_file("foo/buu/bii.py")
cwd = os.getcwd()
os.chdir(directory.root())
expected = {
"foo",
"foo/bar",
"foo/bee",
}
try:
actual = namespace_pkgs.implicit_namespace_packages(".")
self.assertPathsEqual(actual, expected)
finally:
os.chdir(cwd)
directory.remove()
def test_finds_correct_namespace_packages(self) -> None:
directory = TempDir()
directory.add_file("foo/bar/biz.py")
directory.add_file("foo/bee/boo.py")
directory.add_file("foo/buu/__init__.py")
directory.add_file("foo/buu/bii.py")
expected = {
directory.root() + "/foo",
directory.root() + "/foo/bar",
directory.root() + "/foo/bee",
}
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertPathsEqual(actual, expected)
def test_ignores_empty_directories(self) -> None:
directory = TempDir()
directory.add_file("foo/bar/biz.py")
directory.add_dir("foo/cat")
expected = {
directory.root() + "/foo",
directory.root() + "/foo/bar",
}
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertPathsEqual(actual, expected)
def test_empty_case(self) -> None:
directory = TempDir()
directory.add_file("foo/__init__.py")
directory.add_file("foo/bar/__init__.py")
directory.add_file("foo/bar/biz.py")
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertEqual(actual, set())
def test_ignores_non_module_files_in_directories(self) -> None:
directory = TempDir()
directory.add_file("foo/__init__.pyi")
directory.add_file("foo/py.typed")
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertEqual(actual, set())
def test_parent_child_relationship_of_namespace_pkgs(self):
directory = TempDir()
directory.add_file("foo/bar/biff/my_module.py")
directory.add_file("foo/bar/biff/another_module.py")
expected = {
directory.root() + "/foo",
directory.root() + "/foo/bar",
directory.root() + "/foo/bar/biff",
}
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertPathsEqual(actual, expected)
def test_parent_child_relationship_of_namespace_and_standard_pkgs(self):
directory = TempDir()
directory.add_file("foo/bar/biff/__init__.py")
directory.add_file("foo/bar/biff/another_module.py")
expected = {
directory.root() + "/foo",
directory.root() + "/foo/bar",
}
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertPathsEqual(actual, expected)
def test_parent_child_relationship_of_namespace_and_nested_standard_pkgs(self):
directory = TempDir()
directory.add_file("foo/bar/__init__.py")
directory.add_file("foo/bar/biff/another_module.py")
directory.add_file("foo/bar/biff/__init__.py")
directory.add_file("foo/bar/boof/big_module.py")
directory.add_file("foo/bar/boof/__init__.py")
directory.add_file("fim/in_a_ns_pkg.py")
expected = {
directory.root() + "/foo",
directory.root() + "/fim",
}
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertPathsEqual(actual, expected)
def test_recognized_all_nonstandard_module_types(self):
directory = TempDir()
directory.add_file("ayy/my_module.pyc")
directory.add_file("bee/ccc/dee/eee.so")
directory.add_file("eff/jee/aych.pyd")
expected = {
directory.root() + "/ayy",
directory.root() + "/bee",
directory.root() + "/bee/ccc",
directory.root() + "/bee/ccc/dee",
directory.root() + "/eff",
directory.root() + "/eff/jee",
}
actual = namespace_pkgs.implicit_namespace_packages(directory.root())
self.assertPathsEqual(actual, expected)
def test_skips_ignored_directories(self):
directory = TempDir()
directory.add_file("foo/boo/my_module.py")
directory.add_file("foo/bar/another_module.py")
expected = {
directory.root() + "/foo",
directory.root() + "/foo/bar",
}
actual = namespace_pkgs.implicit_namespace_packages(
directory.root(),
ignored_dirnames=[directory.root() + "/foo/boo"],
)
self.assertPathsEqual(actual, expected)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/python/pip_install/tools/wheel_installer/wheel.py 0000664 0000000 0000000 00000010053 14540404546 0026172 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utility class to inspect an extracted wheel directory"""
import email
from typing import Dict, Optional, Set, Tuple
import installer
import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
class Wheel:
"""Representation of the compressed .whl file"""
def __init__(self, path: str):
self._path = path
@property
def path(self) -> str:
return self._path
@property
def name(self) -> str:
# TODO Also available as installer.sources.WheelSource.distribution
name = str(self.metadata["Name"])
return canonicalize_name(name)
@property
def metadata(self) -> email.message.Message:
with installer.sources.WheelFile.open(self.path) as wheel_source:
metadata_contents = wheel_source.read_dist_info("METADATA")
metadata = installer.utils.parse_metadata_file(metadata_contents)
return metadata
@property
def version(self) -> str:
# TODO Also available as installer.sources.WheelSource.version
return str(self.metadata["Version"])
def entry_points(self) -> Dict[str, Tuple[str, str]]:
"""Returns the entrypoints defined in the current wheel
See https://packaging.python.org/specifications/entry-points/ for more info
Returns:
Dict[str, Tuple[str, str]]: A mapping of the entry point's name to it's module and attribute
"""
with installer.sources.WheelFile.open(self.path) as wheel_source:
if "entry_points.txt" not in wheel_source.dist_info_filenames:
return dict()
entry_points_mapping = dict()
entry_points_contents = wheel_source.read_dist_info("entry_points.txt")
entry_points = installer.utils.parse_entrypoints(entry_points_contents)
for script, module, attribute, script_section in entry_points:
if script_section == "console":
entry_points_mapping[script] = (module, attribute)
return entry_points_mapping
def dependencies(self, extras_requested: Optional[Set[str]] = None) -> Set[str]:
dependency_set = set()
for wheel_req in self.metadata.get_all("Requires-Dist", []):
req = pkg_resources.Requirement(wheel_req) # type: ignore
if req.marker is None or any(
req.marker.evaluate({"extra": extra})
for extra in extras_requested or [""]
):
dependency_set.add(req.name) # type: ignore
return dependency_set
def unzip(self, directory: str) -> None:
installation_schemes = {
"purelib": "/site-packages",
"platlib": "/site-packages",
"headers": "/include",
"scripts": "/bin",
"data": "/data",
}
destination = installer.destinations.SchemeDictionaryDestination(
installation_schemes,
# TODO Should entry_point scripts also be handled by installer rather than custom code?
interpreter="/dev/null",
script_kind="posix",
destdir=directory,
bytecode_optimization_levels=[],
)
with installer.sources.WheelFile.open(self.path) as wheel_source:
installer.install(
source=wheel_source,
destination=destination,
additional_metadata={
"INSTALLER": b"https://github.com/bazelbuild/rules_python",
},
)
rules_python-0.22.1/python/pip_install/tools/wheel_installer/wheel_installer.py 0000664 0000000 0000000 00000040525 14540404546 0030256 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import errno
import glob
import json
import os
import re
import shutil
import subprocess
import sys
import textwrap
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Dict, Iterable, List, Optional, Set, Tuple
from pip._vendor.packaging.utils import canonicalize_name
from python.pip_install.tools.lib import annotation, arguments, bazel
from python.pip_install.tools.wheel_installer import namespace_pkgs, wheel
def _configure_reproducible_wheels() -> None:
"""Modifies the environment to make wheel building reproducible.
Wheels created from sdists are not reproducible by default. We can however workaround this by
patching in some configuration with environment variables.
"""
# wheel, by default, enables debug symbols in GCC. This incidentally captures the build path in the .so file
# We can override this behavior by disabling debug symbols entirely.
# https://github.com/pypa/pip/issues/6505
if "CFLAGS" in os.environ:
os.environ["CFLAGS"] += " -g0"
else:
os.environ["CFLAGS"] = "-g0"
# set SOURCE_DATE_EPOCH to 1980 so that we can use python wheels
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md#python-setuppy-bdist_wheel-cannot-create-whl
if "SOURCE_DATE_EPOCH" not in os.environ:
os.environ["SOURCE_DATE_EPOCH"] = "315532800"
# Python wheel metadata files can be unstable.
# See https://bitbucket.org/pypa/wheel/pull-requests/74/make-the-output-of-metadata-files/diff
if "PYTHONHASHSEED" not in os.environ:
os.environ["PYTHONHASHSEED"] = "0"
def _parse_requirement_for_extra(
requirement: str,
) -> Tuple[Optional[str], Optional[Set[str]]]:
"""Given a requirement string, returns the requirement name and set of extras, if extras specified.
Else, returns (None, None)
"""
# https://www.python.org/dev/peps/pep-0508/#grammar
extras_pattern = re.compile(
r"^\s*([0-9A-Za-z][0-9A-Za-z_.\-]*)\s*\[\s*([0-9A-Za-z][0-9A-Za-z_.\-]*(?:\s*,\s*[0-9A-Za-z][0-9A-Za-z_.\-]*)*)\s*\]"
)
matches = extras_pattern.match(requirement)
if matches:
return (
canonicalize_name(matches.group(1)),
{extra.strip() for extra in matches.group(2).split(",")},
)
return None, None
def _setup_namespace_pkg_compatibility(wheel_dir: str) -> None:
"""Converts native namespace packages to pkgutil-style packages
Namespace packages can be created in one of three ways. They are detailed here:
https://packaging.python.org/guides/packaging-namespace-packages/#creating-a-namespace-package
'pkgutil-style namespace packages' (2) and 'pkg_resources-style namespace packages' (3) works in Bazel, but
'native namespace packages' (1) do not.
We ensure compatibility with Bazel of method 1 by converting them into method 2.
Args:
wheel_dir: the directory of the wheel to convert
"""
namespace_pkg_dirs = namespace_pkgs.implicit_namespace_packages(
wheel_dir,
ignored_dirnames=["%s/bin" % wheel_dir],
)
for ns_pkg_dir in namespace_pkg_dirs:
namespace_pkgs.add_pkgutil_style_namespace_pkg_init(ns_pkg_dir)
def _generate_entry_point_contents(
module: str, attribute: str, shebang: str = "#!/usr/bin/env python3"
) -> str:
"""Generate the contents of an entry point script.
Args:
module (str): The name of the module to use.
attribute (str): The name of the attribute to call.
shebang (str, optional): The shebang to use for the entry point python
file.
Returns:
str: A string of python code.
"""
return textwrap.dedent(
"""\
{shebang}
import sys
from {module} import {attribute}
if __name__ == "__main__":
sys.exit({attribute}())
""".format(
shebang=shebang, module=module, attribute=attribute
)
)
def _generate_entry_point_rule(name: str, script: str, pkg: str) -> str:
"""Generate a Bazel `py_binary` rule for an entry point script.
Note that the script is used to determine the name of the target. The name of
entry point targets should be uniuqe to avoid conflicts with existing sources or
directories within a wheel.
Args:
name (str): The name of the generated py_binary.
script (str): The path to the entry point's python file.
pkg (str): The package owning the entry point. This is expected to
match up with the `py_library` defined for each repository.
Returns:
str: A `py_binary` instantiation.
"""
return textwrap.dedent(
"""\
py_binary(
name = "{name}",
srcs = ["{src}"],
# This makes this directory a top-level in the python import
# search path for anything that depends on this.
imports = ["."],
deps = ["{pkg}"],
)
""".format(
name=name, src=str(script).replace("\\", "/"), pkg=pkg
)
)
def _generate_copy_commands(src, dest, is_executable=False) -> str:
"""Generate a [@bazel_skylib//rules:copy_file.bzl%copy_file][cf] target
[cf]: https://github.com/bazelbuild/bazel-skylib/blob/1.1.1/docs/copy_file_doc.md
Args:
src (str): The label for the `src` attribute of [copy_file][cf]
dest (str): The label for the `out` attribute of [copy_file][cf]
is_executable (bool, optional): Whether or not the file being copied is executable.
sets `is_executable` for [copy_file][cf]
Returns:
str: A `copy_file` instantiation.
"""
return textwrap.dedent(
"""\
copy_file(
name = "{dest}.copy",
src = "{src}",
out = "{dest}",
is_executable = {is_executable},
)
""".format(
src=src,
dest=dest,
is_executable=is_executable,
)
)
def _generate_build_file_contents(
name: str,
dependencies: List[str],
whl_file_deps: List[str],
data_exclude: List[str],
tags: List[str],
srcs_exclude: List[str] = [],
data: List[str] = [],
additional_content: List[str] = [],
) -> str:
"""Generate a BUILD file for an unzipped Wheel
Args:
name: the target name of the py_library
dependencies: a list of Bazel labels pointing to dependencies of the library
whl_file_deps: a list of Bazel labels pointing to wheel file dependencies of this wheel.
data_exclude: more patterns to exclude from the data attribute of generated py_library rules.
tags: list of tags to apply to generated py_library rules.
additional_content: A list of additional content to append to the BUILD file.
Returns:
A complete BUILD file as a string
We allow for empty Python sources as for Wheels containing only compiled C code
there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`).
"""
data_exclude = list(
set(
[
"**/* *",
"**/*.py",
"**/*.pyc",
# RECORD is known to contain sha256 checksums of files which might include the checksums
# of generated files produced when wheels are installed. The file is ignored to avoid
# Bazel caching issues.
"**/*.dist-info/RECORD",
]
+ data_exclude
)
)
return "\n".join(
[
textwrap.dedent(
"""\
load("@rules_python//python:defs.bzl", "py_library", "py_binary")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
package(default_visibility = ["//visibility:public"])
filegroup(
name = "{dist_info_label}",
srcs = glob(["site-packages/*.dist-info/**"], allow_empty = True),
)
filegroup(
name = "{data_label}",
srcs = glob(["data/**"], allow_empty = True),
)
filegroup(
name = "{whl_file_label}",
srcs = glob(["*.whl"], allow_empty = True),
data = [{whl_file_deps}],
)
py_library(
name = "{name}",
srcs = glob(["site-packages/**/*.py"], exclude={srcs_exclude}, allow_empty = True),
data = {data} + glob(["site-packages/**/*"], exclude={data_exclude}),
# This makes this directory a top-level in the python import
# search path for anything that depends on this.
imports = ["site-packages"],
deps = [{dependencies}],
tags = [{tags}],
)
""".format(
name=name,
dependencies=",".join(sorted(dependencies)),
data_exclude=json.dumps(sorted(data_exclude)),
whl_file_label=bazel.WHEEL_FILE_LABEL,
whl_file_deps=",".join(sorted(whl_file_deps)),
tags=",".join(sorted(['"%s"' % t for t in tags])),
data_label=bazel.DATA_LABEL,
dist_info_label=bazel.DIST_INFO_LABEL,
entry_point_prefix=bazel.WHEEL_ENTRY_POINT_PREFIX,
srcs_exclude=json.dumps(sorted(srcs_exclude)),
data=json.dumps(sorted(data)),
)
)
]
+ additional_content
)
def _extract_wheel(
wheel_file: str,
extras: Dict[str, Set[str]],
pip_data_exclude: List[str],
enable_implicit_namespace_pkgs: bool,
repo_prefix: str,
installation_dir: Path = Path("."),
annotation: Optional[annotation.Annotation] = None,
) -> None:
"""Extracts wheel into given directory and creates py_library and filegroup targets.
Args:
wheel_file: the filepath of the .whl
installation_dir: the destination directory for installation of the wheel.
extras: a list of extras to add as dependencies for the installed wheel
pip_data_exclude: list of file patterns to exclude from the generated data section of the py_library
enable_implicit_namespace_pkgs: if true, disables conversion of implicit namespace packages and will unzip as-is
annotation: An optional set of annotations to apply to the BUILD contents of the wheel.
"""
whl = wheel.Wheel(wheel_file)
whl.unzip(installation_dir)
if not enable_implicit_namespace_pkgs:
_setup_namespace_pkg_compatibility(installation_dir)
extras_requested = extras[whl.name] if whl.name in extras else set()
# Packages may create dependency cycles when specifying optional-dependencies / 'extras'.
# Example: github.com/google/etils/blob/a0b71032095db14acf6b33516bca6d885fe09e35/pyproject.toml#L32.
self_edge_dep = set([whl.name])
whl_deps = sorted(whl.dependencies(extras_requested) - self_edge_dep)
sanitised_dependencies = [
bazel.sanitised_repo_library_label(d, repo_prefix=repo_prefix) for d in whl_deps
]
sanitised_wheel_file_dependencies = [
bazel.sanitised_repo_file_label(d, repo_prefix=repo_prefix) for d in whl_deps
]
entry_points = []
for name, (module, attribute) in sorted(whl.entry_points().items()):
# There is an extreme edge-case with entry_points that end with `.py`
# See: https://github.com/bazelbuild/bazel/blob/09c621e4cf5b968f4c6cdf905ab142d5961f9ddc/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java#L174
entry_point_without_py = f"{name[:-3]}_py" if name.endswith(".py") else name
entry_point_target_name = (
f"{bazel.WHEEL_ENTRY_POINT_PREFIX}_{entry_point_without_py}"
)
entry_point_script_name = f"{entry_point_target_name}.py"
(installation_dir / entry_point_script_name).write_text(
_generate_entry_point_contents(module, attribute)
)
entry_points.append(
_generate_entry_point_rule(
entry_point_target_name,
entry_point_script_name,
bazel.PY_LIBRARY_LABEL,
)
)
with open(os.path.join(installation_dir, "BUILD.bazel"), "w") as build_file:
additional_content = entry_points
data = []
data_exclude = pip_data_exclude
srcs_exclude = []
if annotation:
for src, dest in annotation.copy_files.items():
data.append(dest)
additional_content.append(_generate_copy_commands(src, dest))
for src, dest in annotation.copy_executables.items():
data.append(dest)
additional_content.append(
_generate_copy_commands(src, dest, is_executable=True)
)
data.extend(annotation.data)
data_exclude.extend(annotation.data_exclude_glob)
srcs_exclude.extend(annotation.srcs_exclude_glob)
if annotation.additive_build_content:
additional_content.append(annotation.additive_build_content)
contents = _generate_build_file_contents(
name=bazel.PY_LIBRARY_LABEL,
dependencies=sanitised_dependencies,
whl_file_deps=sanitised_wheel_file_dependencies,
data_exclude=data_exclude,
data=data,
srcs_exclude=srcs_exclude,
tags=["pypi_name=" + whl.name, "pypi_version=" + whl.version],
additional_content=additional_content,
)
build_file.write(contents)
def main() -> None:
parser = argparse.ArgumentParser(
description="Build and/or fetch a single wheel based on the requirement passed in"
)
parser.add_argument(
"--requirement",
action="store",
required=True,
help="A single PEP508 requirement specifier string.",
)
parser.add_argument(
"--annotation",
type=annotation.annotation_from_str_path,
help="A json encoded file containing annotations for rendered packages.",
)
arguments.parse_common_args(parser)
args = parser.parse_args()
deserialized_args = dict(vars(args))
arguments.deserialize_structured_args(deserialized_args)
_configure_reproducible_wheels()
pip_args = (
[sys.executable, "-m", "pip"]
+ (["--isolated"] if args.isolated else [])
+ ["download" if args.download_only else "wheel", "--no-deps"]
+ deserialized_args["extra_pip_args"]
)
requirement_file = NamedTemporaryFile(mode="wb", delete=False)
try:
requirement_file.write(args.requirement.encode("utf-8"))
requirement_file.flush()
# Close the file so pip is allowed to read it when running on Windows.
# For more information, see: https://bugs.python.org/issue14243
requirement_file.close()
# Requirement specific args like --hash can only be passed in a requirements file,
# so write our single requirement into a temp file in case it has any of those flags.
pip_args.extend(["-r", requirement_file.name])
env = os.environ.copy()
env.update(deserialized_args["environment"])
# Assumes any errors are logged by pip so do nothing. This command will fail if pip fails
subprocess.run(pip_args, check=True, env=env)
finally:
try:
os.unlink(requirement_file.name)
except OSError as e:
if e.errno != errno.ENOENT:
raise
name, extras_for_pkg = _parse_requirement_for_extra(args.requirement)
extras = {name: extras_for_pkg} if extras_for_pkg and name else dict()
whl = next(iter(glob.glob("*.whl")))
_extract_wheel(
wheel_file=whl,
extras=extras,
pip_data_exclude=deserialized_args["pip_data_exclude"],
enable_implicit_namespace_pkgs=args.enable_implicit_namespace_pkgs,
repo_prefix=args.repo_prefix,
annotation=args.annotation,
)
if __name__ == "__main__":
main()
rules_python-0.22.1/python/pip_install/tools/wheel_installer/wheel_installer_test.py 0000664 0000000 0000000 00000007225 14540404546 0031315 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import shutil
import tempfile
import unittest
from pathlib import Path
from python.pip_install.tools.wheel_installer import wheel_installer
class TestRequirementExtrasParsing(unittest.TestCase):
def test_parses_requirement_for_extra(self) -> None:
cases = [
("name[foo]", ("name", frozenset(["foo"]))),
("name[ Foo123 ]", ("name", frozenset(["Foo123"]))),
(" name1[ foo ] ", ("name1", frozenset(["foo"]))),
("Name[foo]", ("name", frozenset(["foo"]))),
("name_foo[bar]", ("name-foo", frozenset(["bar"]))),
(
"name [fred,bar] @ http://foo.com ; python_version=='2.7'",
("name", frozenset(["fred", "bar"])),
),
(
"name[quux, strange];python_version<'2.7' and platform_version=='2'",
("name", frozenset(["quux", "strange"])),
),
(
"name; (os_name=='a' or os_name=='b') and os_name=='c'",
(None, None),
),
(
"name@http://foo.com",
(None, None),
),
]
for case, expected in cases:
with self.subTest():
self.assertTupleEqual(
wheel_installer._parse_requirement_for_extra(case), expected
)
class BazelTestCase(unittest.TestCase):
def test_generate_entry_point_contents(self):
got = wheel_installer._generate_entry_point_contents("sphinx.cmd.build", "main")
want = """#!/usr/bin/env python3
import sys
from sphinx.cmd.build import main
if __name__ == "__main__":
sys.exit(main())
"""
self.assertEqual(got, want)
def test_generate_entry_point_contents_with_shebang(self):
got = wheel_installer._generate_entry_point_contents(
"sphinx.cmd.build", "main", shebang="#!/usr/bin/python"
)
want = """#!/usr/bin/python
import sys
from sphinx.cmd.build import main
if __name__ == "__main__":
sys.exit(main())
"""
self.assertEqual(got, want)
class TestWhlFilegroup(unittest.TestCase):
def setUp(self) -> None:
self.wheel_name = "example_minimal_package-0.0.1-py3-none-any.whl"
self.wheel_dir = tempfile.mkdtemp()
self.wheel_path = os.path.join(self.wheel_dir, self.wheel_name)
shutil.copy(os.path.join("examples", "wheel", self.wheel_name), self.wheel_dir)
def tearDown(self):
shutil.rmtree(self.wheel_dir)
def test_wheel_exists(self) -> None:
wheel_installer._extract_wheel(
self.wheel_path,
installation_dir=Path(self.wheel_dir),
extras={},
pip_data_exclude=[],
enable_implicit_namespace_pkgs=False,
repo_prefix="prefix_",
)
self.assertIn(self.wheel_name, os.listdir(self.wheel_dir))
with open("{}/BUILD.bazel".format(self.wheel_dir)) as build_file:
build_file_content = build_file.read()
self.assertIn("filegroup", build_file_content)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/python/private/ 0000775 0000000 0000000 00000000000 14540404546 0017330 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/private/BUILD.bazel 0000664 0000000 0000000 00000004525 14540404546 0021214 0 ustar 00root root 0000000 0000000 # Copyright 2021 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python:versions.bzl", "print_toolchains_checksums")
load(":stamp.bzl", "stamp_build_setting")
licenses(["notice"])
filegroup(
name = "distribution",
srcs = glob(["**"]) + ["//python/private/proto:distribution"],
visibility = ["//python:__pkg__"],
)
# Filegroup of bzl files that can be used by downstream rules for documentation generation
filegroup(
name = "bzl",
srcs = glob(["**/*.bzl"]),
visibility = ["//python:__pkg__"],
)
bzl_library(
name = "reexports_bzl",
srcs = ["reexports.bzl"],
visibility = [
"//docs:__pkg__",
"//python:__pkg__",
],
deps = [":bazel_tools_bzl"],
)
bzl_library(
name = "util_bzl",
srcs = ["util.bzl"],
visibility = [
"//docs:__subpackages__",
"//python:__subpackages__",
],
deps = ["@bazel_skylib//lib:types"],
)
# @bazel_tools can't define bzl_library itself, so we just put a wrapper around it.
bzl_library(
name = "bazel_tools_bzl",
srcs = [
"@bazel_tools//tools/python:srcs_version.bzl",
"@bazel_tools//tools/python:toolchain.bzl",
"@bazel_tools//tools/python:utils.bzl",
],
visibility = ["//python:__pkg__"],
)
# Needed to define bzl_library targets for docgen. (We don't define the
# bzl_library target here because it'd give our users a transitive dependency
# on Skylib.)
exports_files(
[
"coverage.patch",
"py_package.bzl",
"py_wheel.bzl",
"reexports.bzl",
"stamp.bzl",
"util.bzl",
],
visibility = ["//docs:__pkg__"],
)
# Used to determine the use of `--stamp` in Starlark rules
stamp_build_setting(name = "stamp")
print_toolchains_checksums(name = "print_toolchains_checksums")
rules_python-0.22.1/python/private/coverage.patch 0000664 0000000 0000000 00000001043 14540404546 0022142 0 ustar 00root root 0000000 0000000 # Because of how coverage is run, the current directory is the first in
# sys.path. This is a problem for the tests, because they may import a module of
# the same name as a module in the current directory.
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index dbf66e0a..780505ac 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -937,6 +937,7 @@ def main(argv=None):
This is installed as the script entry point.
"""
+ sys.path.append(sys.path.pop(0))
if argv is None:
argv = sys.argv[1:]
try:
rules_python-0.22.1/python/private/coverage_deps.bzl 0000664 0000000 0000000 00000021512 14540404546 0022650 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Dependencies for coverage.py used by the hermetic toolchain.
"""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load(
"//python:versions.bzl",
"MINOR_MAPPING",
"PLATFORMS",
)
# Update with './tools/update_coverage_deps.py '
#START: managed by update_coverage_deps.py script
_coverage_deps = {
"cp310": {
"aarch64-apple-darwin": (
"https://files.pythonhosted.org/packages/89/a2/cbf599e50bb4be416e0408c4cf523c354c51d7da39935461a9687e039481/coverage-6.5.0-cp310-cp310-macosx_11_0_arm64.whl",
"784f53ebc9f3fd0e2a3f6a78b2be1bd1f5575d7863e10c6e12504f240fd06660",
),
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/15/b0/3639d84ee8a900da0cf6450ab46e22517e4688b6cec0ba8ab6f8166103a2/coverage-6.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"b4a5be1748d538a710f87542f22c2cad22f80545a847ad91ce45e77417293eb4",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/c4/8d/5ec7d08f4601d2d792563fe31db5e9322c306848fec1e65ec8885927f739/coverage-6.5.0-cp310-cp310-macosx_10_9_x86_64.whl",
"ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/3c/7d/d5211ea782b193ab8064b06dc0cc042cf1a4ca9c93a530071459172c550f/coverage-6.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"af4fffaffc4067232253715065e30c5a7ec6faac36f8fc8d6f64263b15f74db0",
),
},
"cp311": {
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/36/f3/5cbd79cf4cd059c80b59104aca33b8d05af4ad5bf5b1547645ecee716378/coverage-6.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"c4ed2820d919351f4167e52425e096af41bfabacb1857186c1ea32ff9983ed75",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/50/cf/455930004231fa87efe8be06d13512f34e070ddfee8b8bf5a050cdc47ab3/coverage-6.5.0-cp311-cp311-macosx_10_9_x86_64.whl",
"4a5375e28c5191ac38cca59b38edd33ef4cc914732c916f2929029b4bfb50795",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/6a/63/8e82513b7e4a1b8d887b4e85c1c2b6c9b754a581b187c0b084f3330ac479/coverage-6.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"a8fb6cf131ac4070c9c5a3e21de0f7dc5a0fbe8bc77c9456ced896c12fcdad91",
),
},
"cp38": {
"aarch64-apple-darwin": (
"https://files.pythonhosted.org/packages/07/82/79fa21ceca9a9b091eb3c67e27eb648dade27b2c9e1eb23af47232a2a365/coverage-6.5.0-cp38-cp38-macosx_11_0_arm64.whl",
"2198ea6fc548de52adc826f62cb18554caedfb1d26548c1b7c88d8f7faa8f6ba",
),
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/40/3b/cd68cb278c4966df00158811ec1e357b9a7d132790c240fc65da57e10013/coverage-6.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"6c4459b3de97b75e3bd6b7d4b7f0db13f17f504f3d13e2a7c623786289dd670e",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/05/63/a789b462075395d34f8152229dccf92b25ca73eac05b3f6cd75fa5017095/coverage-6.5.0-cp38-cp38-macosx_10_9_x86_64.whl",
"d900bb429fdfd7f511f868cedd03a6bbb142f3f9118c09b99ef8dc9bf9643c3c",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/bd/a0/e263b115808226fdb2658f1887808c06ac3f1b579ef5dda02309e0d54459/coverage-6.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"6b07130585d54fe8dff3d97b93b0e20290de974dc8177c320aeaf23459219c0b",
),
},
"cp39": {
"aarch64-apple-darwin": (
"https://files.pythonhosted.org/packages/63/e9/f23e8664ec4032d7802a1cf920853196bcbdce7b56408e3efe1b2da08f3c/coverage-6.5.0-cp39-cp39-macosx_11_0_arm64.whl",
"95203854f974e07af96358c0b261f1048d8e1083f2de9b1c565e1be4a3a48cfc",
),
"aarch64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/18/95/27f80dcd8273171b781a19d109aeaed7f13d78ef6d1e2f7134a5826fd1b4/coverage-6.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"b9023e237f4c02ff739581ef35969c3739445fb059b060ca51771e69101efffe",
),
"x86_64-apple-darwin": (
"https://files.pythonhosted.org/packages/ea/52/c08080405329326a7ff16c0dfdb4feefaa8edd7446413df67386fe1bbfe0/coverage-6.5.0-cp39-cp39-macosx_10_9_x86_64.whl",
"633713d70ad6bfc49b34ead4060531658dc6dfc9b3eb7d8a716d5873377ab745",
),
"x86_64-unknown-linux-gnu": (
"https://files.pythonhosted.org/packages/6b/f2/919f0fdc93d3991ca074894402074d847be8ac1e1d78e7e9e1c371b69a6f/coverage-6.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"8f830ed581b45b82451a40faabb89c84e1a998124ee4212d440e9c6cf70083e5",
),
},
}
#END: managed by update_coverage_deps.py script
_coverage_patch = Label("//python/private:coverage.patch")
def coverage_dep(name, python_version, platform, visibility, install = True):
"""Register a singe coverage dependency based on the python version and platform.
Args:
name: The name of the registered repository.
python_version: The full python version.
platform: The platform, which can be found in //python:versions.bzl PLATFORMS dict.
visibility: The visibility of the coverage tool.
install: should we install the dependency with a given name or generate the label
of the bzlmod dependency fallback, which is hard-coded in MODULE.bazel?
Returns:
The label of the coverage tool if the platform is supported, otherwise - None.
"""
if "windows" in platform:
# NOTE @aignas 2023-01-19: currently we do not support windows as the
# upstream coverage wrapper is written in shell. Do not log any warning
# for now as it is not actionable.
return None
python_short_version = python_version.rpartition(".")[0]
abi = python_short_version.replace("3.", "cp3")
url, sha256 = _coverage_deps.get(abi, {}).get(platform, (None, ""))
if url == None:
# Some wheels are not present for some builds, so let's silently ignore those.
return None
if not install:
# FIXME @aignas 2023-01-19: right now we use globally installed coverage
# which has visibility set to public, but is hidden due to repo remapping.
#
# The name of the toolchain is not known when registering the coverage tooling,
# so we use this as a workaround for now.
return Label("@pypi__coverage_{abi}_{platform}//:coverage".format(
abi = abi,
platform = platform,
))
maybe(
http_archive,
name = name,
build_file_content = """
filegroup(
name = "coverage",
srcs = ["coverage/__main__.py"],
data = glob(["coverage/*.py", "coverage/**/*.py", "coverage/*.so"]),
visibility = {visibility},
)
""".format(
visibility = visibility,
),
patch_args = ["-p1"],
patches = [_coverage_patch],
sha256 = sha256,
type = "zip",
urls = [url],
)
return Label("@@{name}//:coverage".format(name = name))
def install_coverage_deps():
"""Register the dependency for the coverage dep.
This is only used under bzlmod.
"""
for python_version in MINOR_MAPPING.values():
for platform in PLATFORMS.keys():
if "windows" in platform:
continue
coverage_dep(
name = "pypi__coverage_cp{version_no_dot}_{platform}".format(
version_no_dot = python_version.rpartition(".")[0].replace(".", ""),
platform = platform,
),
python_version = python_version,
platform = platform,
visibility = ["//visibility:public"],
install = True,
)
rules_python-0.22.1/python/private/proto/ 0000775 0000000 0000000 00000000000 14540404546 0020473 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/private/proto/BUILD.bazel 0000664 0000000 0000000 00000003005 14540404546 0022347 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private:__pkg__"],
)
bzl_library(
name = "py_proto_library_bzl",
srcs = ["py_proto_library.bzl"],
visibility = ["//python:__pkg__"],
deps = [
"//python:defs_bzl",
"@rules_proto//proto:defs",
],
)
proto_lang_toolchain(
name = "python_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@com_google_protobuf//:protobuf_python",
# NOTE: This isn't *actually* public. It's an implicit dependency of py_proto_library,
# so must be public so user usages of the rule can reference it.
visibility = ["//visibility:public"],
)
rules_python-0.22.1/python/private/proto/py_proto_library.bzl 0000664 0000000 0000000 00000014417 14540404546 0024612 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The implementation of the `py_proto_library` rule and its aspect."""
load("@rules_proto//proto:defs.bzl", "ProtoInfo", "proto_common")
load("//python:defs.bzl", "PyInfo")
ProtoLangToolchainInfo = proto_common.ProtoLangToolchainInfo
_PyProtoInfo = provider(
doc = "Encapsulates information needed by the Python proto rules.",
fields = {
"imports": """
(depset[str]) The field forwarding PyInfo.imports coming from
the proto language runtime dependency.""",
"runfiles_from_proto_deps": """
(depset[File]) Files from the transitive closure implicit proto
dependencies""",
"transitive_sources": """(depset[File]) The Python sources.""",
},
)
def _filter_provider(provider, *attrs):
return [dep[provider] for attr in attrs for dep in attr if provider in dep]
def _py_proto_aspect_impl(target, ctx):
"""Generates and compiles Python code for a proto_library.
The function runs protobuf compiler on the `proto_library` target generating
a .py file for each .proto file.
Args:
target: (Target) A target providing `ProtoInfo`. Usually this means a
`proto_library` target, but not always; you must expect to visit
non-`proto_library` targets, too.
ctx: (RuleContext) The rule context.
Returns:
([_PyProtoInfo]) Providers collecting transitive information about
generated files.
"""
_proto_library = ctx.rule.attr
# Check Proto file names
for proto in target[ProtoInfo].direct_sources:
if proto.is_source and "-" in proto.dirname:
fail("Cannot generate Python code for a .proto whose path contains '-' ({}).".format(
proto.path,
))
proto_lang_toolchain_info = ctx.attr._aspect_proto_toolchain[ProtoLangToolchainInfo]
api_deps = [proto_lang_toolchain_info.runtime]
generated_sources = []
proto_info = target[ProtoInfo]
if proto_info.direct_sources:
# Generate py files
generated_sources = proto_common.declare_generated_files(
actions = ctx.actions,
proto_info = proto_info,
extension = "_pb2.py",
name_mapper = lambda name: name.replace("-", "_").replace(".", "/"),
)
proto_common.compile(
actions = ctx.actions,
proto_info = proto_info,
proto_lang_toolchain_info = proto_lang_toolchain_info,
generated_files = generated_sources,
plugin_output = ctx.bin_dir.path,
)
# Generated sources == Python sources
python_sources = generated_sources
deps = _filter_provider(_PyProtoInfo, getattr(_proto_library, "deps", []))
runfiles_from_proto_deps = depset(
transitive = [dep[DefaultInfo].default_runfiles.files for dep in api_deps] +
[dep.runfiles_from_proto_deps for dep in deps],
)
transitive_sources = depset(
direct = python_sources,
transitive = [dep.transitive_sources for dep in deps],
)
return [
_PyProtoInfo(
imports = depset(
transitive = [dep[PyInfo].imports for dep in api_deps],
),
runfiles_from_proto_deps = runfiles_from_proto_deps,
transitive_sources = transitive_sources,
),
]
_py_proto_aspect = aspect(
implementation = _py_proto_aspect_impl,
attrs = {
"_aspect_proto_toolchain": attr.label(
default = ":python_toolchain",
),
},
attr_aspects = ["deps"],
required_providers = [ProtoInfo],
provides = [_PyProtoInfo],
)
def _py_proto_library_rule(ctx):
"""Merges results of `py_proto_aspect` in `deps`.
Args:
ctx: (RuleContext) The rule context.
Returns:
([PyInfo, DefaultInfo, OutputGroupInfo])
"""
if not ctx.attr.deps:
fail("'deps' attribute mustn't be empty.")
pyproto_infos = _filter_provider(_PyProtoInfo, ctx.attr.deps)
default_outputs = depset(
transitive = [info.transitive_sources for info in pyproto_infos],
)
return [
DefaultInfo(
files = default_outputs,
default_runfiles = ctx.runfiles(transitive_files = depset(
transitive =
[default_outputs] +
[info.runfiles_from_proto_deps for info in pyproto_infos],
)),
),
OutputGroupInfo(
default = depset(),
),
PyInfo(
transitive_sources = default_outputs,
imports = depset(transitive = [info.imports for info in pyproto_infos]),
# Proto always produces 2- and 3- compatible source files
has_py2_only_sources = False,
has_py3_only_sources = False,
),
]
py_proto_library = rule(
implementation = _py_proto_library_rule,
doc = """
Use `py_proto_library` to generate Python libraries from `.proto` files.
The convention is to name the `py_proto_library` rule `foo_py_pb2`,
when it is wrapping `proto_library` rule `foo_proto`.
`deps` must point to a `proto_library` rule.
Example:
```starlark
py_library(
name = "lib",
deps = [":foo_py_pb2"],
)
py_proto_library(
name = "foo_py_pb2",
deps = [":foo_proto"],
)
proto_library(
name = "foo_proto",
srcs = ["foo.proto"],
)
```""",
attrs = {
"deps": attr.label_list(
doc = """
The list of `proto_library` rules to generate Python libraries for.
Usually this is just the one target: the proto library of interest.
It can be any target providing `ProtoInfo`.""",
providers = [ProtoInfo],
aspects = [_py_proto_aspect],
),
},
provides = [PyInfo],
)
rules_python-0.22.1/python/private/py_package.bzl 0000664 0000000 0000000 00000005156 14540404546 0022153 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Implementation of py_package rule"
def _path_inside_wheel(input_file):
# input_file.short_path is sometimes relative ("../${repository_root}/foobar")
# which is not a valid path within a zip file. Fix that.
short_path = input_file.short_path
if short_path.startswith("..") and len(short_path) >= 3:
# Path separator. '/' on linux.
separator = short_path[2]
# Consume '../' part.
short_path = short_path[3:]
# Find position of next '/' and consume everything up to that character.
pos = short_path.find(separator)
short_path = short_path[pos + 1:]
return short_path
def _py_package_impl(ctx):
inputs = depset(
transitive = [dep[DefaultInfo].data_runfiles.files for dep in ctx.attr.deps] +
[dep[DefaultInfo].default_runfiles.files for dep in ctx.attr.deps],
)
# TODO: '/' is wrong on windows, but the path separator is not available in starlark.
# Fix this once ctx.configuration has directory separator information.
packages = [p.replace(".", "/") for p in ctx.attr.packages]
if not packages:
filtered_inputs = inputs
else:
filtered_files = []
# TODO: flattening depset to list gives poor performance,
for input_file in inputs.to_list():
wheel_path = _path_inside_wheel(input_file)
for package in packages:
if wheel_path.startswith(package):
filtered_files.append(input_file)
filtered_inputs = depset(direct = filtered_files)
return [DefaultInfo(
files = filtered_inputs,
)]
py_package_lib = struct(
implementation = _py_package_impl,
attrs = {
"deps": attr.label_list(
doc = "",
),
"packages": attr.string_list(
mandatory = False,
allow_empty = True,
doc = """\
List of Python packages to include in the distribution.
Sub-packages are automatically included.
""",
),
},
path_inside_wheel = _path_inside_wheel,
)
rules_python-0.22.1/python/private/py_wheel.bzl 0000664 0000000 0000000 00000034421 14540404546 0021661 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"Implementation of py_wheel rule"
load("//python/private:stamp.bzl", "is_stamping_enabled")
load(":py_package.bzl", "py_package_lib")
PyWheelInfo = provider(
doc = "Information about a wheel produced by `py_wheel`",
fields = {
"name_file": (
"File: A file containing the canonical name of the wheel (after " +
"stamping, if enabled)."
),
"wheel": "File: The wheel file itself.",
},
)
_distribution_attrs = {
"abi": attr.string(
default = "none",
doc = "Python ABI tag. 'none' for pure-Python wheels.",
),
"distribution": attr.string(
mandatory = True,
doc = """\
Name of the distribution.
This should match the project name onm PyPI. It's also the name that is used to
refer to the package in other packages' dependencies.
""",
),
"platform": attr.string(
default = "any",
doc = """\
Supported platform. Use 'any' for pure-Python wheel.
If you have included platform-specific data, such as a .pyd or .so
extension module, you will need to specify the platform in standard
pip format. If you support multiple platforms, you can define
platform constraints, then use a select() to specify the appropriate
specifier, eg:
`
platform = select({
"//platforms:windows_x86_64": "win_amd64",
"//platforms:macos_x86_64": "macosx_10_7_x86_64",
"//platforms:linux_x86_64": "manylinux2014_x86_64",
})
`
""",
),
"python_tag": attr.string(
default = "py3",
doc = "Supported Python version(s), eg `py3`, `cp35.cp36`, etc",
),
"stamp": attr.int(
doc = """\
Whether to encode build information into the wheel. Possible values:
- `stamp = 1`: Always stamp the build information into the wheel, even in \
[--nostamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) builds. \
This setting should be avoided, since it potentially kills remote caching for the target and \
any downstream actions that depend on it.
- `stamp = 0`: Always replace build information by constant values. This gives good build result caching.
- `stamp = -1`: Embedding of build information is controlled by the \
[--[no]stamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) flag.
Stamped targets are not rebuilt unless their dependencies change.
""",
default = -1,
values = [1, 0, -1],
),
"version": attr.string(
mandatory = True,
doc = """\
Version number of the package.
Note that this attribute supports stamp format strings as well as 'make variables'.
For example:
- `version = "1.2.3-{BUILD_TIMESTAMP}"`
- `version = "{BUILD_EMBED_LABEL}"`
- `version = "$(VERSION)"`
Note that Bazel's output filename cannot include the stamp information, as outputs must be known
during the analysis phase and the stamp data is available only during the action execution.
The [`py_wheel`](/docs/packaging.md#py_wheel) macro produces a `.dist`-suffix target which creates a
`dist/` folder containing the wheel with the stamped name, suitable for publishing.
See [`py_wheel_dist`](/docs/packaging.md#py_wheel_dist) for more info.
""",
),
"_stamp_flag": attr.label(
doc = "A setting used to determine whether or not the `--stamp` flag is enabled",
default = Label("//python/private:stamp"),
),
}
_requirement_attrs = {
"extra_requires": attr.string_list_dict(
doc = "List of optional requirements for this package",
),
"requires": attr.string_list(
doc = ("List of requirements for this package. See the section on " +
"[Declaring required dependency](https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#declaring-dependencies) " +
"for details and examples of the format of this argument."),
),
}
_entrypoint_attrs = {
"console_scripts": attr.string_dict(
doc = """\
Deprecated console_script entry points, e.g. `{'main': 'examples.wheel.main:main'}`.
Deprecated: prefer the `entry_points` attribute, which supports `console_scripts` as well as other entry points.
""",
),
"entry_points": attr.string_list_dict(
doc = """\
entry_points, e.g. `{'console_scripts': ['main = examples.wheel.main:main']}`.
""",
),
}
_other_attrs = {
"author": attr.string(
doc = "A string specifying the author of the package.",
default = "",
),
"author_email": attr.string(
doc = "A string specifying the email address of the package author.",
default = "",
),
"classifiers": attr.string_list(
doc = "A list of strings describing the categories for the package. For valid classifiers see https://pypi.org/classifiers",
),
"description_file": attr.label(
doc = "A file containing text describing the package.",
allow_single_file = True,
),
"extra_distinfo_files": attr.label_keyed_string_dict(
doc = "Extra files to add to distinfo directory in the archive.",
allow_files = True,
),
"homepage": attr.string(
doc = "A string specifying the URL for the package homepage.",
default = "",
),
"license": attr.string(
doc = "A string specifying the license of the package.",
default = "",
),
"python_requires": attr.string(
doc = (
"Python versions required by this distribution, e.g. '>=3.5,<3.7'"
),
default = "",
),
"strip_path_prefixes": attr.string_list(
default = [],
doc = "path prefixes to strip from files added to the generated package",
),
}
def _escape_filename_segment(segment):
"""Escape a segment of the wheel filename.
See https://www.python.org/dev/peps/pep-0427/#escaping-and-unicode
"""
# TODO: this is wrong, isalnum replaces non-ascii letters, while we should
# not replace them.
# TODO: replace this with a regexp once starlark supports them.
escaped = ""
for character in segment.elems():
# isalnum doesn't handle unicode characters properly.
if character.isalnum() or character == ".":
escaped += character
elif not escaped.endswith("_"):
escaped += "_"
return escaped
def _replace_make_variables(flag, ctx):
"""Replace $(VERSION) etc make variables in flag"""
if "$" in flag:
for varname, varsub in ctx.var.items():
flag = flag.replace("$(%s)" % varname, varsub)
return flag
def _input_file_to_arg(input_file):
"""Converts a File object to string for --input_file argument to wheelmaker"""
return "%s;%s" % (py_package_lib.path_inside_wheel(input_file), input_file.path)
def _py_wheel_impl(ctx):
abi = _replace_make_variables(ctx.attr.abi, ctx)
python_tag = _replace_make_variables(ctx.attr.python_tag, ctx)
version = _replace_make_variables(ctx.attr.version, ctx)
outfile = ctx.actions.declare_file("-".join([
_escape_filename_segment(ctx.attr.distribution),
_escape_filename_segment(version),
_escape_filename_segment(python_tag),
_escape_filename_segment(abi),
_escape_filename_segment(ctx.attr.platform),
]) + ".whl")
name_file = ctx.actions.declare_file(ctx.label.name + ".name")
inputs_to_package = depset(
direct = ctx.files.deps,
)
# Inputs to this rule which are not to be packaged.
# Currently this is only the description file (if used).
other_inputs = []
# Wrap the inputs into a file to reduce command line length.
packageinputfile = ctx.actions.declare_file(ctx.attr.name + "_target_wrapped_inputs.txt")
content = ""
for input_file in inputs_to_package.to_list():
content += _input_file_to_arg(input_file) + "\n"
ctx.actions.write(output = packageinputfile, content = content)
other_inputs.append(packageinputfile)
args = ctx.actions.args()
args.add("--name", ctx.attr.distribution)
args.add("--version", version)
args.add("--python_tag", python_tag)
args.add("--abi", abi)
args.add("--platform", ctx.attr.platform)
args.add("--out", outfile)
args.add("--name_file", name_file)
args.add_all(ctx.attr.strip_path_prefixes, format_each = "--strip_path_prefix=%s")
# Pass workspace status files if stamping is enabled
if is_stamping_enabled(ctx.attr):
args.add("--volatile_status_file", ctx.version_file)
args.add("--stable_status_file", ctx.info_file)
other_inputs.extend([ctx.version_file, ctx.info_file])
args.add("--input_file_list", packageinputfile)
# Note: Description file and version are not embedded into metadata.txt yet,
# it will be done later by wheelmaker script.
metadata_file = ctx.actions.declare_file(ctx.attr.name + ".metadata.txt")
metadata_contents = ["Metadata-Version: 2.1"]
metadata_contents.append("Name: %s" % ctx.attr.distribution)
if ctx.attr.author:
metadata_contents.append("Author: %s" % ctx.attr.author)
if ctx.attr.author_email:
metadata_contents.append("Author-email: %s" % ctx.attr.author_email)
if ctx.attr.homepage:
metadata_contents.append("Home-page: %s" % ctx.attr.homepage)
if ctx.attr.license:
metadata_contents.append("License: %s" % ctx.attr.license)
for c in ctx.attr.classifiers:
metadata_contents.append("Classifier: %s" % c)
if ctx.attr.python_requires:
metadata_contents.append("Requires-Python: %s" % ctx.attr.python_requires)
for requirement in ctx.attr.requires:
metadata_contents.append("Requires-Dist: %s" % requirement)
for option, option_requirements in sorted(ctx.attr.extra_requires.items()):
metadata_contents.append("Provides-Extra: %s" % option)
for requirement in option_requirements:
metadata_contents.append(
"Requires-Dist: %s; extra == '%s'" % (requirement, option),
)
ctx.actions.write(
output = metadata_file,
content = "\n".join(metadata_contents) + "\n",
)
other_inputs.append(metadata_file)
args.add("--metadata_file", metadata_file)
# Merge console_scripts into entry_points.
entrypoints = dict(ctx.attr.entry_points) # Copy so we can mutate it
if ctx.attr.console_scripts:
# Copy a console_scripts group that may already exist, so we can mutate it.
console_scripts = list(entrypoints.get("console_scripts", []))
entrypoints["console_scripts"] = console_scripts
for name, ref in ctx.attr.console_scripts.items():
console_scripts.append("{name} = {ref}".format(name = name, ref = ref))
# If any entry_points are provided, construct the file here and add it to the files to be packaged.
# see: https://packaging.python.org/specifications/entry-points/
if entrypoints:
lines = []
for group, entries in sorted(entrypoints.items()):
if lines:
# Blank line between groups
lines.append("")
lines.append("[{group}]".format(group = group))
lines += sorted(entries)
entry_points_file = ctx.actions.declare_file(ctx.attr.name + "_entry_points.txt")
content = "\n".join(lines)
ctx.actions.write(output = entry_points_file, content = content)
other_inputs.append(entry_points_file)
args.add("--entry_points_file", entry_points_file)
if ctx.attr.description_file:
description_file = ctx.file.description_file
args.add("--description_file", description_file)
other_inputs.append(description_file)
for target, filename in ctx.attr.extra_distinfo_files.items():
target_files = target.files.to_list()
if len(target_files) != 1:
fail(
"Multi-file target listed in extra_distinfo_files %s",
filename,
)
other_inputs.extend(target_files)
args.add(
"--extra_distinfo_file",
filename + ";" + target_files[0].path,
)
ctx.actions.run(
inputs = depset(direct = other_inputs, transitive = [inputs_to_package]),
outputs = [outfile, name_file],
arguments = [args],
executable = ctx.executable._wheelmaker,
progress_message = "Building wheel {}".format(ctx.label),
)
return [
DefaultInfo(
files = depset([outfile]),
runfiles = ctx.runfiles(files = [outfile]),
),
PyWheelInfo(
wheel = outfile,
name_file = name_file,
),
]
def _concat_dicts(*dicts):
result = {}
for d in dicts:
result.update(d)
return result
py_wheel_lib = struct(
implementation = _py_wheel_impl,
attrs = _concat_dicts(
{
"deps": attr.label_list(
doc = """\
Targets to be included in the distribution.
The targets to package are usually `py_library` rules or filesets (for packaging data files).
Note it's usually better to package `py_library` targets and use
`entry_points` attribute to specify `console_scripts` than to package
`py_binary` rules. `py_binary` targets would wrap a executable script that
tries to locate `.runfiles` directory which is not packaged in the wheel.
""",
),
"_wheelmaker": attr.label(
executable = True,
cfg = "exec",
default = "//tools:wheelmaker",
),
},
_distribution_attrs,
_requirement_attrs,
_entrypoint_attrs,
_other_attrs,
),
)
py_wheel = rule(
implementation = py_wheel_lib.implementation,
doc = """\
Internal rule used by the [py_wheel macro](/docs/packaging.md#py_wheel).
These intentionally have the same name to avoid sharp edges with Bazel macros.
For example, a `bazel query` for a user's `py_wheel` macro expands to `py_wheel` targets,
in the way they expect.
""",
attrs = py_wheel_lib.attrs,
)
rules_python-0.22.1/python/private/reexports.bzl 0000664 0000000 0000000 00000003227 14540404546 0022100 0 ustar 00root root 0000000 0000000 # Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Internal re-exports of built-in symbols.
Currently the definitions here are re-exports of the native rules, "blessed" to
work under `--incompatible_load_python_rules_from_bzl`. As the native rules get
migrated to Starlark, their implementations will be removed from here.
We want to re-export a built-in symbol as if it were defined in a Starlark
file, so that users can for instance do:
```
load("@rules_python//python:defs.bzl", "PyInfo")
```
Unfortunately, we can't just write in defs.bzl
```
PyInfo = PyInfo
```
because the declaration of module-level symbol `PyInfo` makes the builtin
inaccessible. So instead we access the builtin here and export it under a
different name. Then we can load it from defs.bzl and export it there under
the original name.
"""
# Don't use underscore prefix, since that would make the symbol local to this
# file only. Use a non-conventional name to emphasize that this is not a public
# symbol.
# buildifier: disable=name-conventions
internal_PyInfo = PyInfo
# buildifier: disable=name-conventions
internal_PyRuntimeInfo = PyRuntimeInfo
rules_python-0.22.1/python/private/stamp.bzl 0000664 0000000 0000000 00000005664 14540404546 0021200 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A small utility module dedicated to detecting whether or not the `--stamp` flag is enabled
This module can be removed likely after the following PRs ar addressed:
- https://github.com/bazelbuild/bazel/issues/11164
"""
StampSettingInfo = provider(
doc = "Information about the `--stamp` command line flag",
fields = {
"value": "bool: Whether or not the `--stamp` flag was enabled",
},
)
def _stamp_build_setting_impl(ctx):
return StampSettingInfo(value = ctx.attr.value)
_stamp_build_setting = rule(
doc = """\
Whether to encode build information into the binary. Possible values:
- stamp = 1: Always stamp the build information into the binary, even in [--nostamp][stamp] builds. \
This setting should be avoided, since it potentially kills remote caching for the binary and \
any downstream actions that depend on it.
- stamp = 0: Always replace build information by constant values. This gives good build result caching.
- stamp = -1: Embedding of build information is controlled by the [--[no]stamp][stamp] flag.
Stamped binaries are not rebuilt unless their dependencies change.
[stamp]: https://docs.bazel.build/versions/main/user-manual.html#flag--stamp
""",
implementation = _stamp_build_setting_impl,
attrs = {
"value": attr.bool(
doc = "The default value of the stamp build flag",
mandatory = True,
),
},
)
def stamp_build_setting(name, visibility = ["//visibility:public"]):
native.config_setting(
name = "stamp_detect",
values = {"stamp": "1"},
visibility = visibility,
)
_stamp_build_setting(
name = name,
value = select({
":stamp_detect": True,
"//conditions:default": False,
}),
visibility = visibility,
)
def is_stamping_enabled(attr):
"""Determine whether or not build stamping is enabled
Args:
attr (struct): A rule's struct of attributes (`ctx.attr`)
Returns:
bool: The stamp value
"""
stamp_num = getattr(attr, "stamp", -1)
if stamp_num == 1:
return True
elif stamp_num == 0:
return False
elif stamp_num == -1:
stamp_flag = getattr(attr, "_stamp_flag", None)
return stamp_flag[StampSettingInfo].value if stamp_flag else False
else:
fail("Unexpected `stamp` value: {}".format(stamp_num))
rules_python-0.22.1/python/private/toolchains_repo.bzl 0000664 0000000 0000000 00000024354 14540404546 0023241 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create a repository to hold the toolchains.
This follows guidance here:
https://docs.bazel.build/versions/main/skylark/deploying.html#registering-toolchains
The "complex computation" in our case is simply downloading large artifacts.
This guidance tells us how to avoid that: we put the toolchain targets in the
alias repository with only the toolchain attribute pointing into the
platform-specific repositories.
"""
load(
"//python:versions.bzl",
"LINUX_NAME",
"MACOS_NAME",
"PLATFORMS",
"WINDOWS_NAME",
)
def get_repository_name(repository_workspace):
dummy_label = "//:_"
return str(repository_workspace.relative(dummy_label))[:-len(dummy_label)] or "@"
def _toolchains_repo_impl(rctx):
python_version_constraint = "{rules_python}//python/config_settings:is_python_{python_version}".format(
rules_python = get_repository_name(rctx.attr._rules_python_workspace),
python_version = rctx.attr.python_version,
)
build_content = """\
# Generated by python/private/toolchains_repo.bzl
#
# These can be registered in the workspace file or passed to --extra_toolchains
# flag. By default all these toolchains are registered by the
# python_register_toolchains macro so you don't normally need to interact with
# these targets.
"""
for [platform, meta] in PLATFORMS.items():
build_content += """\
# Bazel selects this toolchain to get a Python interpreter
# for executing build actions.
toolchain(
name = "{platform}_toolchain",
target_compatible_with = {compatible_with},
target_settings = ["{python_version_constraint}"] if {set_python_version_constraint} else [],
toolchain = "@{user_repository_name}_{platform}//:python_runtimes",
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
)
""".format(
compatible_with = meta.compatible_with,
name = rctx.attr.name,
platform = platform,
python_version_constraint = python_version_constraint,
set_python_version_constraint = rctx.attr.set_python_version_constraint,
user_repository_name = rctx.attr.user_repository_name,
)
rctx.file("BUILD.bazel", build_content)
toolchains_repo = repository_rule(
_toolchains_repo_impl,
doc = "Creates a repository with toolchain definitions for all known platforms " +
"which can be registered or selected.",
attrs = {
"python_version": attr.string(doc = "The Python version."),
"set_python_version_constraint": attr.bool(doc = "if target_compatible_with for the toolchain should set the version constraint"),
"user_repository_name": attr.string(doc = "what the user chose for the base name"),
"_rules_python_workspace": attr.label(default = Label("//:WORKSPACE")),
},
)
def _toolchain_aliases_impl(rctx):
(os_name, arch) = get_host_os_arch(rctx)
host_platform = get_host_platform(os_name, arch)
is_windows = (os_name == WINDOWS_NAME)
python3_binary_path = "python.exe" if is_windows else "bin/python3"
# Base BUILD file for this repository.
build_contents = """\
# Generated by python/private/toolchains_repo.bzl
package(default_visibility = ["//visibility:public"])
load("@rules_python//python:versions.bzl", "PLATFORMS", "gen_python_config_settings")
gen_python_config_settings()
exports_files(["defs.bzl"])
alias(name = "files", actual = select({{":" + item: "@{py_repository}_" + item + "//:files" for item in PLATFORMS.keys()}}))
alias(name = "includes", actual = select({{":" + item: "@{py_repository}_" + item + "//:includes" for item in PLATFORMS.keys()}}))
alias(name = "libpython", actual = select({{":" + item: "@{py_repository}_" + item + "//:libpython" for item in PLATFORMS.keys()}}))
alias(name = "py3_runtime", actual = select({{":" + item: "@{py_repository}_" + item + "//:py3_runtime" for item in PLATFORMS.keys()}}))
alias(name = "python_headers", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_headers" for item in PLATFORMS.keys()}}))
alias(name = "python_runtimes", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_runtimes" for item in PLATFORMS.keys()}}))
alias(name = "python3", actual = select({{":" + item: "@{py_repository}_" + item + "//:" + ("python.exe" if "windows" in item else "bin/python3") for item in PLATFORMS.keys()}}))
""".format(
py_repository = rctx.attr.user_repository_name,
)
if not is_windows:
build_contents += """\
alias(name = "pip", actual = select({{":" + item: "@{py_repository}_" + item + "//:python_runtimes" for item in PLATFORMS.keys() if "windows" not in item}}))
""".format(
py_repository = rctx.attr.user_repository_name,
host_platform = host_platform,
)
rctx.file("BUILD.bazel", build_contents)
# Expose a Starlark file so rules can know what host platform we used and where to find an interpreter
# when using repository_ctx.path, which doesn't understand aliases.
rctx.file("defs.bzl", content = """\
# Generated by python/private/toolchains_repo.bzl
load("{rules_python}//python/config_settings:transition.bzl", _py_binary = "py_binary", _py_test = "py_test")
load("{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements")
host_platform = "{host_platform}"
interpreter = "@{py_repository}_{host_platform}//:{python3_binary_path}"
def py_binary(name, **kwargs):
return _py_binary(
name = name,
python_version = "{python_version}",
**kwargs
)
def py_test(name, **kwargs):
return _py_test(
name = name,
python_version = "{python_version}",
**kwargs
)
def compile_pip_requirements(name, **kwargs):
return _compile_pip_requirements(
name = name,
py_binary = py_binary,
py_test = py_test,
**kwargs
)
""".format(
host_platform = host_platform,
py_repository = rctx.attr.user_repository_name,
python_version = rctx.attr.python_version,
python3_binary_path = python3_binary_path,
rules_python = get_repository_name(rctx.attr._rules_python_workspace),
))
toolchain_aliases = repository_rule(
_toolchain_aliases_impl,
doc = """Creates a repository with a shorter name meant for the host platform, which contains
a BUILD.bazel file declaring aliases to the host platform's targets.
""",
attrs = {
"python_version": attr.string(doc = "The Python version."),
"user_repository_name": attr.string(
mandatory = True,
doc = "The base name for all created repositories, like 'python38'.",
),
"_rules_python_workspace": attr.label(default = Label("//:WORKSPACE")),
},
)
def _multi_toolchain_aliases_impl(rctx):
rules_python = rctx.attr._rules_python_workspace.workspace_name
for python_version, repository_name in rctx.attr.python_versions.items():
file = "{}/defs.bzl".format(python_version)
rctx.file(file, content = """\
# Generated by python/private/toolchains_repo.bzl
load(
"@{repository_name}//:defs.bzl",
_compile_pip_requirements = "compile_pip_requirements",
_host_platform = "host_platform",
_interpreter = "interpreter",
_py_binary = "py_binary",
_py_test = "py_test",
)
compile_pip_requirements = _compile_pip_requirements
host_platform = _host_platform
interpreter = _interpreter
py_binary = _py_binary
py_test = _py_test
""".format(
repository_name = repository_name,
))
rctx.file("{}/BUILD.bazel".format(python_version), "")
pip_bzl = """\
# Generated by python/private/toolchains_repo.bzl
load("@{rules_python}//python:pip.bzl", "pip_parse", _multi_pip_parse = "multi_pip_parse")
def multi_pip_parse(name, requirements_lock, **kwargs):
return _multi_pip_parse(
name = name,
python_versions = {python_versions},
requirements_lock = requirements_lock,
**kwargs
)
""".format(
python_versions = rctx.attr.python_versions.keys(),
rules_python = rules_python,
)
rctx.file("pip.bzl", content = pip_bzl)
rctx.file("BUILD.bazel", "")
multi_toolchain_aliases = repository_rule(
_multi_toolchain_aliases_impl,
attrs = {
"python_versions": attr.string_dict(doc = "The Python versions."),
"_rules_python_workspace": attr.label(default = Label("//:WORKSPACE")),
},
)
def sanitize_platform_name(platform):
return platform.replace("-", "_")
def get_host_platform(os_name, arch):
"""Gets the host platform.
Args:
os_name: the host OS name.
arch: the host arch.
Returns:
The host platform.
"""
host_platform = None
for platform, meta in PLATFORMS.items():
if meta.os_name == os_name and meta.arch == arch:
host_platform = platform
if not host_platform:
fail("No platform declared for host OS {} on arch {}".format(os_name, arch))
return host_platform
def get_host_os_arch(rctx):
"""Infer the host OS name and arch from a repository context.
Args:
rctx: Bazel's repository_ctx.
Returns:
A tuple with the host OS name and arch.
"""
os_name = rctx.os.name
# We assume the arch for Windows is always x86_64.
if "windows" in os_name.lower():
arch = "x86_64"
# Normalize the os_name. E.g. os_name could be "OS windows server 2019".
os_name = WINDOWS_NAME
else:
# This is not ideal, but bazel doesn't directly expose arch.
arch = rctx.execute(["uname", "-m"]).stdout.strip()
# Normalize the os_name.
if "mac" in os_name.lower():
os_name = MACOS_NAME
elif "linux" in os_name.lower():
os_name = LINUX_NAME
return (os_name, arch)
rules_python-0.22.1/python/private/util.bzl 0000664 0000000 0000000 00000004566 14540404546 0021031 0 ustar 00root root 0000000 0000000 """Functionality shared by multiple pieces of code."""
load("@bazel_skylib//lib:types.bzl", "types")
def copy_propagating_kwargs(from_kwargs, into_kwargs = None):
"""Copies args that must be compatible between two targets with a dependency relationship.
This is intended for when one target depends on another, so they must have
compatible settings such as `testonly` and `compatible_with`. This usually
happens when a macro generates multiple targets, some of which depend
on one another, so their settings must be compatible.
Args:
from_kwargs: keyword args dict whose common kwarg will be copied.
into_kwargs: optional keyword args dict that the values from `from_kwargs`
will be copied into. The values in this dict will take precedence
over the ones in `from_kwargs` (i.e., if this has `testonly` already
set, then it won't be overwritten).
NOTE: THIS WILL BE MODIFIED IN-PLACE.
Returns:
Keyword args to use for the depender target derived from the dependency
target. If `into_kwargs` was passed in, then that same object is
returned; this is to facilitate easy `**` expansion.
"""
if into_kwargs == None:
into_kwargs = {}
# Include tags because people generally expect tags to propagate.
for attr in ("testonly", "tags", "compatible_with", "restricted_to"):
if attr in from_kwargs and attr not in into_kwargs:
into_kwargs[attr] = from_kwargs[attr]
return into_kwargs
# The implementation of the macros and tagging mechanism follows the example
# set by rules_cc and rules_java.
_MIGRATION_TAG = "__PYTHON_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
def add_migration_tag(attrs):
"""Add a special tag to `attrs` to aid migration off native rles.
Args:
attrs: dict of keyword args. The `tags` key will be modified in-place.
Returns:
The same `attrs` object, but modified.
"""
if "tags" in attrs and attrs["tags"] != None:
tags = attrs["tags"]
# Preserve the input type: this allows a test verifying the underlying
# rule can accept the tuple for the tags argument.
if types.is_tuple(tags):
attrs["tags"] = tags + (_MIGRATION_TAG,)
else:
attrs["tags"] = tags + [_MIGRATION_TAG]
else:
attrs["tags"] = [_MIGRATION_TAG]
return attrs
rules_python-0.22.1/python/proto.bzl 0000664 0000000 0000000 00000001374 14540404546 0017537 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Python proto library.
"""
load("//python/private/proto:py_proto_library.bzl", _py_proto_library = "py_proto_library")
py_proto_library = _py_proto_library
rules_python-0.22.1/python/py_binary.bzl 0000664 0000000 0000000 00000002414 14540404546 0020364 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for py_binary."""
load("//python/private:util.bzl", "add_migration_tag")
def py_binary(**attrs):
"""See the Bazel core [py_binary](https://docs.bazel.build/versions/master/be/python.html#py_binary) documentation.
Args:
**attrs: Rule attributes
"""
if attrs.get("python_version") == "PY2":
fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")
if attrs.get("srcs_version") in ("PY2", "PY2ONLY"):
fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")
# buildifier: disable=native-python
native.py_binary(**add_migration_tag(attrs))
rules_python-0.22.1/python/py_cc_link_params_info.bzl 0000664 0000000 0000000 00000000136 14540404546 0023057 0 ustar 00root root 0000000 0000000 """Public entry point for PyCcLinkParamsInfo."""
PyCcLinkParamsInfo = PyCcLinkParamsProvider
rules_python-0.22.1/python/py_import.bzl 0000664 0000000 0000000 00000005013 14540404546 0020410 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for py_import rule."""
load(":py_info.bzl", "PyInfo")
def _py_import_impl(ctx):
# See https://github.com/bazelbuild/bazel/blob/0.24.0/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPythonSemantics.java#L104 .
import_paths = [
"/".join([ctx.workspace_name, x.short_path])
for x in ctx.files.srcs
]
return [
DefaultInfo(
default_runfiles = ctx.runfiles(ctx.files.srcs, collect_default = True),
),
PyInfo(
transitive_sources = depset(transitive = [
dep[PyInfo].transitive_sources
for dep in ctx.attr.deps
]),
imports = depset(direct = import_paths, transitive = [
dep[PyInfo].imports
for dep in ctx.attr.deps
]),
),
]
py_import = rule(
doc = """This rule allows the use of Python packages as dependencies.
It imports the given `.egg` file(s), which might be checked in source files,
fetched externally as with `http_file`, or produced as outputs of other rules.
It may be used like a `py_library`, in the `deps` of other Python rules.
This is similar to [java_import](https://docs.bazel.build/versions/master/be/java.html#java_import).
""",
implementation = _py_import_impl,
attrs = {
"deps": attr.label_list(
doc = "The list of other libraries to be linked in to the " +
"binary target.",
providers = [PyInfo],
),
"srcs": attr.label_list(
doc = "The list of Python package files provided to Python targets " +
"that depend on this target. Note that currently only the .egg " +
"format is accepted. For .whl files, try the whl_library rule. " +
"We accept contributions to extend py_import to handle .whl.",
allow_files = [".egg"],
),
},
)
rules_python-0.22.1/python/py_info.bzl 0000664 0000000 0000000 00000001326 14540404546 0020034 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for PyInfo."""
load("//python/private:reexports.bzl", "internal_PyInfo")
PyInfo = internal_PyInfo
rules_python-0.22.1/python/py_library.bzl 0000664 0000000 0000000 00000002175 14540404546 0020550 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for py_library."""
load("//python/private:util.bzl", "add_migration_tag")
def py_library(**attrs):
"""See the Bazel core [py_library](https://docs.bazel.build/versions/master/be/python.html#py_library) documentation.
Args:
**attrs: Rule attributes
"""
if attrs.get("srcs_version") in ("PY2", "PY2ONLY"):
fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")
# buildifier: disable=native-python
native.py_library(**add_migration_tag(attrs))
rules_python-0.22.1/python/py_runtime.bzl 0000664 0000000 0000000 00000002166 14540404546 0020567 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for py_runtime."""
load("//python/private:util.bzl", "add_migration_tag")
def py_runtime(**attrs):
"""See the Bazel core [py_runtime](https://docs.bazel.build/versions/master/be/python.html#py_runtime) documentation.
Args:
**attrs: Rule attributes
"""
if attrs.get("python_version") == "PY2":
fail("Python 2 is no longer supported: see https://github.com/bazelbuild/rules_python/issues/886")
# buildifier: disable=native-python
native.py_runtime(**add_migration_tag(attrs))
rules_python-0.22.1/python/py_runtime_info.bzl 0000664 0000000 0000000 00000001362 14540404546 0021577 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for PyRuntimeInfo."""
load("//python/private:reexports.bzl", "internal_PyRuntimeInfo")
PyRuntimeInfo = internal_PyRuntimeInfo
rules_python-0.22.1/python/py_runtime_pair.bzl 0000664 0000000 0000000 00000005327 14540404546 0021604 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for py_runtime_pair."""
load("@bazel_tools//tools/python:toolchain.bzl", _py_runtime_pair = "py_runtime_pair")
# NOTE: This doc is copy/pasted from the builtin py_runtime_pair rule so our
# doc generator gives useful API docs.
def py_runtime_pair(name, py2_runtime = None, py3_runtime = None, **attrs):
"""A toolchain rule for Python.
This used to wrap up to two Python runtimes, one for Python 2 and one for Python 3.
However, Python 2 is no longer supported, so it now only wraps a single Python 3
runtime.
Usually the wrapped runtimes are declared using the `py_runtime` rule, but any
rule returning a `PyRuntimeInfo` provider may be used.
This rule returns a `platform_common.ToolchainInfo` provider with the following
schema:
```python
platform_common.ToolchainInfo(
py2_runtime = None,
py3_runtime = ,
)
```
Example usage:
```python
# In your BUILD file...
load("@rules_python//python:defs.bzl", "py_runtime_pair")
py_runtime(
name = "my_py3_runtime",
interpreter_path = "/system/python3",
python_version = "PY3",
)
py_runtime_pair(
name = "my_py_runtime_pair",
py3_runtime = ":my_py3_runtime",
)
toolchain(
name = "my_toolchain",
target_compatible_with = <...>,
toolchain = ":my_py_runtime_pair",
toolchain_type = "@rules_python//python:toolchain_type",
)
```
```python
# In your WORKSPACE...
register_toolchains("//my_pkg:my_toolchain")
```
Args:
name: str, the name of the target
py2_runtime: optional Label; must be unset or None; an error is raised
otherwise.
py3_runtime: Label; a target with `PyRuntimeInfo` for Python 3.
**attrs: Extra attrs passed onto the native rule
"""
if attrs.get("py2_runtime"):
fail("PYthon 2 is no longer supported: see https://github.com/bazelbuild/rules_python/issues/886")
_py_runtime_pair(
name = name,
py2_runtime = py2_runtime,
py3_runtime = py3_runtime,
**attrs
)
rules_python-0.22.1/python/py_test.bzl 0000664 0000000 0000000 00000002402 14540404546 0020054 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Public entry point for py_test."""
load("//python/private:util.bzl", "add_migration_tag")
def py_test(**attrs):
"""See the Bazel core [py_test](https://docs.bazel.build/versions/master/be/python.html#py_test) documentation.
Args:
**attrs: Rule attributes
"""
if attrs.get("python_version") == "PY2":
fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")
if attrs.get("srcs_version") in ("PY2", "PY2ONLY"):
fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")
# buildifier: disable=native-python
native.py_test(**add_migration_tag(attrs))
rules_python-0.22.1/python/python.bzl 0000664 0000000 0000000 00000004510 14540404546 0017710 0 ustar 00root root 0000000 0000000 # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Re-exports for some of the core Bazel Python rules.
This file is deprecated; please use the exports in defs.bzl instead. This is to
follow the new naming convention of putting core rules for a language
underneath @rules_//:defs.bzl. The exports in this file will be
disallowed in a future Bazel release by
`--incompatible_load_python_rules_from_bzl`.
"""
def py_library(*args, **kwargs):
"""Deprecated py_library rule.
See the Bazel core [py_library](
https://docs.bazel.build/versions/master/be/python.html#py_library)
documentation.
Deprecated: This symbol will become unusuable when
`--incompatible_load_python_rules_from_bzl` is enabled. Please use the
symbols in `@rules_python//python:defs.bzl` instead.
"""
# buildifier: disable=native-python
native.py_library(*args, **kwargs)
def py_binary(*args, **kwargs):
"""Deprecated py_binary rule.
See the Bazel core [py_binary](
https://docs.bazel.build/versions/master/be/python.html#py_binary)
documentation.
Deprecated: This symbol will become unusuable when
`--incompatible_load_python_rules_from_bzl` is enabled. Please use the
symbols in `@rules_python//python:defs.bzl` instead.
"""
# buildifier: disable=native-python
native.py_binary(*args, **kwargs)
def py_test(*args, **kwargs):
"""Deprecated py_test rule.
See the Bazel core [py_test](
https://docs.bazel.build/versions/master/be/python.html#py_test)
documentation.
Deprecated: This symbol will become unusuable when
`--incompatible_load_python_rules_from_bzl` is enabled. Please use the
symbols in `@rules_python//python:defs.bzl` instead.
"""
# buildifier: disable=native-python
native.py_test(*args, **kwargs)
rules_python-0.22.1/python/repositories.bzl 0000664 0000000 0000000 00000055425 14540404546 0021131 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This file contains macros to be called during WORKSPACE evaluation.
For historic reasons, pip_repositories() is defined in //python:pip.bzl.
"""
load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//python/private:coverage_deps.bzl", "coverage_dep")
load(
"//python/private:toolchains_repo.bzl",
"multi_toolchain_aliases",
"toolchain_aliases",
"toolchains_repo",
)
load(
":versions.bzl",
"DEFAULT_RELEASE_BASE_URL",
"MINOR_MAPPING",
"PLATFORMS",
"TOOL_VERSIONS",
"get_release_info",
)
def http_archive(**kwargs):
maybe(_http_archive, **kwargs)
def py_repositories():
"""Runtime dependencies that users must install.
This function should be loaded and called in the user's WORKSPACE.
With bzlmod enabled, this function is not needed since MODULE.bazel handles transitive deps.
"""
http_archive(
name = "bazel_skylib",
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
],
)
########
# Remaining content of the file is only used to support toolchains.
########
STANDALONE_INTERPRETER_FILENAME = "STANDALONE_INTERPRETER"
def get_interpreter_dirname(rctx, python_interpreter_target):
"""Get a python interpreter target dirname.
Args:
rctx (repository_ctx): The repository rule's context object.
python_interpreter_target (Target): A target representing a python interpreter.
Returns:
str: The Python interpreter directory.
"""
return rctx.path(Label("{}//:WORKSPACE".format(str(python_interpreter_target).split("//")[0]))).dirname
def is_standalone_interpreter(rctx, python_interpreter_target):
"""Query a python interpreter target for whether or not it's a rules_rust provided toolchain
Args:
rctx (repository_ctx): The repository rule's context object.
python_interpreter_target (Target): A target representing a python interpreter.
Returns:
bool: Whether or not the target is from a rules_python generated toolchain.
"""
# Only update the location when using a hermetic toolchain.
if not python_interpreter_target:
return False
# This is a rules_python provided toolchain.
return rctx.execute([
"ls",
"{}/{}".format(
get_interpreter_dirname(rctx, python_interpreter_target),
STANDALONE_INTERPRETER_FILENAME,
),
]).return_code == 0
def _python_repository_impl(rctx):
if rctx.attr.distutils and rctx.attr.distutils_content:
fail("Only one of (distutils, distutils_content) should be set.")
if bool(rctx.attr.url) == bool(rctx.attr.urls):
fail("Exactly one of (url, urls) must be set.")
platform = rctx.attr.platform
python_version = rctx.attr.python_version
python_short_version = python_version.rpartition(".")[0]
release_filename = rctx.attr.release_filename
urls = rctx.attr.urls or [rctx.attr.url]
if release_filename.endswith(".zst"):
rctx.download(
url = urls,
sha256 = rctx.attr.sha256,
output = release_filename,
)
unzstd = rctx.which("unzstd")
if not unzstd:
url = rctx.attr.zstd_url.format(version = rctx.attr.zstd_version)
rctx.download_and_extract(
url = url,
sha256 = rctx.attr.zstd_sha256,
)
working_directory = "zstd-{version}".format(version = rctx.attr.zstd_version)
make_result = rctx.execute(
["make", "--jobs=4"],
timeout = 600,
quiet = True,
working_directory = working_directory,
)
if make_result.return_code:
fail_msg = (
"Failed to compile 'zstd' from source for use in Python interpreter extraction. " +
"'make' error message: {}".format(make_result.stderr)
)
fail(fail_msg)
zstd = "{working_directory}/zstd".format(working_directory = working_directory)
unzstd = "./unzstd"
rctx.symlink(zstd, unzstd)
exec_result = rctx.execute([
"tar",
"--extract",
"--strip-components=2",
"--use-compress-program={unzstd}".format(unzstd = unzstd),
"--file={}".format(release_filename),
])
if exec_result.return_code:
fail_msg = (
"Failed to extract Python interpreter from '{}'. ".format(release_filename) +
"'tar' error message: {}".format(exec_result.stderr)
)
fail(fail_msg)
else:
rctx.download_and_extract(
url = urls,
sha256 = rctx.attr.sha256,
stripPrefix = rctx.attr.strip_prefix,
)
patches = rctx.attr.patches
if patches:
for patch in patches:
# Should take the strip as an attr, but this is fine for the moment
rctx.patch(patch, strip = 1)
# Write distutils.cfg to the Python installation.
if "windows" in rctx.os.name:
distutils_path = "Lib/distutils/distutils.cfg"
else:
distutils_path = "lib/python{}/distutils/distutils.cfg".format(python_short_version)
if rctx.attr.distutils:
rctx.file(distutils_path, rctx.read(rctx.attr.distutils))
elif rctx.attr.distutils_content:
rctx.file(distutils_path, rctx.attr.distutils_content)
# Make the Python installation read-only.
if not rctx.attr.ignore_root_user_error:
if "windows" not in rctx.os.name:
lib_dir = "lib" if "windows" not in platform else "Lib"
exec_result = rctx.execute(["chmod", "-R", "ugo-w", lib_dir])
if exec_result.return_code != 0:
fail_msg = "Failed to make interpreter installation read-only. 'chmod' error msg: {}".format(
exec_result.stderr,
)
fail(fail_msg)
exec_result = rctx.execute(["touch", "{}/.test".format(lib_dir)])
if exec_result.return_code == 0:
exec_result = rctx.execute(["id", "-u"])
if exec_result.return_code != 0:
fail("Could not determine current user ID. 'id -u' error msg: {}".format(
exec_result.stderr,
))
uid = int(exec_result.stdout.strip())
if uid == 0:
fail("The current user is root, please run as non-root when using the hermetic Python interpreter. See https://github.com/bazelbuild/rules_python/pull/713.")
else:
fail("The current user has CAP_DAC_OVERRIDE set, please drop this capability when using the hermetic Python interpreter. See https://github.com/bazelbuild/rules_python/pull/713.")
python_bin = "python.exe" if ("windows" in platform) else "bin/python3"
glob_include = []
glob_exclude = [
"**/* *", # Bazel does not support spaces in file names.
# Unused shared libraries. `python` executable and the `:libpython` target
# depend on `libpython{python_version}.so.1.0`.
"lib/libpython{python_version}.so",
# static libraries
"lib/**/*.a",
# tests for the standard libraries.
"lib/python{python_version}/**/test/**",
"lib/python{python_version}/**/tests/**",
]
if rctx.attr.ignore_root_user_error:
glob_exclude += [
# These pycache files are created on first use of the associated python files.
# Exclude them from the glob because otherwise between the first time and second time a python toolchain is used,"
# the definition of this filegroup will change, and depending rules will get invalidated."
# See https://github.com/bazelbuild/rules_python/issues/1008 for unconditionally adding these to toolchains so we can stop ignoring them."
"**/__pycache__/*.pyc",
"**/__pycache__/*.pyo",
]
if "windows" in platform:
glob_include += [
"*.exe",
"*.dll",
"bin/**",
"DLLs/**",
"extensions/**",
"include/**",
"Lib/**",
"libs/**",
"Scripts/**",
"share/**",
]
else:
glob_include += [
"bin/**",
"extensions/**",
"include/**",
"lib/**",
"libs/**",
"share/**",
]
if rctx.attr.coverage_tool:
if "windows" in rctx.os.name:
coverage_tool = None
else:
coverage_tool = '"{}"'.format(rctx.attr.coverage_tool)
coverage_attr_text = """\
coverage_tool = select({{
":coverage_enabled": {coverage_tool},
"//conditions:default": None
}}),
""".format(coverage_tool = coverage_tool)
else:
coverage_attr_text = " # coverage_tool attribute not supported by this Bazel version"
build_content = """\
# Generated by python/repositories.bzl
load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")
package(default_visibility = ["//visibility:public"])
filegroup(
name = "files",
srcs = glob(
include = {glob_include},
# Platform-agnostic filegroup can't match on all patterns.
allow_empty = True,
exclude = {glob_exclude},
),
)
cc_import(
name = "interface",
interface_library = "libs/python{python_version_nodot}.lib",
system_provided = True,
)
filegroup(
name = "includes",
srcs = glob(["include/**/*.h"]),
)
cc_library(
name = "python_headers",
deps = select({{
"@bazel_tools//src/conditions:windows": [":interface"],
"//conditions:default": None,
}}),
hdrs = [":includes"],
includes = [
"include",
"include/python{python_version}",
"include/python{python_version}m",
],
)
cc_library(
name = "libpython",
hdrs = [":includes"],
srcs = select({{
"@platforms//os:windows": ["python3.dll", "libs/python{python_version_nodot}.lib"],
"@platforms//os:macos": ["lib/libpython{python_version}.dylib"],
"@platforms//os:linux": ["lib/libpython{python_version}.so", "lib/libpython{python_version}.so.1.0"],
}}),
)
exports_files(["python", "{python_path}"])
# Used to only download coverage toolchain when the coverage is collected by
# bazel.
config_setting(
name = "coverage_enabled",
values = {{"collect_code_coverage": "true"}},
visibility = ["//visibility:private"],
)
py_runtime(
name = "py3_runtime",
files = [":files"],
{coverage_attr}
interpreter = "{python_path}",
python_version = "PY3",
)
py_runtime_pair(
name = "python_runtimes",
py2_runtime = None,
py3_runtime = ":py3_runtime",
)
""".format(
glob_exclude = repr(glob_exclude),
glob_include = repr(glob_include),
python_path = python_bin,
python_version = python_short_version,
python_version_nodot = python_short_version.replace(".", ""),
coverage_attr = coverage_attr_text,
)
rctx.delete("python")
rctx.symlink(python_bin, "python")
rctx.file(STANDALONE_INTERPRETER_FILENAME, "# File intentionally left blank. Indicates that this is an interpreter repo created by rules_python.")
rctx.file("BUILD.bazel", build_content)
attrs = {
"coverage_tool": rctx.attr.coverage_tool,
"distutils": rctx.attr.distutils,
"distutils_content": rctx.attr.distutils_content,
"ignore_root_user_error": rctx.attr.ignore_root_user_error,
"name": rctx.attr.name,
"patches": rctx.attr.patches,
"platform": platform,
"python_version": python_version,
"release_filename": release_filename,
"sha256": rctx.attr.sha256,
"strip_prefix": rctx.attr.strip_prefix,
}
if rctx.attr.url:
attrs["url"] = rctx.attr.url
else:
attrs["urls"] = urls
return attrs
python_repository = repository_rule(
_python_repository_impl,
doc = "Fetches the external tools needed for the Python toolchain.",
attrs = {
"coverage_tool": attr.label(
# Mirrors the definition at
# https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/common/python/py_runtime_rule.bzl
allow_files = False,
doc = """
This is a target to use for collecting code coverage information from `py_binary`
and `py_test` targets.
If set, the target must either produce a single file or be an executable target.
The path to the single file, or the executable if the target is executable,
determines the entry point for the python coverage tool. The target and its
runfiles will be added to the runfiles when coverage is enabled.
The entry point for the tool must be loadable by a Python interpreter (e.g. a
`.py` or `.pyc` file). It must accept the command line arguments
of coverage.py (https://coverage.readthedocs.io), at least including
the `run` and `lcov` subcommands.
For more information see the official bazel docs
(https://bazel.build/reference/be/python#py_runtime.coverage_tool).
""",
),
"distutils": attr.label(
allow_single_file = True,
doc = "A distutils.cfg file to be included in the Python installation. " +
"Either distutils or distutils_content can be specified, but not both.",
mandatory = False,
),
"distutils_content": attr.string(
doc = "A distutils.cfg file content to be included in the Python installation. " +
"Either distutils or distutils_content can be specified, but not both.",
mandatory = False,
),
"ignore_root_user_error": attr.bool(
default = False,
doc = "Whether the check for root should be ignored or not. This causes cache misses with .pyc files.",
mandatory = False,
),
"patches": attr.label_list(
doc = "A list of patch files to apply to the unpacked interpreter",
mandatory = False,
),
"platform": attr.string(
doc = "The platform name for the Python interpreter tarball.",
mandatory = True,
values = PLATFORMS.keys(),
),
"python_version": attr.string(
doc = "The Python version.",
mandatory = True,
),
"release_filename": attr.string(
doc = "The filename of the interpreter to be downloaded",
mandatory = True,
),
"sha256": attr.string(
doc = "The SHA256 integrity hash for the Python interpreter tarball.",
mandatory = True,
),
"strip_prefix": attr.string(
doc = "A directory prefix to strip from the extracted files.",
),
"url": attr.string(
doc = "The URL of the interpreter to download. Exactly one of url and urls must be set.",
),
"urls": attr.string_list(
doc = "The URL of the interpreter to download. Exactly one of url and urls must be set.",
),
"zstd_sha256": attr.string(
default = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0",
),
"zstd_url": attr.string(
default = "https://github.com/facebook/zstd/releases/download/v{version}/zstd-{version}.tar.gz",
),
"zstd_version": attr.string(
default = "1.5.2",
),
},
)
# Wrapper macro around everything above, this is the primary API.
def python_register_toolchains(
name,
python_version,
distutils = None,
distutils_content = None,
register_toolchains = True,
register_coverage_tool = False,
set_python_version_constraint = False,
tool_versions = TOOL_VERSIONS,
bzlmod = False,
**kwargs):
"""Convenience macro for users which does typical setup.
- Create a repository for each built-in platform like "python_linux_amd64" -
this repository is lazily fetched when Python is needed for that platform.
- Create a repository exposing toolchains for each platform like
"python_platforms".
- Register a toolchain pointing at each platform.
Users can avoid this macro and do these steps themselves, if they want more
control.
Args:
name: base name for all created repos, like "python38".
python_version: the Python version.
distutils: see the distutils attribute in the python_repository repository rule.
distutils_content: see the distutils_content attribute in the python_repository repository rule.
register_toolchains: Whether or not to register the downloaded toolchains.
register_coverage_tool: Whether or not to register the downloaded coverage tool to the toolchains.
NOTE: Coverage support using the toolchain is only supported in Bazel 6 and higher.
set_python_version_constraint: When set to true, target_compatible_with for the toolchains will include a version constraint.
tool_versions: a dict containing a mapping of version with SHASUM and platform info. If not supplied, the defaults
in python/versions.bzl will be used.
bzlmod: Whether this rule is being run under a bzlmod module extension.
**kwargs: passed to each python_repositories call.
"""
base_url = kwargs.pop("base_url", DEFAULT_RELEASE_BASE_URL)
if python_version in MINOR_MAPPING:
python_version = MINOR_MAPPING[python_version]
toolchain_repo_name = "{name}_toolchains".format(name = name)
# When using unreleased Bazel versions, the version is an empty string
if native.bazel_version:
bazel_major = int(native.bazel_version.split(".")[0])
if bazel_major < 6:
if register_coverage_tool:
# buildifier: disable=print
print((
"WARNING: ignoring register_coverage_tool=True when " +
"registering @{name}: Bazel 6+ required, got {version}"
).format(
name = name,
version = native.bazel_version,
))
register_coverage_tool = False
for platform in PLATFORMS.keys():
sha256 = tool_versions[python_version]["sha256"].get(platform, None)
if not sha256:
continue
(release_filename, urls, strip_prefix, patches) = get_release_info(platform, python_version, base_url, tool_versions)
# allow passing in a tool version
coverage_tool = None
coverage_tool = tool_versions[python_version].get("coverage_tool", {}).get(platform, None)
if register_coverage_tool and coverage_tool == None:
coverage_tool = coverage_dep(
name = "{name}_{platform}_coverage".format(
name = name,
platform = platform,
),
python_version = python_version,
platform = platform,
visibility = ["@@{name}_{platform}//:__subpackages__".format(
name = name,
platform = platform,
)],
install = not bzlmod,
)
python_repository(
name = "{name}_{platform}".format(
name = name,
platform = platform,
),
sha256 = sha256,
patches = patches,
platform = platform,
python_version = python_version,
release_filename = release_filename,
urls = urls,
distutils = distutils,
distutils_content = distutils_content,
strip_prefix = strip_prefix,
coverage_tool = coverage_tool,
**kwargs
)
if register_toolchains:
native.register_toolchains("@{toolchain_repo_name}//:{platform}_toolchain".format(
toolchain_repo_name = toolchain_repo_name,
platform = platform,
))
toolchains_repo(
name = toolchain_repo_name,
python_version = python_version,
set_python_version_constraint = set_python_version_constraint,
user_repository_name = name,
)
toolchain_aliases(
name = name,
python_version = python_version,
user_repository_name = name,
)
def python_register_multi_toolchains(
name,
python_versions,
default_version = None,
**kwargs):
"""Convenience macro for registering multiple Python toolchains.
Args:
name: base name for each name in python_register_toolchains call.
python_versions: the Python version.
default_version: the default Python version. If not set, the first version in
python_versions is used.
**kwargs: passed to each python_register_toolchains call.
"""
if len(python_versions) == 0:
fail("python_versions must not be empty")
if not default_version:
default_version = python_versions.pop(0)
for python_version in python_versions:
if python_version == default_version:
# We register the default version lastly so that it's not picked first when --platforms
# is set with a constraint during toolchain resolution. This is due to the fact that
# Bazel will match the unconstrained toolchain if we register it before the constrained
# ones.
continue
python_register_toolchains(
name = name + "_" + python_version.replace(".", "_"),
python_version = python_version,
set_python_version_constraint = True,
**kwargs
)
python_register_toolchains(
name = name + "_" + default_version.replace(".", "_"),
python_version = default_version,
set_python_version_constraint = False,
**kwargs
)
multi_toolchain_aliases(
name = name,
python_versions = {
python_version: name + "_" + python_version.replace(".", "_")
for python_version in (python_versions + [default_version])
},
)
rules_python-0.22.1/python/runfiles/ 0000775 0000000 0000000 00000000000 14540404546 0017505 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/runfiles/BUILD.bazel 0000664 0000000 0000000 00000003372 14540404546 0021370 0 ustar 00root root 0000000 0000000 # Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("//python:defs.bzl", "py_library")
load("//python:packaging.bzl", "py_wheel")
filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)
py_library(
name = "runfiles",
srcs = [
"__init__.py",
"runfiles.py",
],
visibility = ["//visibility:public"],
)
# This can be manually tested by running tests/runfiles/runfiles_wheel_integration_test.sh
# We ought to have an automated integration test for it, too.
# see https://github.com/bazelbuild/rules_python/issues/1002
py_wheel(
name = "wheel",
# From https://pypi.org/classifiers/
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
],
description_file = "README.rst",
dist_folder = "dist",
distribution = "bazel_runfiles",
homepage = "https://github.com/bazelbuild/rules_python",
strip_path_prefixes = ["python"],
twine = "@publish_deps_twine//:pkg",
# this can be replaced by building with --stamp --embed_label=1.2.3
version = "{BUILD_EMBED_LABEL}",
visibility = ["//visibility:public"],
deps = [":runfiles"],
)
rules_python-0.22.1/python/runfiles/README.rst 0000664 0000000 0000000 00000003450 14540404546 0021176 0 ustar 00root root 0000000 0000000 bazel-runfiles library
======================
This is a Bazel Runfiles lookup library for Bazel-built Python binaries and tests.
Learn about runfiles: read `Runfiles guide `_
or watch `Fabian's BazelCon talk `_.
Typical Usage
-------------
1. Add the 'bazel-runfiles' dependency along with other third-party dependencies, for example in your
``requirements.txt`` file.
2. Depend on this runfiles library from your build rule, like you would other third-party libraries::
py_binary(
name = "my_binary",
...
deps = [requirement("bazel-runfiles")],
)
3. Import the runfiles library::
import runfiles # not "from runfiles import runfiles"
4. Create a Runfiles object and use rlocation to look up runfile paths::
r = runfiles.Create()
...
with open(r.Rlocation("my_workspace/path/to/my/data.txt"), "r") as f:
contents = f.readlines()
...
The code above creates a manifest- or directory-based implementations based
on the environment variables in os.environ. See `Create()` for more info.
If you want to explicitly create a manifest- or directory-based
implementations, you can do so as follows::
r1 = runfiles.CreateManifestBased("path/to/foo.runfiles_manifest")
r2 = runfiles.CreateDirectoryBased("path/to/foo.runfiles/")
If you want to start subprocesses, and the subprocess can't automatically
find the correct runfiles directory, you can explicitly set the right
environment variables for them::
import subprocess
import runfiles
r = runfiles.Create()
env = {}
...
env.update(r.EnvVars())
p = subprocess.Popen([r.Rlocation("path/to/binary")], env, ...) rules_python-0.22.1/python/runfiles/__init__.py 0000664 0000000 0000000 00000001164 14540404546 0021620 0 ustar 00root root 0000000 0000000 # Copyright 2023 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from .runfiles import *
rules_python-0.22.1/python/runfiles/runfiles.py 0000664 0000000 0000000 00000034514 14540404546 0021715 0 ustar 00root root 0000000 0000000 # Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Runfiles lookup library for Bazel-built Python binaries and tests.
See README.md for usage instructions.
"""
import inspect
import os
import posixpath
import sys
if False:
# Mypy needs these symbols imported, but since they only exist in python 3.5+,
# this import may fail at runtime. Luckily mypy can follow this conditional import.
from typing import Callable, Dict, Optional, Tuple, Union
def CreateManifestBased(manifest_path):
# type: (str) -> _Runfiles
return _Runfiles(_ManifestBased(manifest_path))
def CreateDirectoryBased(runfiles_dir_path):
# type: (str) -> _Runfiles
return _Runfiles(_DirectoryBased(runfiles_dir_path))
def Create(env=None):
# type: (Optional[Dict[str, str]]) -> Optional[_Runfiles]
"""Returns a new `Runfiles` instance.
The returned object is either:
- manifest-based, meaning it looks up runfile paths from a manifest file, or
- directory-based, meaning it looks up runfile paths under a given directory
path
If `env` contains "RUNFILES_MANIFEST_FILE" with non-empty value, this method
returns a manifest-based implementation. The object eagerly reads and caches
the whole manifest file upon instantiation; this may be relevant for
performance consideration.
Otherwise, if `env` contains "RUNFILES_DIR" with non-empty value (checked in
this priority order), this method returns a directory-based implementation.
If neither cases apply, this method returns null.
Args:
env: {string: string}; optional; the map of environment variables. If None,
this function uses the environment variable map of this process.
Raises:
IOError: if some IO error occurs.
"""
env_map = os.environ if env is None else env
manifest = env_map.get("RUNFILES_MANIFEST_FILE")
if manifest:
return CreateManifestBased(manifest)
directory = env_map.get("RUNFILES_DIR")
if directory:
return CreateDirectoryBased(directory)
return None
class _Runfiles(object):
"""Returns the runtime location of runfiles.
Runfiles are data-dependencies of Bazel-built binaries and tests.
"""
def __init__(self, strategy):
# type: (Union[_ManifestBased, _DirectoryBased]) -> None
self._strategy = strategy
self._python_runfiles_root = _FindPythonRunfilesRoot()
self._repo_mapping = _ParseRepoMapping(
strategy.RlocationChecked("_repo_mapping")
)
def Rlocation(self, path, source_repo=None):
# type: (str, Optional[str]) -> Optional[str]
"""Returns the runtime path of a runfile.
Runfiles are data-dependencies of Bazel-built binaries and tests.
The returned path may not be valid. The caller should check the path's
validity and that the path exists.
The function may return None. In that case the caller can be sure that the
rule does not know about this data-dependency.
Args:
path: string; runfiles-root-relative path of the runfile
source_repo: string; optional; the canonical name of the repository
whose repository mapping should be used to resolve apparent to
canonical repository names in `path`. If `None` (default), the
repository mapping of the repository containing the caller of this
method is used. Explicitly setting this parameter should only be
necessary for libraries that want to wrap the runfiles library. Use
`CurrentRepository` to obtain canonical repository names.
Returns:
the path to the runfile, which the caller should check for existence, or
None if the method doesn't know about this runfile
Raises:
TypeError: if `path` is not a string
ValueError: if `path` is None or empty, or it's absolute or not normalized
"""
if not path:
raise ValueError()
if not isinstance(path, str):
raise TypeError()
if (
path.startswith("../")
or "/.." in path
or path.startswith("./")
or "/./" in path
or path.endswith("/.")
or "//" in path
):
raise ValueError('path is not normalized: "%s"' % path)
if path[0] == "\\":
raise ValueError('path is absolute without a drive letter: "%s"' % path)
if os.path.isabs(path):
return path
if source_repo is None and self._repo_mapping:
# Look up runfiles using the repository mapping of the caller of the
# current method. If the repo mapping is empty, determining this
# name is not necessary.
source_repo = self.CurrentRepository(frame=2)
# Split off the first path component, which contains the repository
# name (apparent or canonical).
target_repo, _, remainder = path.partition("/")
if not remainder or (source_repo, target_repo) not in self._repo_mapping:
# One of the following is the case:
# - not using Bzlmod, so the repository mapping is empty and
# apparent and canonical repository names are the same
# - target_repo is already a canonical repository name and does not
# have to be mapped.
# - path did not contain a slash and referred to a root symlink,
# which also should not be mapped.
return self._strategy.RlocationChecked(path)
# target_repo is an apparent repository name. Look up the corresponding
# canonical repository name with respect to the current repository,
# identified by its canonical name.
target_canonical = self._repo_mapping[(source_repo, target_repo)]
return self._strategy.RlocationChecked(target_canonical + "/" + remainder)
def EnvVars(self):
# type: () -> Dict[str, str]
"""Returns environment variables for subprocesses.
The caller should set the returned key-value pairs in the environment of
subprocesses in case those subprocesses are also Bazel-built binaries that
need to use runfiles.
Returns:
{string: string}; a dict; keys are environment variable names, values are
the values for these environment variables
"""
return self._strategy.EnvVars()
def CurrentRepository(self, frame=1):
# type: (int) -> str
"""Returns the canonical name of the caller's Bazel repository.
For example, this function returns '' (the empty string) when called
from the main repository and a string of the form
'rules_python~0.13.0` when called from code in the repository
corresponding to the rules_python Bazel module.
More information about the difference between canonical repository
names and the `@repo` part of labels is available at:
https://bazel.build/build/bzlmod#repository-names
NOTE: This function inspects the callstack to determine where in the
runfiles the caller is located to determine which repository it came
from. This may fail or produce incorrect results depending on who the
caller is, for example if it is not represented by a Python source
file. Use the `frame` argument to control the stack lookup.
Args:
frame: int; the stack frame to return the repository name for.
Defaults to 1, the caller of the CurrentRepository function.
Returns:
The canonical name of the Bazel repository containing the file
containing the frame-th caller of this function
Raises:
ValueError: if the caller cannot be determined or the caller's file
path is not contained in the Python runfiles tree
"""
# pylint:disable=protected-access # for sys._getframe
# pylint:disable=raise-missing-from # we're still supporting Python 2
try:
caller_path = inspect.getfile(sys._getframe(frame))
except (TypeError, ValueError):
raise ValueError("failed to determine caller's file path")
caller_runfiles_path = os.path.relpath(caller_path, self._python_runfiles_root)
if caller_runfiles_path.startswith(".." + os.path.sep):
raise ValueError(
"{} does not lie under the runfiles root {}".format(
caller_path, self._python_runfiles_root
)
)
caller_runfiles_directory = caller_runfiles_path[
: caller_runfiles_path.find(os.path.sep)
]
# With Bzlmod, the runfiles directory of the main repository is always
# named "_main". Without Bzlmod, the value returned by this function is
# never used, so we just assume Bzlmod is enabled.
if caller_runfiles_directory == "_main":
# The canonical name of the main repository (also known as the
# workspace) is the empty string.
return ""
# For all other repositories, the name of the runfiles directory is the
# canonical name.
return caller_runfiles_directory
def _FindPythonRunfilesRoot():
# type: () -> str
"""Finds the root of the Python runfiles tree."""
root = __file__
# Walk up our own runfiles path to the root of the runfiles tree from which
# the current file is being run. This path coincides with what the Bazel
# Python stub sets up as sys.path[0]. Since that entry can be changed at
# runtime, we rederive it here.
for _ in range("rules_python/python/runfiles/runfiles.py".count("/") + 1):
root = os.path.dirname(root)
return root
def _ParseRepoMapping(repo_mapping_path):
# type: (Optional[str]) -> Dict[Tuple[str, str], str]
"""Parses the repository mapping manifest."""
# If the repository mapping file can't be found, that is not an error: We
# might be running without Bzlmod enabled or there may not be any runfiles.
# In this case, just apply an empty repo mapping.
if not repo_mapping_path:
return {}
try:
with open(repo_mapping_path, "r") as f:
content = f.read()
except FileNotFoundError:
return {}
repo_mapping = {}
for line in content.split("\n"):
if not line:
# Empty line following the last line break
break
current_canonical, target_local, target_canonical = line.split(",")
repo_mapping[(current_canonical, target_local)] = target_canonical
return repo_mapping
class _ManifestBased(object):
"""`Runfiles` strategy that parses a runfiles-manifest to look up runfiles."""
def __init__(self, path):
# type: (str) -> None
if not path:
raise ValueError()
if not isinstance(path, str):
raise TypeError()
self._path = path
self._runfiles = _ManifestBased._LoadRunfiles(path)
def RlocationChecked(self, path):
# type: (str) -> Optional[str]
"""Returns the runtime path of a runfile."""
exact_match = self._runfiles.get(path)
if exact_match:
return exact_match
# If path references a runfile that lies under a directory that
# itself is a runfile, then only the directory is listed in the
# manifest. Look up all prefixes of path in the manifest and append
# the relative path from the prefix to the looked up path.
prefix_end = len(path)
while True:
prefix_end = path.rfind("/", 0, prefix_end - 1)
if prefix_end == -1:
return None
prefix_match = self._runfiles.get(path[0:prefix_end])
if prefix_match:
return prefix_match + "/" + path[prefix_end + 1 :]
@staticmethod
def _LoadRunfiles(path):
# type: (str) -> Dict[str, str]
"""Loads the runfiles manifest."""
result = {}
with open(path, "r") as f:
for line in f:
line = line.strip()
if line:
tokens = line.split(" ", 1)
if len(tokens) == 1:
result[line] = line
else:
result[tokens[0]] = tokens[1]
return result
def _GetRunfilesDir(self):
# type: () -> str
if self._path.endswith("/MANIFEST") or self._path.endswith("\\MANIFEST"):
return self._path[: -len("/MANIFEST")]
elif self._path.endswith(".runfiles_manifest"):
return self._path[: -len("_manifest")]
else:
return ""
def EnvVars(self):
# type: () -> Dict[str, str]
directory = self._GetRunfilesDir()
return {
"RUNFILES_MANIFEST_FILE": self._path,
"RUNFILES_DIR": directory,
# TODO(laszlocsomor): remove JAVA_RUNFILES once the Java launcher can
# pick up RUNFILES_DIR.
"JAVA_RUNFILES": directory,
}
class _DirectoryBased(object):
"""`Runfiles` strategy that appends runfiles paths to the runfiles root."""
def __init__(self, path):
# type: (str) -> None
if not path:
raise ValueError()
if not isinstance(path, str):
raise TypeError()
self._runfiles_root = path
def RlocationChecked(self, path):
# type: (str) -> str
# Use posixpath instead of os.path, because Bazel only creates a runfiles
# tree on Unix platforms, so `Create()` will only create a directory-based
# runfiles strategy on those platforms.
return posixpath.join(self._runfiles_root, path)
def EnvVars(self):
# type: () -> Dict[str, str]
return {
"RUNFILES_DIR": self._runfiles_root,
# TODO(laszlocsomor): remove JAVA_RUNFILES once the Java launcher can
# pick up RUNFILES_DIR.
"JAVA_RUNFILES": self._runfiles_root,
}
rules_python-0.22.1/python/tests/ 0000775 0000000 0000000 00000000000 14540404546 0017020 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/tests/toolchains/ 0000775 0000000 0000000 00000000000 14540404546 0021163 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/tests/toolchains/BUILD.bazel 0000664 0000000 0000000 00000001364 14540404546 0023045 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load(":defs.bzl", "acceptance_tests")
load(":versions_test.bzl", "versions_test_suite")
versions_test_suite(name = "versions_test")
acceptance_tests()
rules_python-0.22.1/python/tests/toolchains/defs.bzl 0000664 0000000 0000000 00000015120 14540404546 0022614 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module contains the definition for the toolchains testing rules.
"""
load("//python:versions.bzl", "PLATFORMS", "TOOL_VERSIONS")
_WINDOWS_RUNNER_TEMPLATE = """\
@ECHO OFF
set PATHEXT=.COM;.EXE;.BAT
powershell.exe -c "& ./{interpreter_path} {run_acceptance_test_py}"
"""
def _acceptance_test_impl(ctx):
workspace = ctx.actions.declare_file("/".join([ctx.attr.python_version, "WORKSPACE"]))
ctx.actions.expand_template(
template = ctx.file._workspace_tmpl,
output = workspace,
substitutions = {"%python_version%": ctx.attr.python_version},
)
build_bazel = ctx.actions.declare_file("/".join([ctx.attr.python_version, "BUILD.bazel"]))
ctx.actions.expand_template(
template = ctx.file._build_bazel_tmpl,
output = build_bazel,
substitutions = {"%python_version%": ctx.attr.python_version},
)
python_version_test = ctx.actions.declare_file("/".join([ctx.attr.python_version, "python_version_test.py"]))
ctx.actions.symlink(
target_file = ctx.file._python_version_test,
output = python_version_test,
)
run_acceptance_test_py = ctx.actions.declare_file("/".join([ctx.attr.python_version, "run_acceptance_test.py"]))
ctx.actions.expand_template(
template = ctx.file._run_acceptance_test_tmpl,
output = run_acceptance_test_py,
substitutions = {
"%is_windows%": str(ctx.attr.is_windows),
"%python_version%": ctx.attr.python_version,
"%test_location%": "/".join([ctx.attr.test_location, ctx.attr.python_version]),
},
)
toolchain = ctx.toolchains["@bazel_tools//tools/python:toolchain_type"]
py3_runtime = toolchain.py3_runtime
interpreter_path = py3_runtime.interpreter_path
if not interpreter_path:
interpreter_path = py3_runtime.interpreter.short_path
if ctx.attr.is_windows:
executable = ctx.actions.declare_file("run_test_{}.bat".format(ctx.attr.python_version))
ctx.actions.write(
output = executable,
content = _WINDOWS_RUNNER_TEMPLATE.format(
interpreter_path = interpreter_path.replace("../", "external/"),
run_acceptance_test_py = run_acceptance_test_py.short_path,
),
is_executable = True,
)
else:
executable = ctx.actions.declare_file("run_test_{}.sh".format(ctx.attr.python_version))
ctx.actions.write(
output = executable,
content = "exec '{interpreter_path}' '{run_acceptance_test_py}'".format(
interpreter_path = interpreter_path,
run_acceptance_test_py = run_acceptance_test_py.short_path,
),
is_executable = True,
)
files = [
build_bazel,
executable,
python_version_test,
run_acceptance_test_py,
workspace,
] + ctx.files._distribution
return [DefaultInfo(
executable = executable,
files = depset(
direct = files,
transitive = [py3_runtime.files],
),
runfiles = ctx.runfiles(
files = files,
transitive_files = py3_runtime.files,
),
)]
_acceptance_test = rule(
implementation = _acceptance_test_impl,
doc = "A rule for the toolchain acceptance tests.",
attrs = {
"is_windows": attr.bool(
doc = "(Provided by the macro) Whether this is running under Windows or not.",
mandatory = True,
),
"python_version": attr.string(
doc = "The Python version to be used when requesting the toolchain.",
mandatory = True,
),
"test_location": attr.string(
doc = "(Provided by the macro) The value of native.package_name().",
mandatory = True,
),
"_build_bazel_tmpl": attr.label(
doc = "The BUILD.bazel template.",
allow_single_file = True,
default = Label("//python/tests/toolchains/workspace_template:BUILD.bazel.tmpl"),
),
"_distribution": attr.label(
doc = "The rules_python source distribution.",
default = Label("//:distribution"),
),
"_python_version_test": attr.label(
doc = "The python_version_test.py used to test the Python version.",
allow_single_file = True,
default = Label("//python/tests/toolchains/workspace_template:python_version_test.py"),
),
"_run_acceptance_test_tmpl": attr.label(
doc = "The run_acceptance_test.py template.",
allow_single_file = True,
default = Label("//python/tests/toolchains:run_acceptance_test.py.tmpl"),
),
"_workspace_tmpl": attr.label(
doc = "The WORKSPACE template.",
allow_single_file = True,
default = Label("//python/tests/toolchains/workspace_template:WORKSPACE.tmpl"),
),
},
test = True,
toolchains = ["@bazel_tools//tools/python:toolchain_type"],
)
def acceptance_test(python_version, **kwargs):
_acceptance_test(
is_windows = select({
"@bazel_tools//src/conditions:host_windows": True,
"//conditions:default": False,
}),
python_version = python_version,
test_location = native.package_name(),
**kwargs
)
# buildifier: disable=unnamed-macro
def acceptance_tests():
"""Creates a matrix of acceptance_test targets for all the toolchains.
"""
for python_version in TOOL_VERSIONS.keys():
for platform, meta in PLATFORMS.items():
if platform not in TOOL_VERSIONS[python_version]["sha256"]:
continue
acceptance_test(
name = "python_{python_version}_{platform}_test".format(
python_version = python_version.replace(".", "_"),
platform = platform,
),
python_version = python_version,
target_compatible_with = meta.compatible_with,
tags = ["acceptance-test"],
)
rules_python-0.22.1/python/tests/toolchains/run_acceptance_test.py.tmpl 0000664 0000000 0000000 00000004716 14540404546 0026531 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import subprocess
import unittest
class TestPythonVersion(unittest.TestCase):
@classmethod
def setUpClass(cls):
os.chdir("%test_location%")
rules_python_path = os.path.join(os.environ["TEST_SRCDIR"], "rules_python")
test_tmpdir = os.environ["TEST_TMPDIR"]
if %is_windows%:
home = os.path.join(test_tmpdir, "HOME")
os.mkdir(home)
os.environ["HOME"] = home
local_app_data = os.path.join(test_tmpdir, "LocalAppData")
os.mkdir(local_app_data)
os.environ["LocalAppData"] = local_app_data
# Bazelisk requires a cache directory be set
os.environ["XDG_CACHE_HOME"] = os.path.join(test_tmpdir, "xdg-cache-home")
# Unset this so this works when called by Bazel's latest Bazel build
# pipeline. It sets the following combination, which interfere with each other:
# * --sandbox_tmpfs_path=/tmp
# * --test_env=USE_BAZEL_VERSION
# * USE_BAZEL_VERSION=/tmp/
os.environ.pop("USE_BAZEL_VERSION", None)
with open(".bazelrc", "w") as bazelrc:
bazelrc.write(
os.linesep.join(
[
'build --override_repository rules_python="{}"'.format(
rules_python_path.replace("\\", "/")
),
"build --test_output=errors",
]
)
)
def test_match_toolchain(self):
output = subprocess.check_output(
f"bazel run @python//:python3 -- --version",
shell = True, # Shell needed to look up via PATH
text=True,
).strip()
self.assertEqual(output, "Python %python_version%")
subprocess.run("bazel test //...", shell=True, check=True)
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/python/tests/toolchains/versions_test.bzl 0000664 0000000 0000000 00000003522 14540404546 0024605 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit tests for starlark helpers
See https://docs.bazel.build/versions/main/skylark/testing.html#for-testing-starlark-utilities
"""
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS")
required_platforms = [
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
]
def _smoke_test_impl(ctx):
env = unittest.begin(ctx)
for version in TOOL_VERSIONS.keys():
platforms = TOOL_VERSIONS[version]["sha256"]
for required_platform in required_platforms:
asserts.true(
env,
required_platform in platforms.keys(),
"Missing platform {} for version {}".format(required_platform, version),
)
for minor in MINOR_MAPPING:
version = MINOR_MAPPING[minor]
asserts.true(
env,
version in TOOL_VERSIONS.keys(),
"Missing version {} in TOOL_VERSIONS".format(version),
)
return unittest.end(env)
# The unittest library requires that we export the test cases as named test rules,
# but their names are arbitrary and don't appear anywhere.
_t0_test = unittest.make(_smoke_test_impl)
def versions_test_suite(name):
unittest.suite(name, _t0_test)
rules_python-0.22.1/python/tests/toolchains/workspace_template/ 0000775 0000000 0000000 00000000000 14540404546 0025054 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/python/tests/toolchains/workspace_template/BUILD.bazel 0000664 0000000 0000000 00000000137 14540404546 0026733 0 ustar 00root root 0000000 0000000 exports_files([
"BUILD.bazel.tmpl",
"WORKSPACE.tmpl",
"python_version_test.py",
])
rules_python-0.22.1/python/tests/toolchains/workspace_template/BUILD.bazel.tmpl 0000664 0000000 0000000 00000000310 14540404546 0027677 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_test")
py_test(
name = "python_version_test",
srcs = ["python_version_test.py"],
env = {
"PYTHON_VERSION": "%python_version%",
},
)
rules_python-0.22.1/python/tests/toolchains/workspace_template/README.md 0000664 0000000 0000000 00000000177 14540404546 0026340 0 ustar 00root root 0000000 0000000 # Toolchains testing WORKSPACE template
This directory contains templates for generating acceptance tests for the
toolchains.
rules_python-0.22.1/python/tests/toolchains/workspace_template/WORKSPACE.tmpl 0000664 0000000 0000000 00000002572 14540404546 0027316 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
workspace(name = "workspace_test")
local_repository(
name = "rules_python",
path = "",
)
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
name = "python",
python_version = "%python_version%",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_skylib",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
],
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
rules_python-0.22.1/python/tests/toolchains/workspace_template/python_version_test.py 0000664 0000000 0000000 00000001531 14540404546 0031553 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import platform
import unittest
class TestPythonVersion(unittest.TestCase):
def test_match_toolchain(self):
self.assertEqual(platform.python_version(), os.getenv("PYTHON_VERSION"))
if __name__ == "__main__":
unittest.main()
rules_python-0.22.1/python/versions.bzl 0000664 0000000 0000000 00000041766 14540404546 0020255 0 ustar 00root root 0000000 0000000 # Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The Python versions we use for the toolchains.
"""
# Values returned by https://bazel.build/rules/lib/repository_os.
MACOS_NAME = "mac os"
LINUX_NAME = "linux"
WINDOWS_NAME = "windows"
DEFAULT_RELEASE_BASE_URL = "https://github.com/indygreg/python-build-standalone/releases/download"
# When updating the versions and releases, run the following command to get
# the hashes:
# bazel run //python/private:print_toolchains_checksums
#
# Note, to users looking at how to specify their tool versions, coverage_tool version for each
# interpreter can be specified by:
# "3.8.10": {
# "url": "20210506/cpython-{python_version}-{platform}-pgo+lto-20210506T0943.tar.zst",
# "sha256": {
# "x86_64-apple-darwin": "8d06bec08db8cdd0f64f4f05ee892cf2fcbc58cfb1dd69da2caab78fac420238",
# "x86_64-unknown-linux-gnu": "aec8c4c53373b90be7e2131093caa26063be6d9d826f599c935c0e1042af3355",
# },
# "coverage_tool": {
# "x86_64-apple-darwin": """,
# "x86_64-unknown-linux-gnu": """,
# },
# "strip_prefix": "python",
# },
#
# It is possible to provide lists in "url".
#
# buildifier: disable=unsorted-dict-items
TOOL_VERSIONS = {
"3.8.10": {
"url": "20210506/cpython-{python_version}-{platform}-pgo+lto-20210506T0943.tar.zst",
"sha256": {
"x86_64-apple-darwin": "8d06bec08db8cdd0f64f4f05ee892cf2fcbc58cfb1dd69da2caab78fac420238",
"x86_64-unknown-linux-gnu": "aec8c4c53373b90be7e2131093caa26063be6d9d826f599c935c0e1042af3355",
},
"strip_prefix": "python",
},
"3.8.12": {
"url": "20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "f9a3cbb81e0463d6615125964762d133387d561b226a30199f5b039b20f1d944",
# no aarch64-unknown-linux-gnu build available for 3.8.12
"x86_64-apple-darwin": "f323fbc558035c13a85ce2267d0fad9e89282268ecb810e364fff1d0a079d525",
"x86_64-pc-windows-msvc": "4658e08a00d60b1e01559b74d58ff4dd04da6df935d55f6268a15d6d0a679d74",
"x86_64-unknown-linux-gnu": "5be9c6d61e238b90dfd94755051c0d3a2d8023ebffdb4b0fa4e8fedd09a6cab6",
},
"strip_prefix": "python",
},
"3.8.13": {
"url": "20220802/cpython-{python_version}+20220802-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "ae4131253d890b013171cb5f7b03cadc585ae263719506f7b7e063a7cf6fde76",
# no aarch64-unknown-linux-gnu build available for 3.8.13
"x86_64-apple-darwin": "cd6e7c0a27daf7df00f6882eaba01490dd963f698e99aeee9706877333e0df69",
"x86_64-pc-windows-msvc": "f20643f1b3e263a56287319aea5c3888530c09ad9de3a5629b1a5d207807e6b9",
"x86_64-unknown-linux-gnu": "fb566629ccb5f76ef56d275a3f8017d683f1c20c5beb5d5f38b155ed11e16187",
},
"strip_prefix": "python",
},
"3.8.15": {
"url": "20221106/cpython-{python_version}+20221106-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "1e0a92d1a4f5e6d4a99f86b1cbf9773d703fe7fd032590f3e9c285c7a5eeb00a",
"aarch64-unknown-linux-gnu": "886ab33ced13c84bf59ce8ff79eba6448365bfcafea1bf415bd1d75e21b690aa",
"x86_64-apple-darwin": "70b57f28c2b5e1e3dd89f0d30edd5bc414e8b20195766cf328e1b26bed7890e1",
"x86_64-pc-windows-msvc": "2fdc3fa1c95f982179bbbaedae2b328197658638799b6dcb63f9f494b0de59e2",
"x86_64-unknown-linux-gnu": "e47edfb2ceaf43fc699e20c179ec428b6f3e497cf8e2dcd8e9c936d4b96b1e56",
},
"strip_prefix": "python",
},
"3.8.16": {
"url": "20230116/cpython-{python_version}+20230116-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "d1f408569d8807c1053939d7822b082a17545e363697e1ce3cfb1ee75834c7be",
"aarch64-unknown-linux-gnu": "15d00bc8400ed6d94c665a797dc8ed7a491ae25c5022e738dcd665cd29beec42",
"x86_64-apple-darwin": "484ba901f64fc7888bec5994eb49343dc3f9d00ed43df17ee9c40935aad4aa18",
"x86_64-pc-windows-msvc": "b446bec833eaba1bac9063bb9b4aeadfdf67fa81783b4487a90c56d408fb7994",
"x86_64-unknown-linux-gnu": "c890de112f1ae31283a31fefd2061d5c97bdd4d1bdd795552c7abddef2697ea1",
},
"strip_prefix": "python",
},
"3.9.10": {
"url": "20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "ad66c2a3e7263147e046a32694de7b897a46fb0124409d29d3a93ede631c8aee",
"aarch64-unknown-linux-gnu": "12dd1f125762f47975990ec744532a1cf3db74ad60f4dfb476ca42deb7f78ca4",
"x86_64-apple-darwin": "fdaf594142446029e314a9beb91f1ac75af866320b50b8b968181e592550cd68",
"x86_64-pc-windows-msvc": "c145d9d8143ce163670af124b623d7a2405143a3708b033b4d33eed355e61b24",
"x86_64-unknown-linux-gnu": "455089cc576bd9a58db45e919d1fc867ecdbb0208067dffc845cc9bbf0701b70",
},
"strip_prefix": "python",
},
"3.9.12": {
"url": "20220502/cpython-{python_version}+20220502-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "8dee06c07cc6429df34b6abe091a4684a86f7cec76f5d1ccc1c3ce2bd11168df",
"aarch64-unknown-linux-gnu": "2ee1426c181e65133e57dc55c6a685cb1fb5e63ef02d684b8a667d5c031c4203",
"x86_64-apple-darwin": "2453ba7f76b3df3310353b48c881d6cff622ba06e30d2b6ae91588b2bc9e481a",
"x86_64-pc-windows-msvc": "3024147fd987d9e1b064a3d94932178ff8e0fe98cfea955704213c0762fee8df",
"x86_64-unknown-linux-gnu": "ccca12f698b3b810d79c52f007078f520d588232a36bc12ede944ec3ea417816",
},
"strip_prefix": "python",
},
"3.9.13": {
"url": "20220802/cpython-{python_version}+20220802-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "d9603edc296a2dcbc59d7ada780fd12527f05c3e0b99f7545112daf11636d6e5",
"aarch64-unknown-linux-gnu": "80415aac1b96255b9211f6a4c300f31e9940c7e07a23d0dec12b53aa52c0d25e",
"x86_64-apple-darwin": "9540a7efb7c8a54a48aff1cb9480e49588d9c0a3f934ad53f5b167338174afa3",
"x86_64-pc-windows-msvc": "b538127025a467c64b3351babca2e4d2ea7bdfb7867d5febb3529c34456cdcd4",
"x86_64-unknown-linux-gnu": "ce1cfca2715e7e646dd618a8cb9baff93000e345ccc979b801fc6ccde7ce97df",
},
"strip_prefix": "python",
},
"3.9.15": {
"url": "20221106/cpython-{python_version}+20221106-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "64dc7e1013481c9864152c3dd806c41144c79d5e9cd3140e185c6a5060bdc9ab",
"aarch64-unknown-linux-gnu": "52a8c0a67fb919f80962d992da1bddb511cdf92faf382701ce7673e10a8ff98f",
"x86_64-apple-darwin": "f2bcade6fc976c472f18f2b3204d67202d43ae55cf6f9e670f95e488f780da08",
"x86_64-pc-windows-msvc": "022daacab215679b87f0d200d08b9068a721605fa4721ebeda38220fc641ccf6",
"x86_64-unknown-linux-gnu": "cdc3a4cfddcd63b6cebdd75b14970e02d8ef0ac5be4d350e57ab5df56c19e85e",
},
"strip_prefix": "python",
},
"3.9.16": {
"url": "20230116/cpython-{python_version}+20230116-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "d732d212d42315ac27c6da3e0b69636737a8d72086c980daf844344c010cab80",
"aarch64-unknown-linux-gnu": "1ba520c0db431c84305677f56eb9a4254f5097430ed443e92fc8617f8fba973d",
"x86_64-apple-darwin": "3948384af5e8d4ee7e5ccc648322b99c1c5cf4979954ed5e6b3382c69d6db71e",
"x86_64-pc-windows-msvc": "5274afd6b7ff2bddbd8306385ffb2336764b0e58535db968daeac656246f59a8",
"x86_64-unknown-linux-gnu": "7ba397787932393e65fc2fb9fcfabf54f2bb6751d5da2b45913cb25b2d493758",
},
"strip_prefix": "python",
},
"3.10.2": {
"url": "20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "1409acd9a506e2d1d3b65c1488db4e40d8f19d09a7df099667c87a506f71c0ef",
"aarch64-unknown-linux-gnu": "8f351a8cc348bb45c0f95b8634c8345ec6e749e483384188ad865b7428342703",
"x86_64-apple-darwin": "8146ad4390710ec69b316a5649912df0247d35f4a42e2aa9615bffd87b3e235a",
"x86_64-pc-windows-msvc": "a1d9a594cd3103baa24937ad9150c1a389544b4350e859200b3e5c036ac352bd",
"x86_64-unknown-linux-gnu": "9b64eca2a94f7aff9409ad70bdaa7fbbf8148692662e764401883957943620dd",
},
"strip_prefix": "python",
},
"3.10.4": {
"url": "20220502/cpython-{python_version}+20220502-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "2c99983d1e83e4b6e7411ed9334019f193fba626344a50c36fba6c25d4de78a2",
"aarch64-unknown-linux-gnu": "d8098c0c54546637e7516f93b13403b11f9db285def8d7abd825c31407a13d7e",
"x86_64-apple-darwin": "f2711eaffff3477826a401d09a013c6802f11c04c63ab3686aa72664f1216a05",
"x86_64-pc-windows-msvc": "bee24a3a5c83325215521d261d73a5207ab7060ef3481f76f69b4366744eb81d",
"x86_64-unknown-linux-gnu": "f6f871e53a7b1469c13f9bd7920ad98c4589e549acad8e5a1e14760fff3dd5c9",
},
"strip_prefix": "python",
},
"3.10.6": {
"url": "20220802/cpython-{python_version}+20220802-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "efaf66acdb9a4eb33d57702607d2e667b1a319d58c167a43c96896b97419b8b7",
"aarch64-unknown-linux-gnu": "81625f5c97f61e2e3d7e9f62c484b1aa5311f21bd6545451714b949a29da5435",
"x86_64-apple-darwin": "7718411adf3ea1480f3f018a643eb0550282aefe39e5ecb3f363a4a566a9398c",
"x86_64-pc-windows-msvc": "91889a7dbdceea585ff4d3b7856a6bb8f8a4eca83a0ff52a73542c2e67220eaa",
"x86_64-unknown-linux-gnu": "55aa2190d28dcfdf414d96dc5dcea9fe048fadcd583dc3981fec020869826111",
},
"strip_prefix": "python",
},
"3.10.8": {
"url": "20221106/cpython-{python_version}+20221106-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "d52b03817bd245d28e0a8b2f715716cd0fcd112820ccff745636932c76afa20a",
"aarch64-unknown-linux-gnu": "33170bef18c811906b738be530f934640491b065bf16c4d276c6515321918132",
"x86_64-apple-darwin": "525b79c7ce5de90ab66bd07b0ac1008bafa147ddc8a41bef15ffb7c9c1e9e7c5",
"x86_64-pc-windows-msvc": "f2b6d2f77118f06dd2ca04dae1175e44aaa5077a5ed8ddc63333c15347182bfe",
"x86_64-unknown-linux-gnu": "6c8db44ae0e18e320320bbaaafd2d69cde8bfea171ae2d651b7993d1396260b7",
},
"strip_prefix": "python",
},
"3.10.9": {
"url": "20230116/cpython-{python_version}+20230116-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "018d05a779b2de7a476f3b3ff2d10f503d69d14efcedd0774e6dab8c22ef84ff",
"aarch64-unknown-linux-gnu": "2003750f40cd09d4bf7a850342613992f8d9454f03b3c067989911fb37e7a4d1",
"x86_64-apple-darwin": "0e685f98dce0e5bc8da93c7081f4e6c10219792e223e4b5886730fd73a7ba4c6",
"x86_64-pc-windows-msvc": "59c6970cecb357dc1d8554bd0540eb81ee7f6d16a07acf3d14ed294ece02c035",
"x86_64-unknown-linux-gnu": "d196347aeb701a53fe2bb2b095abec38d27d0fa0443f8a1c2023a1bed6e18cdf",
},
"strip_prefix": "python",
},
"3.11.1": {
"url": "20230116/cpython-{python_version}+20230116-{platform}-{build}.tar.gz",
"sha256": {
"aarch64-apple-darwin": "4918cdf1cab742a90f85318f88b8122aeaa2d04705803c7b6e78e81a3dd40f80",
"aarch64-unknown-linux-gnu": "debf15783bdcb5530504f533d33fda75a7b905cec5361ae8f33da5ba6599f8b4",
"x86_64-apple-darwin": "20a4203d069dc9b710f70b09e7da2ce6f473d6b1110f9535fb6f4c469ed54733",
"x86_64-pc-windows-msvc": "edc08979cb0666a597466176511529c049a6f0bba8adf70df441708f766de5bf",
"x86_64-unknown-linux-gnu": "02a551fefab3750effd0e156c25446547c238688a32fabde2995c941c03a6423",
},
"strip_prefix": "python",
},
}
# buildifier: disable=unsorted-dict-items
MINOR_MAPPING = {
"3.8": "3.8.15",
"3.9": "3.9.16",
"3.10": "3.10.9",
"3.11": "3.11.1",
}
PLATFORMS = {
"aarch64-apple-darwin": struct(
compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:aarch64",
],
os_name = MACOS_NAME,
# Matches the value returned from:
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
arch = "arm64",
),
"aarch64-unknown-linux-gnu": struct(
compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:aarch64",
],
os_name = LINUX_NAME,
# Note: this string differs between OSX and Linux
# Matches the value returned from:
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
arch = "aarch64",
),
"x86_64-apple-darwin": struct(
compatible_with = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
os_name = MACOS_NAME,
arch = "x86_64",
),
"x86_64-pc-windows-msvc": struct(
compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
os_name = WINDOWS_NAME,
arch = "x86_64",
),
"x86_64-unknown-linux-gnu": struct(
compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
os_name = LINUX_NAME,
arch = "x86_64",
),
}
def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_URL, tool_versions = TOOL_VERSIONS):
"""Resolve the release URL for the requested interpreter version
Args:
platform: The platform string for the interpreter
python_version: The version of the intterpreter to get
base_url: The URL to prepend to the 'url' attr in the tool_versions dict
tool_versions: A dict listing the interpreter versions, their SHAs and URL
Returns:
A tuple of (filename, url, and archive strip prefix)
"""
url = tool_versions[python_version]["url"]
if type(url) == type({}):
url = url[platform]
if type(url) != type([]):
url = [url]
strip_prefix = tool_versions[python_version].get("strip_prefix", None)
if type(strip_prefix) == type({}):
strip_prefix = strip_prefix[platform]
release_filename = None
rendered_urls = []
for u in url:
release_filename = u.format(
platform = platform,
python_version = python_version,
build = "shared-install_only" if (WINDOWS_NAME in platform) else "install_only",
)
if "://" in release_filename: # is absolute url?
rendered_urls.append(release_filename)
else:
rendered_urls.append("/".join([base_url, release_filename]))
if release_filename == None:
fail("release_filename should be set by now; were any download URLs given?")
patches = tool_versions[python_version].get("patches", [])
if type(patches) == type({}):
if platform in patches.keys():
patches = patches[platform]
else:
patches = []
return (release_filename, rendered_urls, strip_prefix, patches)
def print_toolchains_checksums(name):
native.genrule(
name = name,
srcs = [],
outs = ["print_toolchains_checksums.sh"],
cmd = """\
cat > "$@" <<'EOF'
#!/bin/bash
set -o errexit -o nounset -o pipefail
echo "Fetching hashes..."
{commands}
EOF
""".format(
commands = "\n".join([
_commands_for_version(python_version)
for python_version in TOOL_VERSIONS.keys()
]),
),
executable = True,
)
def _commands_for_version(python_version):
return "\n".join([
"echo \"{python_version}: {platform}: $$(curl --location --fail {release_url_sha256} 2>/dev/null || curl --location --fail {release_url} 2>/dev/null | shasum -a 256 | awk '{{ print $$1 }}')\"".format(
python_version = python_version,
platform = platform,
release_url = release_url,
release_url_sha256 = release_url + ".sha256",
)
for platform in TOOL_VERSIONS[python_version]["sha256"].keys()
for release_url in get_release_info(platform, python_version)[1]
])
def gen_python_config_settings(name = ""):
for platform in PLATFORMS.keys():
native.config_setting(
name = "{name}{platform}".format(name = name, platform = platform),
constraint_values = PLATFORMS[platform].compatible_with,
)
rules_python-0.22.1/renovate.json 0000664 0000000 0000000 00000000061 14540404546 0017050 0 ustar 00root root 0000000 0000000 {
"extends": [
"config:base"
]
}
rules_python-0.22.1/tests/ 0000775 0000000 0000000 00000000000 14540404546 0015477 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/tests/BUILD.bazel 0000664 0000000 0000000 00000001760 14540404546 0017361 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//tools/bazel_integration_test:bazel_integration_test.bzl", "bazel_integration_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
bazel_integration_test(
name = "pip_repository_entry_points_example",
timeout = "long",
# The dependencies needed for this test are not cross-platform: https://github.com/bazelbuild/rules_python/issues/260
tags = ["fix-windows"],
)
build_test(
name = "bzl_libraries_build_test",
targets = [
# keep sorted
"//python:current_py_toolchain_bzl",
"//python:defs_bzl",
"//python:proto_bzl",
"//python:py_binary_bzl",
"//python:py_cc_link_params_info_bzl",
"//python:py_import_bzl",
"//python:py_info_bzl",
"//python:py_library_bzl",
"//python:py_runtime_bzl",
"//python:py_runtime_info_bzl",
"//python:py_runtime_pair_bzl",
"//python:py_test_bzl",
],
)
rules_python-0.22.1/tests/compile_pip_requirements/ 0000775 0000000 0000000 00000000000 14540404546 0022602 5 ustar 00root root 0000000 0000000 rules_python-0.22.1/tests/compile_pip_requirements/.bazelrc 0000664 0000000 0000000 00000000210 14540404546 0024216 0 ustar 00root root 0000000 0000000 test --test_output=errors
# Windows requires these for multi-python support:
build --enable_runfiles
startup --windows_enable_symlinks
rules_python-0.22.1/tests/compile_pip_requirements/.gitignore 0000664 0000000 0000000 00000000010 14540404546 0024561 0 ustar 00root root 0000000 0000000 bazel-*
rules_python-0.22.1/tests/compile_pip_requirements/BUILD.bazel 0000664 0000000 0000000 00000001302 14540404546 0024454 0 ustar 00root root 0000000 0000000 load("@rules_python//python:pip.bzl", "compile_pip_requirements")
genrule(
name = "generate_requirements_extra_in",
srcs = [],
outs = ["requirements_extra.in"],
cmd = "echo 'setuptools~=65.6.3' > $@",
)
genrule(
name = "generate_requirements_in",
srcs = [],
outs = ["requirements.in"],
cmd = """
cat > $@ <