Skip to content

Commit

Permalink
Build and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Putt committed Dec 20, 2024
1 parent d79a222 commit 87793df
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 52 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,6 @@ jobs:
run: |
isort --check-only req_compile
bazel-workspace:
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-latest", "macos-14", "windows-latest"]
runs-on: ${{ matrix.platform }}
name: bazel test --build ${{ matrix.platform }} (WORKSPACE.bazel)
steps:
- uses: actions/checkout@v2
- name: Configure Build Event Service
run: |
echo "common --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}" > "${CI_BAZELRC_PATH}"
echo "common --config=bes" >> "${CI_BAZELRC_PATH}"
echo "common --announce_rc" >> "${CI_BAZELRC_PATH}"
env:
CI_BAZELRC_PATH: .github/ci.bazelrc
- name: Run Tests
run: |
bazel test --noenable_bzlmod --enable_workspace //...
- name: Perform compilation
run: |
bazel run --noenable_bzlmod --enable_workspace //3rdparty:requirements_compiler "--" --upgrade
bazel-bzlmod:
strategy:
fail-fast: false
Expand Down
27 changes: 14 additions & 13 deletions extensions/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def _requirements_impl(ctx):
annotations = {}

override_module_repos = {}
interpreter = None

# Gather all annotations first.
for mod in ctx.modules:
Expand All @@ -34,6 +35,19 @@ def _requirements_impl(ctx):
patches = annotation.patches,
)
for parse in mod.tags.parse:
# Determine the interpreter to use, if provided. This is required for
# source dists.
if not interpreter:
if ctx.os.name == "mac os x":
if ctx.os.arch == "amd64":
interpreter = parse.interpreter_macos_intel
else:
interpreter = parse.interpreter_macos_aarch64
elif ctx.os.name == "linux":
interpreter = parse.interpreter_linux
elif ctx.os.name.startswith("windows"):
interpreter = parse.interpreter_windows

if mod.is_root and parse.override_module_repos:
for override_mod, override_repos in parse.override_module_repos.items():
if override_mod in override_module_repos:
Expand All @@ -51,19 +65,6 @@ def _requirements_impl(ctx):
continue
created_repos[parse.name] = parse

# Determine the interpreter to use, if provided. This is required for
# source dists.
interpreter = None
if ctx.os.name == "mac os x":
if ctx.os.arch == "amd64":
interpreter = parse.interpreter_macos_intel
else:
interpreter = parse.interpreter_macos_aarch64
elif ctx.os.name == "linux":
interpreter = parse.interpreter_linux
elif ctx.os.name.startswith("windows"):
interpreter = parse.interpreter_windows

py_requirements_repository(
name = parse.name,
hub_name = parse.name,
Expand Down
13 changes: 2 additions & 11 deletions private/reqs_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ filegroup(
)
"""

def parse_constraint(data, repository_name, lockfile, wheel_dirs):
def parse_constraint(data, lockfile, wheel_dirs):
"""Parse a section of a requirements lock file from `req-compile`.
Args:
data (list): The stripped lines of a constraint's section in a lock file.
repository_name (str): The name of the current repository.
lockfile (Label): The label of the current lockfile. Used to resolve paths to
constraints represented by relative paths instead of urls.
wheel_dirs (list): A list of strings that represent directories containing
Expand Down Expand Up @@ -245,15 +244,13 @@ def parse_constraint(data, repository_name, lockfile, wheel_dirs):

def parse_lockfile(
content,
repository_name,
annotations,
lockfile,
constraint = None):
"""Parse a requirements lock file into a map of constraints.
Args:
content (str): The string content of a requirements lock file.
repository_name (str): The name of the current repository
annotations (dict): Annotation data for packages in the current lock file.
lockfile (Label): The label of the lockfile containing `content`.
constraint (Label): An optional Label which represents the constraint value of the package.
Expand All @@ -277,7 +274,6 @@ def parse_lockfile(
if not text or not text.startswith(("#", "-")):
entries.append(parse_constraint(
capturing,
repository_name,
lockfile,
wheel_dirs,
))
Expand All @@ -295,7 +291,6 @@ def parse_lockfile(
if capturing:
entries.append(parse_constraint(
capturing,
repository_name,
lockfile,
wheel_dirs,
))
Expand Down Expand Up @@ -340,12 +335,11 @@ def _write_defs_file(repository_ctx, hub_name, packages, defs_output, id = "", n
interpreter = repr(repository_ctx.attr.interpreter),
))

def _process_lockfile(ctx, hub_name, requirements_lock, annotations = None, constraint = None):
def _process_lockfile(ctx, requirements_lock, annotations = None, constraint = None):
"""Convert a lockfile into a map of packages.
Args:
ctx (repository_ctx): The repository or module context object
hub_name: Name of the hub to process the lock file for.
requirements_lock (Label): The label of the lock file.
annotations: The annotations to apply to the requirements from this lock.
constraint (Label, optional): An optional constraint label associated
Expand All @@ -362,7 +356,6 @@ def _process_lockfile(ctx, hub_name, requirements_lock, annotations = None, cons

packages = parse_lockfile(
content = content,
repository_name = hub_name,
annotations = annotations or {},
lockfile = requirements_lock,
constraint = constraint,
Expand Down Expand Up @@ -519,7 +512,6 @@ def parse_requirements_locks(hub_name, ctx, attrs, annotations):
if attrs.requirements_lock:
packages = _process_lockfile(
ctx = ctx,
hub_name = hub_name,
requirements_lock = attrs.requirements_lock,
annotations = annotations,
)
Expand All @@ -536,7 +528,6 @@ def parse_requirements_locks(hub_name, ctx, attrs, annotations):

packages = _process_lockfile(
ctx = ctx,
hub_name = hub_name,
requirements_lock = lock,
constraint = constraint,
annotations = annotations,
Expand Down
1 change: 0 additions & 1 deletion private/tests/override_module_repos/overrider/bazel-bin

This file was deleted.

1 change: 0 additions & 1 deletion private/tests/override_module_repos/overrider/bazel-out

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion private/tests/unit/parse_lockfile_test_suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def _parse_lockfile_test_impl(ctx):

constraints = parse_lockfile(
content = ctx.attr.content,
repository_name = "parse_lockfile_test",
annotations = {},
lockfile = Label(ctx.attr.mock_lockfile),
)
Expand Down

0 comments on commit 87793df

Please sign in to comment.