blob: 81dcd9be8ceb39aa7a6f8ea1bd3585b0761137a0 [file] [log] [blame]
Dillon Giacoppo12bfbdf2020-01-02 09:26:42 +11001workspace(name = "example_repo")
2
3load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4
5http_archive(
6 name = "rules_python",
Jonathon Belotti3baa2662020-09-08 21:08:43 +10007 url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.3/rules_python-0.0.3.tar.gz",
8 sha256 = "e46612e9bb0dae8745de6a0643be69e8665a03f63163ac6610c210e80d14c3e4",
Dillon Giacoppo12bfbdf2020-01-02 09:26:42 +11009)
Gergely Fábiáned2f6442020-06-03 08:36:12 +020010
Dillon Giacoppo12bfbdf2020-01-02 09:26:42 +110011load("@rules_python//python:repositories.bzl", "py_repositories")
Gergely Fábiáned2f6442020-06-03 08:36:12 +020012
Dillon Giacoppo12bfbdf2020-01-02 09:26:42 +110013py_repositories()
14
Alex Eagle6ed1fe52020-08-31 08:09:18 -070015load("@rules_python//experimental/rules_python_external:defs.bzl", "pip_install")
Gergely Fábiáned2f6442020-06-03 08:36:12 +020016
Dillon Giacoppo12bfbdf2020-01-02 09:26:42 +110017pip_install(
Gergely Fábián2c78da52020-07-09 08:45:01 +020018 # (Optional) You can provide extra parameters to pip.
19 # Here, make pip output verbose (this is usable with `quiet = False`).
20 #extra_pip_args = ["-v"],
21
22 # (Optional) You can exclude custom elements in the data section of the generated BUILD files for pip packages.
23 # Exclude directories with spaces in their names in this example (avoids build errors if there are such directories).
24 #pip_data_exclude = ["**/* */**"],
25
26 # (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
Gergely Fábiáned2f6442020-06-03 08:36:12 +020027 # acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
28 # 1. Python interpreter that you compile in the build file (as above in @python_interpreter).
29 # 2. Pre-compiled python interpreter included with http_archive
30 # 3. Wrapper script, like in the autodetecting python toolchain.
Dillon Giacoppocdc03052020-08-16 19:48:49 +100031 #python_interpreter_target = "@python_interpreter//:python_bin",
Gergely Fábián2c78da52020-07-09 08:45:01 +020032
33 # (Optional) You can set quiet to False if you want to see pip output.
34 #quiet = False,
35
Dillon Giacoppo0aaa43b2020-01-02 11:39:56 +110036 # Uses the default repository name "pip"
Dillon Giacoppo12bfbdf2020-01-02 09:26:42 +110037 requirements = "//:requirements.txt",
38)
Gergely Fábiáned2f6442020-06-03 08:36:12 +020039
Dillon Giacoppocdc03052020-08-16 19:48:49 +100040# You could optionally use an in-build, compiled python interpreter as a toolchain,
41# and also use it to execute pip.
42#
43# Special logic for building python interpreter with OpenSSL from homebrew.
44# See https://devguide.python.org/setup/#macos-and-os-x
45#_py_configure = """
46#if [[ "$OSTYPE" == "darwin"* ]]; then
47# ./configure --prefix=$(pwd)/bazel_install --with-openssl=$(brew --prefix openssl)
48#else
49# ./configure --prefix=$(pwd)/bazel_install
50#fi
51#"""
52#
53# NOTE: you need to have the SSL headers installed to build with openssl support (and use HTTPS).
54# E.g. on Ubuntu: `sudo apt install libssl-dev`
55#http_archive(
56# name = "python_interpreter",
57# build_file_content = """
58#exports_files(["python_bin"])
59#filegroup(
60# name = "files",
61# srcs = glob(["bazel_install/**"], exclude = ["**/* *"]),
62# visibility = ["//visibility:public"],
63#)
64#""",
65# patch_cmds = [
66# "mkdir $(pwd)/bazel_install",
67# _py_configure,
68# "make",
69# "make install",
70# "ln -s bazel_install/bin/python3 python_bin",
71# ],
72# sha256 = "dfab5ec723c218082fe3d5d7ae17ecbdebffa9a1aea4d64aa3a2ecdd2e795864",
73# strip_prefix = "Python-3.8.3",
74# urls = ["https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz"],
75#)
76
Gergely Fábiáned2f6442020-06-03 08:36:12 +020077# Optional:
78# Register the toolchain with the same python interpreter we used for pip in pip_install().
Dillon Giacoppocdc03052020-08-16 19:48:49 +100079#register_toolchains("//:my_py_toolchain")
80# End of in-build Python interpreter setup.