Merge pull request #390 from karlb/uv-python-deploy

Add support for python deployments with uv
pull/396/head
Rui Carmo 2025-01-26 22:17:20 +00:00 zatwierdzone przez GitHub
commit 669fcbfedd
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 24 dodań i 0 usunięć

24
piku.py
Wyświetl plik

@ -398,6 +398,8 @@ def do_deploy(app, deltas={}, newrev=None):
settings.update(deploy_python(app, deltas))
elif exists(join(app_path, 'pyproject.toml')) and which('poetry') and found_app("Python"):
settings.update(deploy_python_with_poetry(app, deltas))
elif exists(join(app_path, 'pyproject.toml')) and which('uv') and found_app("Python (uv)"):
settings.update(deploy_python_with_uv(app, deltas))
elif exists(join(app_path, 'Gemfile')) and found_app("Ruby Application") and check_requirements(['ruby', 'gem', 'bundle']):
settings.update(deploy_ruby(app, deltas))
elif exists(join(app_path, 'package.json')) and found_app("Node") and (
@ -750,6 +752,28 @@ def deploy_python_with_poetry(app, deltas={}):
return spawn_app(app, deltas)
def deploy_python_with_uv(app, deltas={}):
"""Deploy a Python application using Astral uv"""
echo("=====> Starting EXPERIMENTAL uv deployment for '{}'".format(app), fg='red')
env_file = join(APP_ROOT, app, 'ENV')
virtualenv_path = join(ENV_ROOT, app)
# Set unbuffered output and readable UTF-8 mapping
env = {
**environ,
'PYTHONUNBUFFERED': '1',
'PYTHONIOENCODING': 'UTF_8:replace',
'UV_PROJECT_ENVIRONMENT': virtualenv_path
}
if exists(env_file):
env.update(parse_settings(env_file, env))
echo("-----> Calling uv sync", fg='green')
call('uv sync --python-preference only-system', cwd=join(APP_ROOT, app), env=env, shell=True)
return spawn_app(app, deltas)
def deploy_identity(app, deltas={}):
env_path = join(ENV_ROOT, app)
if not exists(env_path):