Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requirement helper function has incorrect workspace name? #135

Open
njlr opened this issue Dec 16, 2024 · 0 comments
Open

requirement helper function has incorrect workspace name? #135

njlr opened this issue Dec 16, 2024 · 0 comments

Comments

@njlr
Copy link
Contributor

njlr commented Dec 16, 2024

This works for me:

# ...
  deps = [
    "@poetry_lock_repo//deps:pytest",
  ],
)

But this does not:

load("@poetry_lock_repo//:requirements.bzl", "requirement")

# ...

  deps = [
    requirement("pytest"),
  ],
)

If I do the following:

print(requirement("pytest"))

I get:

@rules_pycross~~lock_file~poetry_lock_repo//deps:pytest

This doesn't match "@poetry_lock_repo//deps:pytest".

Is there a bug in the requirement helper function?

requirements.bzl

load("@@//tools/bazel/poetry:poetry_lock.bzl", "PINS", "repositories")

def requirement(pkg):
    # Convert given name into normalized package name.
    # https://packaging.python.org/en/latest/specifications/name-normalization/#name-normalization
    pkg = pkg.replace("_", "-").replace(".", "-").lower()
    for i in range(len(pkg)):
        if "--" in pkg:
            pkg = pkg.replace("--", "-")
        else:
            break
    return "@rules_pycross~~lock_file~poetry_lock_repo//deps:%s" % pkg

all_requirements = ["@rules_pycross~~lock_file~poetry_lock_repo//deps:%s" % v for v in PINS.values()]

install_deps = repositories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant