Skip to content

Commit

Permalink
Add metrics for the existence of a uv lockfile
Browse files Browse the repository at this point in the history
To help gauge how often a uv lockfile exists. (Either from
someone trying to use uv and the build failing, or when a
third-party buildpack is used to export the uv lockfile to a
requirements file etc).

Towards #1616.
GUS-W-17431743.
  • Loading branch information
edmorley committed Dec 13, 2024
1 parent dfd025b commit d8ff740
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

- Fixed Dev Center links to reflect recent article URL changes. ([#1723](https://github.com/heroku/heroku-buildpack-python/pull/1723))
- Added metrics for the existence of a uv lockfile. ([#1725](https://github.com/heroku/heroku-buildpack-python/pull/1725))

## [v271] - 2024-12-12

Expand Down
1 change: 1 addition & 0 deletions bin/report
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ ALL_OTHER_FIELDS=(
setup_py_only
sqlite_install_duration
total_duration
uv_lockfile
)

for field in "${STRING_FIELDS[@]}"; do
Expand Down
9 changes: 9 additions & 0 deletions lib/package_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ function package_manager::determine_package_manager() {
meta_set "setup_py_only" "false"
fi

if [[ -f "${build_dir}/uv.lock" ]]; then
meta_set "uv_lockfile" "true"
fi

local num_package_managers_found=${#package_managers_found[@]}

case "${num_package_managers_found}" in
Expand Down Expand Up @@ -87,6 +91,11 @@ function package_manager::determine_package_manager() {
Otherwise, add a package manager file to your app. If your app has
no dependencies, then create an empty 'requirements.txt' file.
If you would like to see support for the package manager uv,
please vote and comment on these GitHub issues:
https://github.com/heroku/heroku-buildpack-python/issues/1616
https://github.com/heroku/roadmap/issues/323
For help with using Python on Heroku, see:
https://devcenter.heroku.com/articles/getting-started-with-python
https://devcenter.heroku.com/articles/python-support
Expand Down
Empty file.
Empty file.
47 changes: 47 additions & 0 deletions spec/hatchet/package_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,53 @@
remote: ! Otherwise, add a package manager file to your app. If your app has
remote: ! no dependencies, then create an empty 'requirements.txt' file.
remote: !
remote: ! If you would like to see support for the package manager uv,
remote: ! please vote and comment on these GitHub issues:
remote: ! https://github.com/heroku/heroku-buildpack-python/issues/1616
remote: ! https://github.com/heroku/roadmap/issues/323
remote: !
remote: ! For help with using Python on Heroku, see:
remote: ! https://devcenter.heroku.com/articles/getting-started-with-python
remote: ! https://devcenter.heroku.com/articles/python-support
remote:
remote: ! Push rejected, failed to compile Python app.
OUTPUT
end
end
end

context 'when there is a uv.lock' do
let(:app) { Hatchet::Runner.new('spec/fixtures/uv_lockfile_only', allow_failure: true) }

it 'fails the build with an informative error message' do
app.deploy do |app|
expect(clean_output(app.output)).to include(<<~OUTPUT)
remote: -----> Python app detected
remote:
remote: ! Error: Couldn't find any supported Python package manager files.
remote: !
remote: ! A Python app on Heroku must have either a 'requirements.txt',
remote: ! 'Pipfile' or 'poetry.lock' package manager file in the root
remote: ! directory of its source code.
remote: !
remote: ! Currently the root directory of your app contains:
remote: !
remote: ! uv.lock
remote: !
remote: ! If your app already has a package manager file, check that it:
remote: !
remote: ! 1. Is in the top level directory (not a subdirectory).
remote: ! 2. Has the correct spelling (the filenames are case-sensitive).
remote: ! 3. Isn't listed in '.gitignore' or '.slugignore'.
remote: !
remote: ! Otherwise, add a package manager file to your app. If your app has
remote: ! no dependencies, then create an empty 'requirements.txt' file.
remote: !
remote: ! If you would like to see support for the package manager uv,
remote: ! please vote and comment on these GitHub issues:
remote: ! https://github.com/heroku/heroku-buildpack-python/issues/1616
remote: ! https://github.com/heroku/roadmap/issues/323
remote: !
remote: ! For help with using Python on Heroku, see:
remote: ! https://devcenter.heroku.com/articles/getting-started-with-python
remote: ! https://devcenter.heroku.com/articles/python-support
Expand Down

0 comments on commit d8ff740

Please sign in to comment.