Azure / Azure/azure-functions-core-tools

Remove need for requirement.txt for Python projects in func pack

Open
#4,676 2 comments 5 reactions 1 assignee Assigned to @Copilot View on GitHub
enhancement func-stack: Python
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
5d 4h
Merged PRs (30d)
15

Description

### Description

Recently we added made some changes in Oryx, which removes the need for `requirements.txt` for Python apps. With the change, if customer only has `pyproject.toml` then `poetry` will be used to resolve dependencies, if both `pyproject.toml` and `uv.lock` are present then `uv` will be used, and if `requirements.txt` is present then `pip` will be used.

Today, the `func pack` with `--no-build` flag is still expecting Python projects to have a `requirements.txt`:

```
func pack --no-build
local.settings.json found in root directory (/Users/lily/Desktop/Functions/mcp/functions-hosting/test/mcp-sdk-functions-hosting-python).
Resolving worker runtime to 'python'.
local.settings.json found in root directory (/Users/lily/Desktop/Functions/mcp/functions-hosting/test/mcp-sdk-functions-hosting-python).
Resolving worker runtime to 'python'.

Validating project...

Validate host.json: PASSED
Validate Flag Compatibility: PASSED
Validate Folder Structure: FAILED

**Required file(s) 'requirements.txt' not found in /Users/lily/Desktop/Functions/mcp/functions-hosting/test/mcp-sdk-functions-hosting-python.**
```

### Related issue
`func pack` (`--no-build` flag is _not_ specified) defaults to using pip install for ensuring the dependencies are available, but this will fail for venv's created by uv since pip is not installed by default.

```
(durableagent) PS Q:\src\durable-agent-framework\python\samples\01_SingleAgent> func pack
local.settings.json found in root directory (Q:\src\durable-agent-framework\python\samples\01_SingleAgent).
Resolving worker runtime to 'python'.
local.settings.json found in root directory (Q:\src\durable-agent-framework\python\samples\01_SingleAgent).
Resolving worker runtime to 'python'.

Validating project...

Validate host.json: PASSED
Validate Flag Compatibility: PASSED
Validate Folder Structure: PASSED
Validation .python_packages directory exists: WARNING
Directory '.python_packages' not found or is empty.
Validate Python Programming Model: PASSED

Found Python version 3.13.7 (py).
Q:\src\durable-agent-framework\python\.venv\Scripts\python.exe -m pip download -r Q:\src\durable-agent-framework\python\samples\01_SingleAgent\requirements.txt --dest C:\Users\larohra\AppData\Local\Temp\azureworker9ez2uk0n

There was an error restoring dependencies. Q:\src\durable-agent-framework\python\.venv\Scripts\python.exe: No module named pip
ERROR: ['Q:\\src\\durable-agent-framework\\python\\.venv\\Scripts\\python.exe', '-m', 'pip', 'download', '-r', 'Q:\\src\\durable-agent-framework\\python\\samples\\01_SingleAgent\\requirements.txt', '--dest', 'C:\\Users\\larohra\\AppData\\Local\\Temp\\azureworker9ez2uk0n'] failed with exit code 1
```

### Ask
The following asks are for Python projects -

1. `func pack --no-build` should check for the presence of `pyproject.toml` and `uv.lock`, and if they're present, the project doesn't need a `requirements.txt` to pack.
2. `func pack` should check for presence of requirements.txt before using pip to install dependencies. If the project only has `pyproject.toml` then `poetry` should be used. If both `pyproject.toml` and `uv.lock` are present then `uv` should be used.

FYI @im-samz

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.