Skip to content

Commit

Permalink
feat: add update Boolean attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Nov 3, 2023
1 parent ce30a01 commit 5aff83d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ packages = [{include = "rules_poetry"}]

[tool.poetry.dependencies]
python = "^3.9"
poetry = "1.4.1"
poetry = "1.6.1"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion python/patches/scripts_executable.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
script_template = SCRIPT_TEMPLATE

- executable = None # for shebangs
+ executable = "#!/usr/bin/env python4" # for shebangs
+ executable = "#!/usr/bin/env python3" # for shebangs

def __init__(self, source_dir, target_dir, add_launchers=True,
dry_run=False, fileop=None):
Expand Down
5 changes: 3 additions & 2 deletions python/poetry.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ from pathlib import Path
_LOCK_FILE_NAME = "poetry.lock"
if __name__ == "__main__":
import os
sys.path = {deps} + sys.path
dir = Path('{toml}').parent
lock = Path('{lock}')
Expand All @@ -20,13 +19,14 @@ if __name__ == "__main__":
if poetry_lock.exists():
poetry_lock.unlink()
poetry_lock.symlink_to(lock.resolve())
sys.argv = [sys.argv[0], "lock", "--no-update", f"--directory={{dir}}"]
sys.argv = [sys.argv[0], "lock", f"--directory={{dir}}"{update}]
runpy.run_module("poetry", run_name="__main__", alter_sys=True)
""".format(
python = _python,
deps = repr(["../{}".format(path) for path in ctx.attr._poetry_deps[PyInfo].imports.to_list()]),
toml = ctx.attr.toml.files.to_list().pop().short_path,
lock = ctx.attr.lock.files.to_list().pop().short_path,
update = "" if ctx.attr.update else ', "--no-update"',
)

output = ctx.actions.declare_file(ctx.label.name + ".update")
Expand All @@ -44,6 +44,7 @@ poetry_update = rule(
attrs = {
"toml": attr.label(allow_single_file = [".toml"]),
"lock": attr.label(allow_single_file = [".lock"]),
"update": attr.bool(default = True),
"_poetry_deps": attr.label(default = "@rules_poetry_deps//:pkg"),
},
)
4 changes: 2 additions & 2 deletions python/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ _PACKAGES_ENDPOINT = "https://files.pythonhosted.org/packages/"
_POETRY_INTERNAL_DEPS = [
(
"pip",
_PACKAGES_ENDPOINT + "50/c2/e06851e8cc28dcad7c155f4753da8833ac06a5c704c109313b8d5a62968a/pip-23.2.1-py3-none-any.whl",
"7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be",
_PACKAGES_ENDPOINT + "47/6a/453160888fab7c6a432a6e25f8afe6256d0d9f2cbd25971021da6491d899/pip-23.3.1-py3-none-any.whl",
"55eb67bb6171d37447e82213be585b75fe2b12b359e993773aca4de9247a052b",
[":patches/scripts_executable.patch"],
),
]
Expand Down

0 comments on commit 5aff83d

Please sign in to comment.