fix: Pip not resolving local packages#250
Conversation
| """Wrapper around pip calls used by chalice.""" | ||
|
|
||
| _LINK_IS_DIR_PATTERN = "Processing (.+?)\n Link is a directory, ignoring download_dir" | ||
| _LINK_IS_DIR_PATTERNS = ["Processing (.+?)\n Link is a directory, ignoring download_dir", "Processing (.+?)\n"] |
There was a problem hiding this comment.
- You can add some docs on why the pattern is changed.
- Match the second one should always match the first. I believe you have already deduplicated this case, but you can simplify it.
- If we only match "Processing sth.", will we introduce non-dir links?
There was a problem hiding this comment.
- I can definitely go ahead and add some docs.
- It is true for this case, but in the future if the output is to change again, there's no guarantee that the new string will be a subset of the old one. Doing it this way should be more extensible and backwards compatible. It also prevents from having to re-write existing pip test stubs that explicitly write out
Processing (.+?)\n Link is a directory, ignoring download_dir. However, if you think removing theLink is a directory, ignoring download_dirpattern is more appropriate, I can certainly go ahead and do that. - This was my main concern. Searching through the pip code, though, I think this should be okay as it doesn't appear to log this type of pattern anywhere else. This could always change, but that's the nature of this type of implementation.
There was a problem hiding this comment.
For 2, You have done a good change on making it a list. You can just keep the second one since the first one is not necessary.
There was a problem hiding this comment.
Won’t that break customers using an older version of pip?
There was a problem hiding this comment.
I don't think it would because the matched group will be the same in both cases, and anything matched by Processing (.+?)\n Link is a directory, ignoring download_dir will also be matched by Processing (.+?)\n. I just tested this and it seems to be fine. If there is backward compatibility concern, I can also include the old pattern.
|
if this fix is preferred over #249, can I ask that you at least include the integration test case from that change? |
|
yes, that setup tests specifically the scenario where requirements.txt has just one entry, this was how I discovered the bug and I'd like to be sure that if a future change conflicts with this setup, the tests will catch it. |
|
I've updated the integration test to match file structure you defined. If there is a similar breaking change in the future, it will catch it. |
|
thanks, that meets my ask entirely. if it wasn't clear, I was suggesting to keep your test case (it seems useful to me) and add mine as an additional test; whether to do that or replace it as you've done is entirely up to y'all. Either way I really appreciate your attention. |
jfuss
left a comment
There was a problem hiding this comment.
Looks good to me. Just a question on one of the tests.
| pip, runner = pip_runner | ||
| appdir, builder = self._make_appdir_and_dependency_builder(reqs, tmpdir, runner) | ||
| requirements_file = os.path.join(appdir, "requirements.txt") | ||
| pip.set_return_tuple(0, (b"Processing ../foo\n" b" Link is a directory," b" ignoring download_dir"), b"") |
There was a problem hiding this comment.
Wonder if we should keep thins so we know we don't break back compat? Or make this output from pip parameterized to test both cases?
There was a problem hiding this comment.
Reverted those tests to keep using the old output string. Updated the unit tests to test a mixture of reading both new and old.
|
@wchengru @jfuss @mildaniel thanks for your work and attention on this. Any idea when this change will make it to a release of aws-sam-cli? |
* feat: Allow Python runtime to build without requiring a manifest (#243) * Allow Python to continue build without requirements.txt * Allow missing requirements.txt file for Python builds * Ruby optional Gemfile and test * Style changes * Add unit tests and additional comments * Fix assertLogs() not compatible with Python2.7 * Fix assertion string * Remove unused exception * Integ. test make sure no artifacts dir has no additional files after build * Kick off build * Check for manifest and skip package actions if not found * Revert Ruby changes until further discussion is had. Make Python workflow more readable. * Remove unused import * Whitespace fix * feat: Allow Ruby runtime to build without requiring a manifest (#245) * Allow Python to continue build without requirements.txt * Allow missing requirements.txt file for Python builds * Ruby optional Gemfile and test * Style changes * Add unit tests and additional comments * Fix assertLogs() not compatible with Python2.7 * Fix assertion string * Remove unused exception * Integ. test make sure no artifacts dir has no additional files after build * Kick off build * Check for manifest and skip package actions if not found * Revert Ruby changes until further discussion is had. Make Python workflow more readable. * Remove unused import * Whitespace fix * Readability changes for Ruby workflow * Remove magic number. Add link to Bundler error codes * Moved var declaration * docs: Guidance on integrating with Lambda Builders (#242) * fix: README - showcase Makefile support (#247) * Update VS2017 to VS2019 (#244) * fix: Pip not resolving local packages (#250) * Fix local packages not being built * Add int. test to catch future local dependency issues * Specify test requirements path from cwd * Removed redundant/superset pattern * Document the pip regex pattern change * Updated integ to match use case * Tests to check backward comp. * chore: bump version to 1.5.0 (#254) Co-authored-by: Daniel Mil <84205762+mildaniel@users.noreply.github.com> Co-authored-by: Giorgio Azzinnaro <giorgio.azzinnaro@gmail.com> Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>
Which issue(s) does this change fix?
aws/aws-sam-cli#2705
Why is this change necessary?
Fix local dependencies not being resolved by pip.
How does it address the issue?
Looks like pip updated the output that we try to string match, meaning we weren't catching local packages for newer versions of pip.
This change adds multiple layers of regex matching to include both the old and new output format.
What side effects does this change have?
Checklist:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.