
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
This is a Bazel Runfiles lookup library for Bazel-built Python binaries and tests.
Learn about runfiles: read Runfiles guide or watch Fabian's BazelCon talk.
The Runfiles API is available from two sources, a direct Bazel target, and a pypi package.
Depend on this runfiles library from your build rule, like you would other third-party libraries:
py_binary(
name = "my_binary",
# ...
deps = ["@rules_python//python/runfiles"],
)
Import the runfiles library:
from python.runfiles import Runfiles
Add the 'bazel-runfiles' dependency along with other third-party dependencies, for example in your requirements.txt
file.
Depend on this runfiles library from your build rule, like you would other third-party libraries:
load("@pip_deps//:requirements.bzl", "requirement")
py_binary(
name = "my_binary",
...
deps = [requirement("bazel-runfiles")],
)
Import the runfiles library:
from runfiles import Runfiles
Create a Runfiles
object and use Rlocation
to look up runfile paths:
r = Runfiles.Create()
# ...
with open(r.Rlocation("my_workspace/path/to/my/data.txt"), "r") as f:
contents = f.readlines()
# ...
Here my_workspace
is the name you specified via module(name = "...")
in your MODULE.bazel
file (with --enable_bzlmod
, default as of Bazel 7) or workspace(name = "...")
in WORKSPACE
(with --noenable_bzlmod
).
The code above creates a manifest- or directory-based implementation based on the environment variables in os.environ
. See Runfiles.Create()
for more info.
If you want to explicitly create a manifest- or directory-based implementation, you can do so as follows:
r1 = Runfiles.CreateManifestBased("path/to/foo.runfiles_manifest")
r2 = Runfiles.CreateDirectoryBased("path/to/foo.runfiles/")
If you want to start subprocesses that access runfiles, you have to set the right environment variables for them:
import subprocess
from python.runfiles import Runfiles
r = Runfiles.Create()
env = {}
# ...
env.update(r.EnvVars())
p = subprocess.run(
[r.Rlocation("path/to/binary")],
env=env,
# ...
)
FAQs
Unknown package
We found that bazel-runfiles demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.