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

pip_parse and pip_install can now parse entry points from wheels #523

Merged
merged 12 commits into from
Sep 5, 2021

Conversation

UebelAndre
Copy link
Contributor

@UebelAndre UebelAndre commented Sep 1, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

  • Does not include precompiled binaries, eg. .par files. See CONTRIBUTING.md for info
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Currently, there is no way to access binaries (or entry points) associated with a wheel in python. This has been a rather annoying problem since it expects users to manually generate it themselves. A process for which there's currently there's no guidance on. This PR aims to solve that by generating these targets automatically.

Issue Number: #341

What is the new behavior?

Both pip_install and pip_parse now generate py_binary targets for each entry point in a wheel. These are accessible via the entry_point macro which has been added to the requirements.bzl files generated by these repository rules.

To use this new functionality, you simply load the entry_point macro:

load("@pip_deps//:requirements.bzl", "entry_point")

alias(
    name = "flake8",
    actual = entry_point("flake8"),
)

Then. the target can be run just like any other py_binary.

bazel run //:flake8 -- --version
3.9.2 (mccabe: 0.6.1, pycodestyle: 2.7.0, pyflakes: 2.3.1) CPython 3.9.6 on Darwin

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla google-cla bot added the cla: yes label Sep 1, 2021
@UebelAndre UebelAndre force-pushed the entrypoint branch 17 times, most recently from 0e5c7ea to 7b7579d Compare September 2, 2021 18:42
@UebelAndre UebelAndre marked this pull request as ready for review September 2, 2021 18:43
@UebelAndre UebelAndre force-pushed the entrypoint branch 2 times, most recently from daf4f5a to 6ec6075 Compare September 2, 2021 22:29
@UebelAndre UebelAndre requested a review from alexeagle September 5, 2021 17:21
@alexeagle
Copy link
Contributor

This is awesome! thanks, I'll merge and go patch into a client codebase and see if we can remove some of our wrappers.

I bet the working directory issue will still be a problem, but that's a missing feature in py_binary to essentially cd right before invoking the python interpreter

Copy link
Contributor

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

🌮

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

Successfully merging this pull request may close these issues.

2 participants