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

compile_pip_requirements does not work when the requirements.in is a result of a rule #860

Closed
ns-ggeorgiev opened this issue Oct 15, 2022 · 5 comments

Comments

@ns-ggeorgiev
Copy link

🐞 bug report

Affected Rule

rule compile_pip_requirements

Is this a regression?

no

Description

when I provide requirements.in file that is generated from a rule, compile_pip_requirements fails file not found, because it is looking for the file in the workspace, instead of bazel sanbox area.

🔬 Minimal Reproduction

genrule(
        name = "requirements_in",
        outs = ["requirements.in"],
        cmd = "echo six > \"$@\"",
    )

compile_pip_requirements(
    name = "requirements",
    requirements_in = ":requirements_in",
    requirements_txt = "requirements.txt",
)

🔥 Exception or Error



Updating bzl/requirements/requirements.txt
Usage: pip_compile.py [OPTIONS] [SRC_FILES]...
Try 'pip_compile.py -h' for help.

Error: Invalid value for '[SRC_FILES]...': Path 'bzl/requirements/requirements.in' does not exist.

@rickeylev
Copy link
Contributor

rickeylev commented Oct 15, 2022 via email

@jvolkman
Copy link
Contributor

Is this fixed by #829?

@rickeylev
Copy link
Contributor

Oh, I see. I stand corrected!

@groodt
Copy link
Collaborator

groodt commented Oct 15, 2022

Oh, I see. I stand corrected!

Only in a sense. The repository rules for locking dependencies probably need a bit more documentation written around them to list the caveats. There are quite a few problematic areas (relative file paths, non-hermetic, platform specific, coupled to a format that might change and rules don’t control) that I think as maintainers we should have the freedom to change if necessary.

@ns-ggeorgiev
Copy link
Author

ns-ggeorgiev commented Oct 16, 2022

The way I solved the same was just adding the following just before changing the current directory to the workspace directory

        if not shutil._samefile(requirements_in, os.path.join(os.environ["BUILD_WORKSPACE_DIRECTORY"], requirements_in)):
            requirements_in = os.path.abspath(requirements_in)

but #829 seems to resolves the issue as well.

I am closing this.

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

4 participants