Skip to content

Commit e6fdadd

Browse files
committed
Do not write requirements.txt for pyproject.toml-based projects
Install pyproject.toml-based projects using `pip install .`. Do not use a requirements.txt for this. The requirements.txt file is needed to handle pinned versions extracted from the poetry.lock file. Note that we cannot simply append `.` to the exported requirements.txt file. Currently pip requires that either all requirements have a hash or none. Including `.` would thus force us to omit hashes for all requirements.
1 parent 30b317d commit e6fdadd

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

bin/compile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,8 @@ mtime "pip.uninstall.time" "${start}"
265265
# If no requirements.txt file given, assume `setup.py develop` is intended.
266266
# This allows for people to ship a setup.py application to Heroku
267267
# (which is rare, but I vouch that it should work!)
268-
269-
if [ ! -f requirements.txt ] && [ ! -f Pipfile ] ; then
270-
if [ -f pyproject.toml ] ; then
271-
# Editable installs are not supported for pyproject.toml-style projects.
272-
echo "." > requirements.txt
273-
else
274-
echo "-e ." > requirements.txt
275-
fi
268+
if [ ! -f requirements.txt ] && [ ! -f Pipfile ] && [ ! -f pyproject.toml ]; then
269+
echo "-e ." > requirements.txt
276270
fi
277271

278272
# Fix egg-links.

bin/steps/pip-install

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,26 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
3434
mcount "tool.pip"
3535

3636
# Count expected build failures.
37-
if grep -q '==0.0.0' requirements.txt; then
37+
if [ -f requirements.txt ] && grep -q '==0.0.0' requirements.txt; then
3838
mcount "failure.none-version"
3939
fi
4040

4141
if [ ! -f "$BUILD_DIR/.heroku/python/bin/pip" ]; then
4242
exit 1
4343
fi
44-
/app/.heroku/python/bin/pip install -r "$BUILD_DIR/requirements.txt" --exists-action=w --src=/app/.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | tee "$WARNINGS_LOG" | cleanup | indent
45-
PIP_STATUS="${PIPESTATUS[0]}"
44+
45+
if [ -f requirements.txt ]; then
46+
/app/.heroku/python/bin/pip install -r "$BUILD_DIR/requirements.txt" --exists-action=w --src=/app/.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | tee "$WARNINGS_LOG" | cleanup | indent
47+
PIP_STATUS="${PIPESTATUS[0]}"
48+
else
49+
PIP_STATUS=0
50+
fi
51+
52+
if [ "$PIP_STATUS" -eq 0 ] && [ -f pyproject.toml ]; then
53+
/app/.heroku/python/bin/pip install . --exists-action=w --disable-pip-version-check --no-cache-dir 2>&1 | tee -a "$WARNINGS_LOG" | cleanup | indent
54+
PIP_STATUS="${PIPESTATUS[0]}"
55+
fi
56+
4657
set -e
4758

4859
show-warnings
@@ -53,8 +64,10 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
5364
fi
5465

5566
# Smart Requirements handling
56-
cp requirements.txt .heroku/python/requirements-declared.txt
57-
/app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
67+
if [ -f requirements.txt ]; then
68+
cp requirements.txt .heroku/python/requirements-declared.txt
69+
/app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
70+
fi
5871

5972
echo
6073

bin/steps/pip-uninstall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set +e
55
# shellcheck source=bin/utils
66
source "$BIN_DIR/utils"
77

8-
if [ ! "$SKIP_PIP_INSTALL" ]; then
8+
if [ ! "$SKIP_PIP_INSTALL" ] && [ -f requirements.txt ]; then
99

1010
if [[ -f .heroku/python/requirements-declared.txt ]]; then
1111

0 commit comments

Comments
 (0)