Skip to content

Commit

Permalink
Migrate Python pip dependencies to single requirements file (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvgijssel authored Apr 26, 2023
1 parent ec322dc commit 7f12db4
Show file tree
Hide file tree
Showing 20 changed files with 610 additions and 1,163 deletions.
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:prettier/package_json.bzl", prettier_bin = "bin")
load("@rules_task//:defs.bzl", "cmd", "task")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -70,3 +71,10 @@ filegroup(
"**/*.bzl",
]),
)

compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements.lock",
)
53 changes: 7 additions & 46 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
All the dependencies for setup
All the dependencies for setup.
"""

module(
Expand Down Expand Up @@ -47,6 +47,12 @@ register_toolchains(
)

pip = use_extension("@rules_python//python:extensions.bzl", "pip")
pip.parse(
name = "pip-setup",
python_interpreter_target = "@python_interpreter//:python",
requirements_lock = "//:requirements.lock",
)
use_repo(pip, "pip-setup")

# ------------------------------------ rules_js ------------------------------------ #
bazel_dep(name = "aspect_rules_js", version = "1.24.1")
Expand All @@ -73,48 +79,3 @@ use_repo(npm, "npm")
# ------------------------------------ buildifier ------------------------------------ #
# NOTE: don't upgrade to 6.1.0 because this has a bug where tests always pass
bazel_dep(name = "buildifier_prebuilt", version = "6.0.0.1")

# ------------------------------------ hypervisor ------------------------------------ #

pip.parse(
name = "hypervisor_deps",
python_interpreter_target = "@python_interpreter//:python",
requirements_lock = "//hypervisor:requirements_lock.txt",
)
use_repo(pip, "hypervisor_deps")

# ------------------------------------ pytest ------------------------------------ #

pip.parse(
name = "pytest",
python_interpreter_target = "@python_interpreter//:python",
requirements_lock = "@//tools/pytest:requirements.lock",
)
use_repo(pip, "pytest")

# ------------------------------------ occupancy_component ------------------------------------ #

pip.parse(
name = "occupancy_component",
python_interpreter_target = "@python_interpreter//:python",
requirements_lock = "@//occupancy_component:requirements.lock",
)
use_repo(pip, "occupancy_component")

# ------------------------------------ infrastructure ------------------------------------ #

pip.parse(
name = "infrastructure-requirements",
python_interpreter_target = "@python_interpreter//:python",
requirements_lock = "//infrastructure:requirements.lock",
)
use_repo(pip, "infrastructure-requirements")

# ------------------------------------ black ------------------------------------ #

pip.parse(
name = "black-requirements",
python_interpreter_target = "@python_interpreter//:python",
requirements_lock = "//tools/black:requirements.lock",
)
use_repo(pip, "black-requirements")
8 changes: 0 additions & 8 deletions hypervisor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# load("//tools/packer:defs.bzl", "packer_image")
# load("//tools/pyinfra:defs.bzl", "pyinfra_run")
# load("//tools/vagrant:defs.bzl", "qcow_to_vagrant_box")
# load("@rules_python//python:pip.bzl", "compile_pip_requirements")

# compile_pip_requirements(
# name = "requirements",
# extra_args = ["--allow-unsafe"],
# requirements_in = "requirements.txt",
# requirements_txt = "requirements_lock.txt",
# )

# packer_image(
# name = "hypervisor_image",
Expand Down
1 change: 0 additions & 1 deletion hypervisor/requirements.txt

This file was deleted.

412 changes: 0 additions & 412 deletions hypervisor/requirements_lock.txt

This file was deleted.

10 changes: 1 addition & 9 deletions infrastructure/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
load("@rules_task//:defs.bzl", "cmd", "task")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@infrastructure-requirements//:requirements.bzl", "requirement")
load("@pip-setup//:requirements.bzl", "requirement")

package(default_visibility = ["//visibility:public"])

compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements.lock",
)

task(
name = "pulumi",
cmds = [
Expand Down
3 changes: 0 additions & 3 deletions infrastructure/requirements.in

This file was deleted.

246 changes: 0 additions & 246 deletions infrastructure/requirements.lock

This file was deleted.

10 changes: 1 addition & 9 deletions occupancy_component/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@occupancy_component//:requirements.bzl", "requirement")
load("@pip-setup//:requirements.bzl", "requirement")
load("//tools/pytest:pytest.bzl", "py_pytest_test")
load("@rules_task//:defs.bzl", "cmd", "task")

compile_pip_requirements(
name = "requirements",
extra_args = ["--allow-unsafe"],
requirements_in = "requirements.in",
requirements_txt = "requirements.lock",
)

py_library(
name = "lib",
srcs = [
Expand Down
2 changes: 0 additions & 2 deletions occupancy_component/requirements.in

This file was deleted.

10 changes: 10 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
black==23.3.0;
pytest==7.1.2;
pytest-cov==3.0.0;
pulumi==3.60.1;
pulumi-command==0.7.1;
pulumi-kubernetes==3.24.2;
pytest-homeassistant-custom-component==0.11.20;
tzdata==2023.3;
pyinfra==2.6.2
sqlalchemy==1.4.40;
Loading

0 comments on commit 7f12db4

Please sign in to comment.