Skip to content

Commit

Permalink
chore: python demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tpasternak committed Sep 23, 2024
1 parent 5121118 commit 9cae315
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/python/with_numpy/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --incompatible_use_plus_in_repo_names
Empty file.
18 changes: 18 additions & 0 deletions examples/python/with_numpy/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bazel_dep(name = "rules_python", version = "0.35.0")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
is_default = True,
python_version = "3.12",
)

pip.parse(
hub_name = "my_deps",
python_version = "3.12",
requirements_lock = "//:requirements.txt",
)
use_repo(pip, "my_deps")

use_repo(python, "python_versions")
10 changes: 10 additions & 0 deletions examples/python/with_numpy/app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@my_deps//:requirements.bzl", "requirement")
load("@python_versions//3.12:defs.bzl", "py_binary")

py_binary(
name = "main",
srcs = ["main.py"],
deps = [
requirement("numpy"),
],
)
3 changes: 3 additions & 0 deletions examples/python/with_numpy/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from numpy import abs

print(abs(-2))
1 change: 1 addition & 0 deletions examples/python/with_numpy/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numpy==2.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
directories:
.

derive_targets_from_directories: true

additional_languages:
python

0 comments on commit 9cae315

Please sign in to comment.