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

add py_binary rule for console_scripts #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chaoran
Copy link

@chaoran chaoran commented Mar 22, 2019

Add py_binary rule if there is console_scripts entry_point defined for the package.

@Globegitter
Copy link

ping @apt-itude would be a nice one to have

py_binary(
name = "{rule}",
srcs = ["bin/{entry_point}.py"],
deps = [":{library_name}"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to provide main = "bin/{entry_point}.py" here, because in the case when {rule} has bin- prepended it won't match automatically.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Thank for catching that.

@Globegitter
Copy link

@chaoran not sure if you also ran into the issues but it seems py_binary targets are causing issues, see: bazelbuild/bazel#7091 (comment)

@chaoran
Copy link
Author

chaoran commented May 16, 2019

@Globegitter Yes, I just tried to run bazel run @pip_deps//pytest:bin-pytest. It gave me an error ImportError: module 'pytest' has no attribute 'main'. I was using a python library that happen to not use the same name for the library and binary file, which didn't cause me any trouble. But, anyway, I gradually start to realize that using python with bazel is lost hope. I'm waiting for Google to support python in bazel natively before I do something serious with it.

BTW I guess adding a genrule to rename the binary xxx.py file to bin-xxx.py would workaround the issue? I haven't tried it yet.

@Globegitter
Copy link

@chaoran - the way I got around this is by providing a patch functionality to a forked version of rules_pip. See ecosia@adce162

Yeah hopefully it keeps on improving over the coming weeks/months. Now with the toolchain support there is not much missing anymore from getting it to work nicely in an OSS environment.

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

Successfully merging this pull request may close these issues.

2 participants