Skip to content

Commit cb5fef7

Browse files
Matt Mackayalexeagle
andauthored
feat: support 'virtual' dependencies (#201)
Fixes #213 --------- Co-authored-by: Alex Eagle <[email protected]>
1 parent 9252988 commit cb5fef7

22 files changed

+593
-31
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ test --test_output=errors
77
# Define value used by tests
88
build --define=SOME_VAR=SOME_VALUE
99

10+
# Use local rules_python
11+
# Enable with --config=dev
12+
common:dev --override_repository=rules_python=~/workspace/rules_python
13+
1014
# Load any settings specific to the current user.
1115
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
1216
# This needs to be last statement in this

WORKSPACE

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ rules_py_dependencies()
1414
# Load the Python toolchain for rules_docker
1515
register_toolchains("//:container_py_toolchain")
1616

17-
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
17+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
1818

1919
python_register_toolchains(
2020
name = "python_toolchain",
2121
python_version = "3.9",
2222
)
2323

24+
py_repositories()
25+
2426
############################################
2527
# Aspect gcc toolchain
2628
load("@aspect_gcc_toolchain//toolchain:repositories.bzl", "gcc_toolchain_dependencies")
@@ -47,6 +49,10 @@ load("@pypi//:requirements.bzl", "install_deps")
4749

4850
install_deps()
4951

52+
load("@django//:requirements.bzl", install_django_deps = "install_deps")
53+
54+
install_django_deps()
55+
5056
################################
5157
# For running our own unit tests
5258
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

docs/rules.md

Lines changed: 99 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal_deps.bzl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Users should *not* need to install these. If users see a load()
44
statement from these, that's a bug in our distribution.
55
"""
66

7-
load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive")
7+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file", _http_archive = "http_archive")
88
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
99

1010
def http_archive(name, **kwargs):
@@ -90,3 +90,24 @@ def rules_py_internal_deps():
9090
strip_prefix = "rules_python-0.18.0/gazelle",
9191
url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.0/rules_python-0.18.0.tar.gz",
9292
)
93+
94+
http_file(
95+
name = "django_4_2_4",
96+
urls = ["https://files.pythonhosted.org/packages/7f/9e/fc6bab255ae10bc57fa2f65646eace3d5405fbb7f5678b90140052d1db0f/Django-4.2.4-py3-none-any.whl"],
97+
sha256 = "860ae6a138a238fc4f22c99b52f3ead982bb4b1aad8c0122bcd8c8a3a02e409d",
98+
downloaded_file_path = "Django-4.2.4-py3-none-any.whl",
99+
)
100+
101+
http_file(
102+
name = "django_4_1_10",
103+
urls = ["https://files.pythonhosted.org/packages/34/25/8a218de57fc9853297a1a8e4927688eff8107d5bc6dcf6c964c59801f036/Django-4.1.10-py3-none-any.whl"],
104+
sha256 = "26d0260c2fb8121009e62ffc548b2398dea2522b6454208a852fb0ef264c206c",
105+
downloaded_file_path = "Django-4.1.10-py3-none-any.whl",
106+
)
107+
108+
http_file(
109+
name = "sqlparse_0_4_0",
110+
urls = ["https://files.pythonhosted.org/packages/10/96/36c136013c4a6ecb8c6aa3eed66e6dcea838f85fd80e1446499f1dabfac7/sqlparse-0.4.0-py3-none-any.whl"],
111+
sha256 = "0523026398aea9c8b5f7a4a6d5c0829c285b4fbd960c17b5967a369342e21e01",
112+
downloaded_file_path = "sqlparse-0.4.0-py3-none-any.whl",
113+
)

internal_python_deps.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ py_wheel(
1616
)
1717
"""
1818

19+
# buildifier: disable=function-docstring
1920
def rules_py_internal_pypi_deps(interpreter):
2021
# Here we can see an example of annotations being applied to an arbitrary
2122
# package. For details on `package_annotation` and it's uses, see the
2223
# docs at @rules_python//docs:pip.md`.
2324

24-
PACKAGES = ["django", "colorama", "django"]
25+
PACKAGES = ["django", "colorama"]
2526
ANNOTATIONS = {
2627
pkg: package_annotation(additive_build_content = PY_WHEEL_RULE_CONTENT)
2728
for pkg in PACKAGES
@@ -33,3 +34,9 @@ def rules_py_internal_pypi_deps(interpreter):
3334
python_interpreter_target = interpreter,
3435
requirements_lock = "//:requirements.txt",
3536
)
37+
38+
pip_parse(
39+
name = "django",
40+
python_interpreter_target = interpreter,
41+
requirements_lock = "//py/tests/virtual/django:requirements.txt",
42+
)

0 commit comments

Comments
 (0)