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

Several pip fixes for Python hydration #186

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

Conversation

lpsinger
Copy link
Contributor

  • Permit installing Python packages from source if host and target match.

    Some Python packages must be installed from source: either PyPI
    only holds source distributions of them, or lacks wheels for the
    target platform. If the host platform matches the target Lambda
    platform, then permit installation of Python packages from source.

  • Use pip --version, not pip list, to test for working pip

    pip list can be very time consuming if there are many packages
    installed. pip --version is fast regardless.

  • Invoke pip using python3 -m pip rather than pip3

    This is closer to the recommended way to invoke pip according to the
    latest pip documentation.

    The reason why this invocation is more robust is that it only
    requires the Python interpreter itself to be on the PATH, and it is
    robust to the bin directory corresponding to site-packages being
    omitted from the PATH (usually by accident).

Thank you for helping out! ✨

We really appreciate your commitment to improving Architect

To maintain a high standard of quality in our releases, before merging every pull request we ask that you've completed the following:

  • Forked the repo and created your branch from master
  • Made sure tests pass (run npm it from the repo root)
  • Expanded test coverage related to your changes:
    • Added and/or updated unit tests (if appropriate)
    • Added and/or updated integration tests (if appropriate)
  • Updated relevant documentation:
  • Summarized your changes in changelog.md
  • Linked to any related issues, PRs, etc. below that may relate to, consume, or necessitate these changes

Please also be sure to completed the CLA (if you haven't already).

Learn more about contributing to Architect here.

Thanks again!

This is closer to the recommended way to invoke pip according to the
[latest pip documentation](https://pip.pypa.io/en/stable/getting-started/).

The reason why this invocation is more robust is that it only
requires the Python interpreter itself to be on the PATH, and it is
robust to the bin directory corresponding to site-packages being
omitted from the PATH (usually by accident).
`pip list` can be very time consuming if there are many packages
installed. `pip --version` is fast regardless.
Some Python packages _must_ be installed from source: either PyPI
only holds source distributions of them, or lacks wheels for the
target platform. If the host platform matches the target Lambda
platform, then permit installation of Python packages from source.
@lpsinger
Copy link
Contributor Author

lpsinger commented Feb 5, 2024

Any news on this?

@ryanblock
Copy link
Member

@lpsinger thanks for your patience! As you may have seen, my focus has been on shipping aws-lite and Arc 11; soon I'll be returning to PRs and work unrelated to that end!

@lpsinger
Copy link
Contributor Author

lpsinger commented Mar 5, 2024

Any updates on this?

@ryanblock
Copy link
Member

Some Python packages must be installed from source: either PyPI only holds source distributions of them, or lacks wheels for the target platform. If the host platform matches the target Lambda platform, then permit installation of Python packages from source.

Yeah, I found that to be the case for some packages, but not many; my recollection at the time of building this Python integration was that the current best practice for packaging was a binary dist. Whereas the approach I took here is more rigid in its requirements for the published package, it is also significantly more deterministic, which is a quality we look for in Architect deployments. Ultimately I'm amenable to this change, but it'll need to be accompanied by at least the same level of testing rigor as we have for the other Python hydration stuff.

pip list can be very time consuming if there are many packages installed. pip --version is fast regardless.

As of this time we must run pip list to see if pipdeptree is present; this cannot be avoided. As you can see in the implementation, we only run this operation one time, then store the result in global state to prevent re-running it. Related: src/actions/autoinstall/python/check-py-tools.js is vestigial from an earlier implementation and can now be deleted; src/actions/autoinstall/python/get-dep-tree.js.

python3 -m pip... is closer to the recommended way to invoke pip according to the latest pip documentation.

Seems reasonable!

@lpsinger
Copy link
Contributor Author

We recently split off the part of our project that was written in Python into a separate project that does not use Architect. I'm not supporting that part of our project, so I will not be taking this PR any further at the moment.

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

Successfully merging this pull request may close these issues.

2 participants