Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
betaboon committed Jan 13, 2025
1 parent 91d9ec5 commit 4f5c165
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 21 deletions.
4 changes: 3 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.9.4")
bazel_dep(name = "bazel_features", version = "1.11.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "rules_python", version = "1.0.0")

# bazel_dep(name = "rules_python", version = "1.0.0")
bazel_dep(name = "rules_python", version = "0.40.0")

bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)

Expand Down
28 changes: 21 additions & 7 deletions e2e/uv/always_build/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.9.4")
bazel_dep(name = "hermetic_cc_toolchain", version = "2.2.1")
bazel_dep(name = "rules_pycross", version = "0.0.0")
bazel_dep(name = "rules_pycross_e2e_shared", version = "0.0.0")
bazel_dep(name = "rules_python", version = "1.0.0")

# bazel_dep(name = "rules_python", version = "1.0.0")
bazel_dep(name = "rules_python", version = "0.40.0")

local_path_override(
module_name = "rules_pycross",
Expand All @@ -20,10 +22,18 @@ python = use_extension("@rules_python//python/extensions:python.bzl", "python")
# The default is latest - 1 to make sure nothing assumes latest == default
python.toolchain(
is_default = True,
python_version = "3.11.6",
python_version = "3.11",
)

# python.toolchain(python_version = "3.10.11")
# python.toolchain(python_version = "3.12.0")
python.override(
minor_mapping = {
"3.10": "3.10.11",
"3.11": "3.11.7",
"3.12": "3.12.0",
},
)
python.toolchain(python_version = "3.10.11")
python.toolchain(python_version = "3.12.0")
use_repo(python, "python_versions")

# rules_pycross
Expand All @@ -36,10 +46,14 @@ environments.create_for_python_toolchains(
"x86_64-unknown-linux-gnu",
],
python_versions = [
"3.10.11",
"3.11.6",
"3.12.0",
"3.10",
"3.11",
"3.12",
# "3.10.11",
# "3.11.6",
# "3.11.7",
# "3.12.0",
# "3.12",
],
)
use_repo(environments, "rules_pycross_e2e_environments")
Expand Down
7 changes: 0 additions & 7 deletions e2e/uv/always_build/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ http_archive(
url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
)

# http_archive(
# name = "rules_python",
# sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
# strip_prefix = "rules_python-0.31.0",
# url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz",
# )

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

py_repositories()
Expand Down
17 changes: 13 additions & 4 deletions pycross/private/interpreter_version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ def rules_python_interpreter_version(name, default_version, **kwargs):
)
"""

selects = {
"@rules_python//python/config_settings:is_python_%s" % version: version
for version in sorted(TOOL_VERSIONS)
}
# selects = {
# "@rules_python//python/config_settings:is_python_%s" % version: version
# for version in sorted(TOOL_VERSIONS)
# }
selects = {}
for version in sorted(TOOL_VERSIONS):
# if version == "3.11.10":
# continue
key = "@rules_python//python/config_settings:is_python_%s" % version
selects[key] = version
print(key, version)

selects["//conditions:default"] = default_version
print("//conditions:default", default_version)

_rules_python_interpreter_version(
name = name,
Expand Down
1 change: 0 additions & 1 deletion pycross/private/pdm.lock

This file was deleted.

1 change: 0 additions & 1 deletion pycross/private/pyproject.toml

This file was deleted.

4 changes: 4 additions & 0 deletions pycross/private/toolchain_helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def _compute_toolchains(
is_multi_version_layout,
python_versions,
platforms):
print("computing", python_versions)
toolchains = []

if not platforms:
Expand Down Expand Up @@ -185,6 +186,7 @@ def _get_single_python_version(rctx, python_toolchain_repo):

def _get_multi_python_versions(rctx, python_toolchain_repo):
pip_bzl_file = python_toolchain_repo.relative("//:pip.bzl")
print("GET MULTI", pip_bzl_file)
content = rctx.read(pip_bzl_file)

versions = []
Expand Down Expand Up @@ -391,6 +393,8 @@ def _pycross_toolchain_repo_impl(rctx):

toolchains_build_sections = [_TOOLCHAINS_BUILD_HEADER.format(default_version = version_info.default_micro_version)]
for tc in computed_toolchains:
print("HERE")
print(tc)
toolchains_build_sections.append(_TOOLCHAIN_TEMPLATE.format(**{k: repr(v) for k, v in tc.items()}))

rctx.file(rctx.path("BUILD.bazel"), "\n".join(toolchains_build_sections))
Expand Down

0 comments on commit 4f5c165

Please sign in to comment.