Created
August 29, 2018 17:27
-
-
Save pcn/24200b3bce414b9cf6160d07d4addfd7 to your computer and use it in GitHub Desktop.
Doing a simple build with bazel and python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package(default_visibility = ["//visibility:public"]) | |
load("@subpar//:subpar.bzl", "par_binary") | |
load( | |
"@io_bazel_rules_python//python:python.bzl", | |
"py_binary", "py_library", "py_test" | |
) | |
# Load the pip_install symbol for my_deps, and create the dependencies' | |
# repositories. | |
load("@my_deps//:requirements.bzl", "requirement") | |
DEPLOY_DEPS = [ | |
requirement("some_dependency_package"), | |
requirement("some_other_dependency_package"), | |
] | |
par_binary( | |
name = 'the-target-name-to-build', | |
srcs = glob(["bin/*.py", "lib/**/*.py"], exclude=["test*", "setup.py", "test/**", "bazel-*/**", ]), | |
deps = DEPLOY_DEPS, | |
main = 'bin/the-binary-to-be-run.py' | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://github.com/google/subpar | |
git_repository( | |
name = "subpar", | |
# remote = "https://github.com/google/subpar", | |
# tag = "1.1.0", | |
remote = "https://github.com/pcn/subpar", | |
commit = "763f32c", | |
) | |
# From https://github.com/bazelbuild/rules_python/blob/master/README.md | |
git_repository( | |
name = "io_bazel_rules_python", | |
remote = "https://github.com/bazelbuild/rules_python.git", | |
commit = "44fdf5f", | |
# remote = "https://github.com/jac-stripe/rules_python.git", # Contains a fix for loading shared libs from zip files | |
# commit = "5893be97181e338447c4da5cdf7c9f4d5e414c02" | |
) | |
# Only needed for PIP support: | |
load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories") | |
pip_repositories() | |
load("@io_bazel_rules_python//python:pip.bzl", "pip_import") | |
# This rule translates the specified requirements.txt into | |
# @my_deps//:requirements.bzl, which itself exposes a pip_install method. | |
pip_import( | |
name = "my_deps", | |
requirements = "//:requirements.txt", | |
) | |
# Load the pip_install symbol for my_deps, and create the dependencies' | |
# repositories. | |
load("@my_deps//:requirements.bzl", "pip_install") | |
pip_install() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment