| # 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", "py_wheel_lib", _PyWheelInfo = "PyWheelInfo") |
| |
| # 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, |
| ) |
| |
| py_wheel = rule( |
| implementation = py_wheel_lib.implementation, |
| doc = """\ |
| A rule for building Python Wheels. |
| |
| Wheels are Python distribution format defined in https://www.python.org/dev/peps/pep-0427/. |
| |
| This rule packages a set of targets into a single wheel. |
| |
| 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"], |
| ) |
| ``` |
| """, |
| attrs = py_wheel_lib.attrs, |
| ) |