Skip to content

Commit b2e067b

Browse files
authored
Merge pull request #721 from heroku/pre-heroku-24-cleanup
Pre-heroku-24 cleanup
2 parents 90f2713 + ef4d30d commit b2e067b

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

bin/compile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ composer_lock_parse_error=$(
8080

8181
# a bunch of sanity checks first
8282
if [[ -s "$COMPOSER" ]]; then
83-
cat "$COMPOSER" | python -mjson.tool &> /dev/null || {
83+
cat "$COMPOSER" | python3 -mjson.tool &> /dev/null || {
8484
mcount "failures.composer_json.lint"
8585
error <<-EOF
8686
Basic validation for '$COMPOSER' failed!
@@ -98,7 +98,7 @@ if [[ -s "$COMPOSER" ]]; then
9898
EOF
9999
}
100100
if [[ ! -f "$COMPOSER_LOCK" ]]; then
101-
cat "$COMPOSER" | python -c 'import sys, json; sys.exit(bool(json.load(sys.stdin).get("require", {})))' 2> /dev/null || {
101+
cat "$COMPOSER" | python3 -c 'import sys, json; sys.exit(bool(json.load(sys.stdin).get("require", {})))' 2> /dev/null || {
102102
mcount "failures.composer_lock.missing"
103103
error <<-EOF
104104
No '$COMPOSER_LOCK' found!
@@ -130,7 +130,7 @@ if [[ -s "$COMPOSER" ]]; then
130130
EOF
131131
}
132132
else
133-
cat "$COMPOSER_LOCK" | python -mjson.tool &> /dev/null || {
133+
cat "$COMPOSER_LOCK" | python3 -mjson.tool &> /dev/null || {
134134
mcount "failures.composer_lock.lint"
135135
error "$composer_lock_parse_error"
136136
}
@@ -320,7 +320,7 @@ composer validate --no-plugins --no-check-publish --no-check-all --quiet "$COMPO
320320
}
321321

322322
# if prefer-stable is false and minimum-stability is not stable, warn about potential unstable platform installs
323-
[[ ! -f "$COMPOSER_LOCK" ]] || minimum_stability=$(cat "$COMPOSER_LOCK" | python -c 'import sys, json; l = json.load(sys.stdin); print(l.get("minimum-stability")); sys.exit(l.get("minimum-stability", "stable") != "stable" and l.get("prefer-stable", False) == False);' 2> /dev/null) || {
323+
[[ ! -f "$COMPOSER_LOCK" ]] || minimum_stability=$(cat "$COMPOSER_LOCK" | python3 -c 'import sys, json; l = json.load(sys.stdin); print(l.get("minimum-stability")); sys.exit(l.get("minimum-stability", "stable") != "stable" and l.get("prefer-stable", False) == False);' 2> /dev/null) || {
324324
possible_stabilities="dev, alpha, beta, or RC"
325325
case $minimum_stability in
326326
alpha)
@@ -670,7 +670,7 @@ unset COMPOSER_GITHUB_OAUTH_TOKEN
670670

671671
# install dependencies unless composer.json is completely empty (in which case it'd talk to packagist.org which may be slow and is unnecessary)
672672
export_env_dir "$env_dir" '^[A-Z_][A-Z0-9_]*$' '^(HOME|PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH|LD_LIBRARY_PATH|STACK|REQUEST_ID|IFS|HEROKU_PHP_INSTALL_DEV|BPLOG_PREFIX|BUILDPACK_LOG_FILE|PHP_INI_SCAN_DIR)$'
673-
if cat "$COMPOSER" | python -c 'import sys,json; sys.exit(not json.load(sys.stdin));'; then
673+
if cat "$COMPOSER" | python3 -c 'import sys,json; sys.exit(not json.load(sys.stdin));'; then
674674
install_log=$(mktemp -t heroku-buildpack-php-composer-install-log-XXXX)
675675
composer install ${HEROKU_PHP_INSTALL_DEV-"--no-dev"} --prefer-dist --optimize-autoloader --no-progress --no-interaction 2>&1 | tee "$install_log" | indent || {
676676
code=$?
@@ -728,7 +728,7 @@ fi
728728
# log number of installed dependencies
729729
mmeasure "dependencies.count" $(composer show --installed 2> /dev/null | wc -l)
730730

731-
if cat "$COMPOSER" | python -c 'import sys,json; sys.exit("compile" not in json.load(sys.stdin).get("scripts", {}));'; then
731+
if cat "$COMPOSER" | python3 -c 'import sys,json; sys.exit("compile" not in json.load(sys.stdin).get("scripts", {}));'; then
732732
status "Running 'composer compile'..."
733733
composer run-script ${HEROKU_PHP_INSTALL_DEV-"--no-dev"} --no-interaction compile 2>&1 | indent || {
734734
mcount "failures.compile_step"
@@ -756,15 +756,15 @@ status "Preparing runtime environment..."
756756
# TODO: warn if require-dev has the package using a different branch
757757
shopt -u dotglob # we don't want .git, .gitignore et al
758758
# figure out the package dir name to write to and copy to it
759-
hbpdir="$composer_vendordir/$(cat $bp_dir/composer.json | python -c 'import sys, json; print(json.load(sys.stdin)["name"])')"
759+
hbpdir="$composer_vendordir/$(cat $bp_dir/composer.json | python3 -c 'import sys, json; print(json.load(sys.stdin)["name"])')"
760760
mkdir -p "$build_dir/$hbpdir"
761761
cp -r "$bp_dir"/* "$build_dir/$hbpdir/"
762762
# make bin dir, just in case
763763
mkdir -p "$build_dir/$composer_bindir"
764764
# figure out shortest relative path from vendor/heroku/heroku-buildpack-php to vendor/bin (or whatever the bin dir is)
765-
relbin=$(python -c "import os.path; print(os.path.relpath('$hbpdir', '$composer_bindir'))")
765+
relbin=$(python3 -c "import os.path; print(os.path.relpath('$hbpdir', '$composer_bindir'))")
766766
# collect bin names from composer.json
767-
relbins=$(cat $bp_dir/composer.json | python -c 'from __future__ import print_function; import sys, json; { print(sys.argv[1]+"/"+bin) for bin in json.load(sys.stdin)["bin"] }' $relbin)
767+
relbins=$(cat $bp_dir/composer.json | python3 -c 'import sys, json; { print(sys.argv[1]+"/"+bin) for bin in json.load(sys.stdin)["bin"] }' $relbin)
768768
# link to bins
769769
cd $build_dir/$composer_bindir
770770
ln -fs $relbins .

bin/heroku-php-apache2

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ shopt -s extglob
1010
shopt -s nullglob
1111

1212
if ! type -p "realpath" > /dev/null; then
13-
# macOS doesn't have realpath
13+
# old macOSes don't have realpath
1414
# readlink is not an option because BSD readlink does not have the GNU -f option
1515
# must be a function so subshells, including $(…), can use it
1616
realpath() {
17-
python -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$@"
17+
python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$@"
1818
}
1919
fi
2020

@@ -310,10 +310,11 @@ composer() {
310310
# check if the composer binary is executable by PHP
311311
if file --brief --dereference "$composer_bin" | grep -e "shell" -e "bash" > /dev/null ; then # newer versions of file return "data" for .phar
312312
# run it directly; it's probably a bash script or similar (homebrew-php does this)
313+
# disable interactive mode just in case our environment doesn't have that set (or 'composer config vendor-dir' will hang with a prompt if there is no composer.json in the cwd)
313314
# re-set COMPOSER_AUTH to ensure a malformed `heroku config:set` will not cause immediate outage
314-
COMPOSER_AUTH= "$composer_bin" "$@"
315+
COMPOSER_NO_INTERACTION=1 COMPOSER_AUTH= "$composer_bin" "$@"
315316
else
316-
COMPOSER_AUTH= php "$composer_bin" "$@"
317+
COMPOSER_NO_INTERACTION=1 COMPOSER_AUTH= php "$composer_bin" "$@"
317318
fi
318319
}
319320
# these exports are used in default web server configs to lock down access to composer directories

bin/heroku-php-nginx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ shopt -s extglob
1010
shopt -s nullglob
1111

1212
if ! type -p "realpath" > /dev/null; then
13-
# macOS doesn't have realpath
13+
# old macOSes don't have realpath
1414
# readlink is not an option because BSD readlink does not have the GNU -f option
1515
# must be a function so subshells, including $(…), can use it
1616
realpath() {
17-
python -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$@"
17+
python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$@"
1818
}
1919
fi
2020

@@ -308,10 +308,11 @@ composer() {
308308
# check if the composer binary is executable by PHP
309309
if file --brief --dereference "$composer_bin" | grep -e "shell" -e "bash" > /dev/null ; then # newer versions of file return "data" for .phar
310310
# run it directly; it's probably a bash script or similar (homebrew-php does this)
311+
# disable interactive mode just in case our environment doesn't have that set (or 'composer config vendor-dir' will hang with a prompt if there is no composer.json in the cwd)
311312
# re-set COMPOSER_AUTH to ensure a malformed `heroku config:set` will not cause immediate outage
312-
COMPOSER_AUTH= "$composer_bin" "$@"
313+
COMPOSER_NO_INTERACTION=1 COMPOSER_AUTH= "$composer_bin" "$@"
313314
else
314-
COMPOSER_AUTH= php "$composer_bin" "$@"
315+
COMPOSER_NO_INTERACTION=1 COMPOSER_AUTH= php "$composer_bin" "$@"
315316
fi
316317
}
317318
# these exports are used in default web server configs to lock down access to composer directories

test/spec/bugs_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
context "because the buildpack ran twice" do
3535
it "fails the build" do
3636
buildpacks = [
37-
"heroku/php",
37+
:default,
3838
:default
3939
]
4040
app = new_app_with_stack_and_platrepo("test/fixtures/default", buildpacks: buildpacks, allow_failure: true)

test/spec/platform_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
bp_root = [".."].cycle("#{manifest_fixtures_subdir}/#{testcase}".count("/")+1).to_a.join("/") # right "../.." sequence to get us back to the root of the buildpack
180180
Dir.chdir("#{manifest_fixtures_subdir}/#{testcase}") do |cwd|
181181
cmd = File.read("ENV") # any env vars for the test (manifest.py needs STACK, S3_BUCKET, S3_PREFIX, TIME)
182-
cmd << " python #{bp_root}/support/build/_util/include/manifest.py "
182+
cmd << " python3 #{bp_root}/support/build/_util/include/manifest.py "
183183
cmd << File.read("ARGS")
184184
stdout, stderr, status = Open3.capture3("bash -c #{Shellwords.escape(cmd)}")
185185

0 commit comments

Comments
 (0)