aka-raccoon / hatch-aws

Hatch plugin for building AWS Lambda functions with SAM
MIT License
13 stars 3 forks source link

Support for `uv` installer #14

Open JP-Ellis opened 3 months ago

JP-Ellis commented 3 months ago

Summary

It would appear hatch-aws uses pip under the hood all the time, resulting in an error when installer = "uv" is used in the Hatch configuration.

Background

Hatch added support for using uv pip install ... instead of a regular pip install .... You can see the docs over at: https://hatch.pypa.io/latest/how-to/environment/select-installer/. When uv is used as the install, pip is not available within the venv.

For most purposes, it should be a drop in replacement, though in my experience there are a couple of edge cases where they might differ.

Traceback

``` Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/Users/JP-Ellis/Library/Application Support/hatch/env/virtual/mypkg/aTIHFqUV/mypkg-build/lib/python3.12/site-packages/hatchling/__main__.py", line 6, in sys.exit(hatchling()) ^^^^^^^^^^^ File "/Users/JP-Ellis/Library/Application Support/hatch/env/virtual/mypkg/aTIHFqUV/mypkg-build/lib/python3.12/site-packages/hatchling/cli/__init__.py", line 26, in hatchling command(**kwargs) File "/Users/JP-Ellis/Library/Application Support/hatch/env/virtual/mypkg/aTIHFqUV/mypkg-build/lib/python3.12/site-packages/hatchling/cli/build/__init__.py", line 82, in build_impl for artifact in builder.build( File "/Users/JP-Ellis/Library/Application Support/hatch/env/virtual/mypkg/aTIHFqUV/mypkg-build/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 155, in build artifact = version_api[version](directory, **build_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/JP-Ellis/Library/Application Support/hatch/env/virtual/mypkg/aTIHFqUV/mypkg-build/lib/python3.12/site-packages/hatch_aws/builder.py", line 103, in build_standard self.build_lambda(aws_lambda=aws_lambda, shared_files=shared_files) File "/Users/JP-Ellis/Library/Application Support/hatch/env/virtual/mypkg/aTIHFqUV/mypkg-build/lib/python3.12/site-packages/hatch_aws/builder.py", line 60, in build_lambda check_call( File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 413, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/Users/JP-Ellis/Library/Application Support/hatch/env/virtual/mypkg/aTIHFqUV/mypkg-build/bin/python', '-m', 'pip', 'install', '--upgrade', '--disable-pip-version-check', '--no-python-version-warning', '-r', '{path}/.aws-sam/build/Gateway/accord_api/gateway/requirements.txt', '-t', '{path}/.aws-sam/build/Gateway']' returned non-zero exit status 1. ```
Levelleor commented 4 days ago

I agree! It would be great to see this work with uv.