You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current cloud foundry[python-buildpack](https://github.com/cloudfoundry/python-buildpack)doesn't support modern python tools, such as[uv](https://docs.astral.sh/uv/), so I created this custom buildpack to bridge the gap.
3
+
The standard Cloud Foundry[python-buildpack](https://github.com/cloudfoundry/python-buildpack)does not focus on modern Python workflows built around[uv](https://docs.astral.sh/uv/). This custom buildpack fills that gap by detecting uv-managed applications, installing a managed Python runtime, and staging locked dependencies for Cloud Foundry.
4
4
5
-
## Installation
5
+
## What this buildpack expects
6
6
7
-
## How to use
7
+
For an app to be detected by this buildpack, it must include:
8
8
9
+
-`pyproject.toml`
10
+
-`uv.lock`
9
11
10
-
### Defining the initialization script
12
+
If the app includes a `.python-version` file, the buildpack uses that version when installing Python.
11
13
12
-
This buildpack detects uv-managed apps when both `pyproject.toml` and `uv.lock` are present.
14
+
## How startup is chosen
13
15
14
-
At staging time, `bin/compile` exports the locked dependencies from `uv.lock`, installs them into `.python_packages`, and writes a `.profile.d/python.sh` file so the app can import those staged packages at runtime. If the app uses a `src/` layout, that `src/` directory is also added to `PYTHONPATH`.
16
+
At release time, the buildpack chooses the web command in this order:
15
17
16
-
At release time, `bin/release` chooses the web command in this order:
17
-
18
-
1. If the app has a `Procfile`, the buildpack does not generate a default process type and Cloud Foundry uses the `Procfile`.
19
-
2. If `pyproject.toml` exists and `[project.scripts]` contains a script named exactly the same as `[project].name`, that script is used.
20
-
3. Otherwise, if `[project.scripts]` contains a `start` script, that script is used.
18
+
1. If the app has a `Procfile`, Cloud Foundry uses it directly.
19
+
2. Otherwise, if `pyproject.toml` defines a console script whose name matches `[project].name`, that script is used.
20
+
3. Otherwise, if `[project.scripts]` defines `start`, that script is used.
21
21
4. Otherwise, if `main.py` exists, the buildpack uses `python3 main.py`.
22
22
5. Otherwise, if `app.py` exists, the buildpack uses `python3 app.py`.
23
-
6. If none of the above are present, the buildpack emits an empty `web` process and you must provide your own entrypoint.
24
23
25
-
For `pyproject.toml` scripts, the buildpack converts a console-script target such as:
24
+
For example, this `pyproject.toml`:
26
25
27
26
```toml
28
27
[project]
@@ -33,15 +32,90 @@ my-app = "server.main:run"
33
32
start = "server.main:start"
34
33
```
35
34
36
-
into a process command like:
35
+
becomes:
37
36
38
37
```sh
39
38
python3 -c "from server.main import run; run()"
40
39
```
41
40
42
-
In the example above, `my-app` wins over `start` because it matches `[project].name`.
41
+
## Installing the buildpack
42
+
43
+
### Option 1: Use a packaged buildpack zip directly
0 commit comments