Skip to content

Commit

Permalink
Switch to Bazelmod from WORKSPACE (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougthor42 authored Feb 20, 2024
1 parent 866eee0 commit 130fade
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Don't use the MODULE.bazel stuff yet.
common --noenable_bzlmod
# Use the MODULE.bazel stuff instead of the old WORKSPACE.
common --enable_bzlmod

# Show output if tests fail.
test --test_output=errors
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,7 @@ secrets.sh
/.clwb/

# End of https://www.toptal.com/developers/gitignore/api/bazel

# Ignore Bazel's lockfile until usability gets resolved. See
# https://github.com/bazelbuild/bazel/issues/20369
MODULE.bazel.lock
38 changes: 38 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Name the workspace/module
module(
name = "bitwarden-to-keepass",
version = "0.0.0",
compatibility_level = 1,
)

# Install rules_python, which allows us to define how bazel should work with python files.
# See https://github.com/bazelbuild/rules_python/blob/c6941a8dad4c7a221125fbad7c8bfaac377e00ba/examples/bzlmod/MODULE.bazel
bazel_dep(name = "rules_python", version = "0.31.0")

# Init the python toolchain using the extension.
# This is similar to the "python_register_toolchains" function in WORKSPACE.
# It creates a hermetic python rather than relying on a system-installed interpreter.
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
# Available versions are listed in @rules_python//python:versions.bzl.
# For some reason we can't set 3.8.18 here - it causes pip.parse() to fail.
python_version = "3.8"
)

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

# Configure how we fetch python dependencies via pip
pip.parse(
# This name is what gets used in other BUILD files with `load()`.
hub_name = "pypi",
python_version = "3.8.18",
# TODO: what to put here? Using this might resolve the "can't set 3.8.18"
# issue mentioned above.
# python_interpreter_target = python,
requirements_lock = "//:requirements_lock.txt",
)

# Same as WORKSPACE install_deps() - actually install the python deps.
use_repo(pip, "pypi")
60 changes: 0 additions & 60 deletions WORKSPACE

This file was deleted.

0 comments on commit 130fade

Please sign in to comment.