Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Make spread_purelib_into_root behave like the wheel was installed by pip #581

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

Merged
merged 1 commit into from
Dec 29, 2021

Conversation

hrfuller
Copy link
Contributor

@hrfuller hrfuller commented Dec 23, 2021

Merge purelib dir into toplevel even if purelib and toplevel have
subdirs with the same name. See tensorflow-io for an example of
a package which was not installed correctly by rules_python before this
change.

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?

In pip_install and pip_parse rule if you try to install a wheel which has Root-Is-Purelib: false (tensorflow-io is an example), python sources in the .data/purelib dir will not be merged into the root because we skip children of the purelib which have the same basename as a directory in the top level of the wheel.

What rules_python does currently: https://gist.github.com/hrfuller/ccc0420cd5b72b38f6151fa1b5c811e0

After running the example open up the created repo in the bazel output base, and notice that purelib directory is not merged.

This leads to issues where tensorflow_io python sources cannot be imported.

Issue Number: N/A

What is the new behavior?

Descendants of the purelib directory will be merged with existing directories in the top level, but will not overwrite any files in the toplevel. This is the same thing that pip does when you install a wheel.

To verify this run

pip install --no-deps --only-binary :all: --target tfio tensorflow-io==0.19.0

Compare the shape of the tfio directory with the external repo bazel generated using the gist above.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

pip.

Merge purelib dir into toplevel even if purelib and toplevel have
subdirs with the same name. See tensorflow-io for an example of
a package which was not installed correctly by rules_python before this
change.
@alexeagle alexeagle force-pushed the merge-purelib-into-root branch from 7e083a7 to a5381b7 Compare December 29, 2021 16:19
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.

Thanks for the great writeup explaining the problem and approach :)

@alexeagle alexeagle merged commit bb04a49 into bazel-contrib:main Dec 29, 2021
@hrfuller hrfuller deleted the merge-purelib-into-root branch December 29, 2021 16:39
for child in purelib_dir.iterdir():
if child.is_dir():
backport_copytree(src=child, dst=pathlib.Path(root_dir, child.name))
elif not pathlib.Path(root_dir, grandchild.name).exists():

Choose a reason for hiding this comment

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

I think grandchild -> child is a needed patch, to avoid NameError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks for catching that. Will provide a patch.

hrfuller added a commit that referenced this pull request Jan 14, 2022
Follow up for #581 fixing undefined name.
@hrfuller hrfuller mentioned this pull request Jan 14, 2022
12 tasks
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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.