Skip to content

Commit

Permalink
Adds pkg_repo example
Browse files Browse the repository at this point in the history
  • Loading branch information
jvolkman committed Dec 4, 2023
1 parent b70cb22 commit 0b39c22
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/pkg_repo/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.4.0
9 changes: 9 additions & 0 deletions examples/pkg_repo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_python//python:defs.bzl", "py_binary")

py_binary(
name = "ipython",
srcs = ["ipython.py"],
deps = [
"@pdm//:ipython",
],
)
66 changes: 66 additions & 0 deletions examples/pkg_repo/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
workspace(
name = "jvolkman_rules_pycross_example",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_python",
sha256 = "9acc0944c94adb23fba1c9988b48768b1bacc6583b52a2586895c5b7491e2e31",
strip_prefix = "rules_python-0.27.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.27.0/rules_python-0.27.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains")

py_repositories()

python_register_multi_toolchains(
name = "python",
default_version = "3.12",
python_versions = [
"3.10",
"3.11",
"3.12",
],
)

load("@python//3.12:defs.bzl", python_interpreter = "interpreter")

local_repository(
name = "jvolkman_rules_pycross",
path = "../..",
)

load("@jvolkman_rules_pycross//pycross:repositories.bzl", "rules_pycross_dependencies")

rules_pycross_dependencies(
python_interpreter_target = python_interpreter,
)

load(
"@jvolkman_rules_pycross//pycross:defs.bzl",
"pkg_repo_model_pdm",
"pycross_pkg_repo",
"pycross_register_for_python_toolchains",
)

pycross_register_for_python_toolchains(
name = "pycross_toolchains",
python_toolchains_repo_name = "python",
)

load("@pycross_toolchains//:defs.bzl", "environments")

pycross_pkg_repo(
name = "pdm",
lock_model = pkg_repo_model_pdm(
lock_file = "@//:pdm.lock",
project_file = "@//:pyproject.toml",
),
target_environments = environments,
)

load("@pdm//:defs.bzl", "install_deps")

install_deps()
3 changes: 3 additions & 0 deletions examples/pkg_repo/ipython.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from IPython import start_ipython

start_ipython()
214 changes: 214 additions & 0 deletions examples/pkg_repo/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/pkg_repo/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[project]
dependencies = [
"ipython>=8.17",
]
requires-python = ">=3.10"

0 comments on commit 0b39c22

Please sign in to comment.