google / subpar

Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.
Apache License 2.0
567 stars 69 forks source link

Don't parse stub file if interpreter is explicitly provided #128

Open dflems opened 3 years ago

dflems commented 3 years ago

It seems like --stub_file is only parsed to derive which interpreter is being used. Correct me if I'm wrong, but it seems like passing in --interpreter should short-circuit parsing that file. Seems like this will allow for using in-workspace py_runtime definitions as long as the interpreter is specified explicitly in the parfile() rule.

I might be missing some important context though.

oxidase commented 3 years ago

I had the same issue with non-system Python runtimes as parsing stubs before checking args.interpreter exits with an exception. I'll dismiss my PR #129 as this PR also add interpreter to the attributes list that is better than my workaround compiler_args = ["--interpreter", "/usr/bin/python3"],

@brandjon please could you review the fix.

dflems commented 3 years ago

closing and reopening to kickstart CI (which didn't seem to pick up my last commit)

dflems commented 3 years ago

@brandjon :wave: does anyone pay attention to this repo? 😢

thundergolfer commented 3 years ago

Seems like this will allow for using in-workspace py_runtime definitions as long as the interpreter is specified explicitly in the parfile() rule.

If you have an in-workspace interpreter at label @python3//:bin/python3 won't passing this as interpreter value result in a .par with a shebang like:

#!@python3//:bin/python3

How does the in-workspace interpreter label get translated into an absolute filepath?

dflems commented 3 years ago

@thundergolfer Ah that's true... On my end, I'm setting interpreter to /usr/bin/env python3 as we have some par_binarys that we export as internal tools