Skip to content

Don't delete wheels from external repos with pip_parse#458

Merged
hrfuller merged 1 commit intobazel-contrib:masterfrom
person142:pip-parse-keep-wheels
Apr 21, 2021
Merged

Don't delete wheels from external repos with pip_parse#458
hrfuller merged 1 commit intobazel-contrib:masterfrom
person142:pip-parse-keep-wheels

Conversation

@person142
Copy link
Copy Markdown
Contributor

@person142 person142 commented Apr 18, 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?

Issue Number: N/A

Wheel targets are broken with pip_parse. This is because currently pip_parse extracts the wheel into the repository root, but then deletes it here:

https://github.com/bazelbuild/rules_python/blob/master/python/pip_install/extract_wheels/lib/bazel.py#L251

This doesn't happen for pip_install because it copies the wheel into the relevant subdirectory:

https://github.com/bazelbuild/rules_python/blob/master/python/pip_install/extract_wheels/lib/bazel.py#L212

What is the new behavior?

Instead of deleting the wheel unconditionally, only do it for the non-incremental case.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

None

class TestWhlFilegroup(unittest.TestCase):
def setUp(self) -> None:
self.wheel_name = "example_minimal_package-0.0.1-py3-none-any.whl"
self.wheel_dir = tempfile.mkdtemp()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the extraction into a temporary directory to keep the runfiles tree clean between test cases.

build_file.write(contents)

os.remove(whl.path)
if not incremental:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The relevant non test change.

@person142 person142 force-pushed the pip-parse-keep-wheels branch from cd2cde6 to b122c27 Compare April 18, 2021 23:48
@person142
Copy link
Copy Markdown
Contributor Author

Ping @hrfuller for this (sorry wish I could request reviews like a normal human).

)[2:] # Take off the leading // from the returned label.
# Assert that the raw wheel ends up in the package.
self.assertIn(wheel_name, os.listdir(generated_bazel_dir))
self.assertIn(self.wheel_name, os.listdir(generated_bazel_dir))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only thing I did differently was also assert a test case that the original wheel at the root is removed in the non-incremental case.

@hrfuller hrfuller merged commit 017eb4f into bazel-contrib:master Apr 21, 2021
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