From 9cae315eb593cb099db9f4862b5638f10b95ebd1 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Mon, 23 Sep 2024 12:11:15 +0200 Subject: [PATCH] chore: python demo --- examples/python/with_numpy/.bazelrc | 1 + examples/python/with_numpy/BUILD.bazel | 0 examples/python/with_numpy/MODULE.bazel | 18 ++++++++++++++++++ examples/python/with_numpy/app/BUILD.bazel | 10 ++++++++++ examples/python/with_numpy/app/main.py | 3 +++ examples/python/with_numpy/requirements.txt | 1 + .../tools/intellij/.managed.bazelproject | 7 +++++++ 7 files changed, 40 insertions(+) create mode 100644 examples/python/with_numpy/.bazelrc create mode 100644 examples/python/with_numpy/BUILD.bazel create mode 100644 examples/python/with_numpy/MODULE.bazel create mode 100644 examples/python/with_numpy/app/BUILD.bazel create mode 100644 examples/python/with_numpy/app/main.py create mode 100644 examples/python/with_numpy/requirements.txt create mode 100644 examples/python/with_numpy/tools/intellij/.managed.bazelproject diff --git a/examples/python/with_numpy/.bazelrc b/examples/python/with_numpy/.bazelrc new file mode 100644 index 00000000000..9eb44dae343 --- /dev/null +++ b/examples/python/with_numpy/.bazelrc @@ -0,0 +1 @@ +common --incompatible_use_plus_in_repo_names \ No newline at end of file diff --git a/examples/python/with_numpy/BUILD.bazel b/examples/python/with_numpy/BUILD.bazel new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/python/with_numpy/MODULE.bazel b/examples/python/with_numpy/MODULE.bazel new file mode 100644 index 00000000000..fe1b3ff79c6 --- /dev/null +++ b/examples/python/with_numpy/MODULE.bazel @@ -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") diff --git a/examples/python/with_numpy/app/BUILD.bazel b/examples/python/with_numpy/app/BUILD.bazel new file mode 100644 index 00000000000..44e312682ae --- /dev/null +++ b/examples/python/with_numpy/app/BUILD.bazel @@ -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"), + ], +) diff --git a/examples/python/with_numpy/app/main.py b/examples/python/with_numpy/app/main.py new file mode 100644 index 00000000000..43c9bcb5e40 --- /dev/null +++ b/examples/python/with_numpy/app/main.py @@ -0,0 +1,3 @@ +from numpy import abs + +print(abs(-2)) \ No newline at end of file diff --git a/examples/python/with_numpy/requirements.txt b/examples/python/with_numpy/requirements.txt new file mode 100644 index 00000000000..98f7200df6c --- /dev/null +++ b/examples/python/with_numpy/requirements.txt @@ -0,0 +1 @@ +numpy==2.1.1 diff --git a/examples/python/with_numpy/tools/intellij/.managed.bazelproject b/examples/python/with_numpy/tools/intellij/.managed.bazelproject new file mode 100644 index 00000000000..a172ed64bb8 --- /dev/null +++ b/examples/python/with_numpy/tools/intellij/.managed.bazelproject @@ -0,0 +1,7 @@ +directories: + . + +derive_targets_from_directories: true + +additional_languages: + python \ No newline at end of file