Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build --incompatible_disable_starlark_host_transitions
build --incompatible_disable_native_repo_rules
build --incompatible_disable_autoloads_in_main_repo

common --deleted_packages=examples/simple,examples/torch,examples/markers,examples/aspect_rules_py,examples/cc_toolchain,examples/airflow,examples/numpy
common --deleted_packages=examples/simple,examples/torch,examples/markers,examples/aspect_rules_py,examples/cc_toolchain,examples/airflow,examples/numpy,examples/wheel

common --deleted_packages=examples/transitions,examples/transitions/toolchains,examples/transitions/toolchains/args,examples/transitions/constraint
common --deleted_packages=examples/transitions/toolchains/clang,examples/transitions/toolchains/clang/tools,examples/transitions/toolchains/clang/args
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
if: runner.os != 'Windows'
run: |
df -h
sudo rm -rf /usr/lib/jvm /usr/share/dotnet /usr/share/swift /usr/local/.ghcup /usr/local/share/powershell /usr/local/julia* /usr/local/lib/android /usr/local/share/chromium /opt/microsoft /opt/google /opt/az /opt/ghc /opt/hostedtoolcache
sudo rm -rf /usr/lib/jvm /usr/share/dotnet /usr/local/.ghcup /usr/local/share/powershell /usr/local/julia* /usr/local/lib/android /usr/local/share/chromium /opt/microsoft /opt/google /opt/az /opt/ghc /opt/hostedtoolcache
docker system prune -af || true
docker builder prune -af || true
df -h
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module(

bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "rules_cc", version = "0.2.18")
bazel_dep(name = "rules_cc", version = "0.2.21")
bazel_dep(name = "rules_multitool", version = "1.11.1")
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_rust", version = "0.70.0")
bazel_dep(name = "rules_python", version = "2.2.0")
bazel_dep(name = "rules_rust", version = "0.71.3")
bazel_dep(name = "rules_shell", version = "0.8.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ In both cases the host interpreter is used in the latter case poetry package wit
To import `ofiuco` in your project, you first need to add it to your `MODULE.bazel` file

```python
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_python", version = "2.2.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.13")
use_repo(python, "python_3_13")

bazel_dep(name = "ofiuco", version = "0.9.0")
bazel_dep(name = "ofiuco", version = "0.9.2")

parse = use_extension("@ofiuco//python:extensions.bzl", "parse")
parse.lock(
Expand Down
1 change: 1 addition & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ tags = {
"torch",
"transitions",
"uv",
"wheel",
]]
2 changes: 1 addition & 1 deletion examples/airflow/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_python", version = "2.2.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.12")
Expand Down
2 changes: 1 addition & 1 deletion examples/aspect_rules_py/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module(
)

bazel_dep(name = "aspect_rules_py", version = "1.10.0")
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_python", version = "2.2.0")

# Register a hermetic Python toolchain rather than rely on a locally-installed
# interpreter.
Expand Down
4 changes: 2 additions & 2 deletions examples/cc_toolchain/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_cc", version = "0.2.21")
bazel_dep(name = "rules_python", version = "2.2.0")
bazel_dep(name = "platforms", version = "1.0.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down
2 changes: 1 addition & 1 deletion examples/markers/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_python", version = "2.2.0")

python_version = "3_13"

Expand Down
1 change: 0 additions & 1 deletion examples/numpy/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
startup --windows_enable_symlinks
common --enable_runfiles
common --macos_sdk_version=11.0 # Required a minimal SDK version on MacOS Tahoe 26
build --sandbox_default_allow_network=false
build --nolegacy_external_runfiles
build --incompatible_autoload_externally=
2 changes: 1 addition & 1 deletion examples/numpy/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "catch2", version = "3.13.0")
bazel_dep(name = "fmt", version = "12.1.0")
bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "rules_cc", version = "0.2.18")
bazel_dep(name = "rules_cc", version = "0.2.21")
bazel_dep(name = "rules_python", version = "2.0.1")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_python", version = "2.2.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.14")
Expand Down
2 changes: 1 addition & 1 deletion examples/torch/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_python", version = "2.2.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.12")
Expand Down
4 changes: 2 additions & 2 deletions examples/transitions/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_cc", version = "0.2.21")
bazel_dep(name = "rules_python", version = "2.2.0")
bazel_dep(name = "platforms", version = "1.0.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down
4 changes: 2 additions & 2 deletions examples/uv/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_python", version = "2.2.0")
bazel_dep(name = "rules_uv", version = "0.89.2")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_cc", version = "0.2.21")
bazel_dep(name = "platforms", version = "1.0.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down
8 changes: 8 additions & 0 deletions examples/wheel/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
startup --nowindows_enable_symlinks
common --@rules_python//python/config_settings:py_freethreaded=yes
common --action_env=ProgramFiles --action_env=ProgramFiles(x86)
build --sandbox_default_allow_network=false
build --incompatible_no_implicit_file_export
build --incompatible_config_setting_private_default_visibility
build --incompatible_disable_starlark_host_transitions
build --incompatible_default_to_explicit_init_py
1 change: 1 addition & 0 deletions examples/wheel/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
last_green
73 changes: 73 additions & 0 deletions examples/wheel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
load("@ofiuco//python:poetry.bzl", "poetry_lock")
load("@ofiuco//python:requirements.bzl", "py_requires_file")
load("@poetry//:defz.bzl", "requirements")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@rules_python//python:packaging.bzl", "py_wheel")

py_library(
name = "network",
srcs = ["network.py"],
deps = [
"@poetry//:requests",
],
)

py_library(
name = "compression",
srcs = ["compression.py"],
deps = [
"@poetry//:urllib3[brotli]",
],
)

py_library(
name = "applib",
srcs = [],
deps = [
":compression",
":network",
],
)

py_binary(
name = "app",
srcs = ["app.py"],
main = "app.py",
deps = [
":applib",
],
)

py_requires_file(
name = "app_requires",
requirements = requirements,
target = ":app",
)

py_wheel(
name = "app_wheel",
distribution = "app",
python_tag = "py3",
requires_file = ":app_requires",
version = "0.0.1",
deps = [":app"],
)

py_test(
name = "test",
size = "large",
srcs = ["test.py"],
data = [
"poetry.lock",
":app_wheel",
],
deps = [
"@poetry//:pytest",
],
)

poetry_lock(
name = "lock",
lock = "poetry.lock",
toml = "pyproject.toml",
)
18 changes: 18 additions & 0 deletions examples/wheel/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bazel_dep(name = "rules_python", version = "2.2.0")

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

bazel_dep(name = "ofiuco", version = "0.0.0")
local_path_override(
module_name = "ofiuco",
path = "../..",
)

parse = use_extension("@ofiuco//python:extensions.bzl", "parse")
parse.lock(
name = "poetry",
generate_extras = True,
lock = "//:poetry.lock",
)
use_repo(parse, "poetry")
10 changes: 10 additions & 0 deletions examples/wheel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Simple example with Poetry lock file

This example shows how to use `ofiuco` to fetch external dependencies from a pyproject.toml file
and than use in BUILD files as dependencies of Bazel targets.

The `poetry.lock` file can be updated with
```
bazel run :lock
```
command or with a locally installed `poetry` as `poetry update`.
Empty file added examples/wheel/WORKSPACE
Empty file.
12 changes: 12 additions & 0 deletions examples/wheel/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from compression import make_pool
from network import get


def main():
pool = make_pool()
print(pool)
print(get("https://example.com").status_code)


if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions examples/wheel/compression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import urllib3


def make_pool():
return urllib3.PoolManager()
5 changes: 5 additions & 0 deletions examples/wheel/network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import requests


def get(url):
return requests.get(url, timeout=5)
Loading
Loading