Skip to content
Snippets Groups Projects
Commit 6faa5a4e authored by Kenneth Reitz's avatar Kenneth Reitz
Browse files

Merge remote-tracking branch 'origin/master'

parents 3634eb1d 2881d65e
No related branches found
No related tags found
No related merge requests found
*.pyc
site
.DS_Store
# Python Buildpack Changelog
## 100
Preliminary pipenv support.
## 99
Cleanup.
......
......@@ -42,7 +42,7 @@ export WARNINGS_LOG=$(mktemp)
export RECOMMENDED_PYTHON_VERSION=$DEFAULT_PYTHON_VERSION
# Setup bpwatch
export PATH=$PATH:$ROOT_DIR/vendor/bpwatch
export PATH=$PATH:$ROOT_DIR/vendor/:$ROOT_DIR/vendor/bpwatch
LOGPLEX_KEY="t.b90d9d29-5388-4908-9737-b4576af1d4ce"
export BPWATCH_STORE_PATH=$CACHE_DIR/bpwatch.json
BUILDPACK_VERSION=v28
......@@ -107,12 +107,6 @@ bpwatch start pre_compile
source $BIN_DIR/steps/hooks/pre_compile
bpwatch stop pre_compile
# If no requirements.txt file given, assume `setup.py develop` is intended.
if [ ! -f requirements.txt ]; then
echo "-e ." > requirements.txt
fi
# Sticky runtimes.
if [ -f $CACHE_DIR/.heroku/python-version ]; then
DEFAULT_PYTHON_VERSION=$(cat $CACHE_DIR/.heroku/python-version)
......@@ -125,6 +119,9 @@ else
CACHED_PYTHON_STACK=$STACK
fi
# Pipenv Python version support.
source $BIN_DIR/steps/pipenv-python-version
# If no runtime given, assume default version.
if [ ! -f runtime.txt ]; then
echo $DEFAULT_PYTHON_VERSION > runtime.txt
......@@ -172,6 +169,14 @@ source $BIN_DIR/steps/python
# Sanity check for setuptools/distribute.
source $BIN_DIR/steps/setuptools
# Pipenv support.
source $BIN_DIR/steps/pipenv
# If no requirements.txt file given, assume `setup.py develop` is intended.
if [ ! -f requirements.txt ]; then
echo "-e ." > requirements.txt
fi
# Uninstall removed dependencies with Pip.
source $BIN_DIR/steps/pip-uninstall
......
......@@ -15,7 +15,7 @@
BUILD_DIR=$1
# Exit early if app is clearly not Python.
if [ ! -f $BUILD_DIR/requirements.txt ] && [ ! -f $BUILD_DIR/setup.py ]; then
if [ ! -f $BUILD_DIR/requirements.txt ] && [ ! -f $BUILD_DIR/setup.py ] && [ ! -f $BUILD_DIR/Pipfile ]; then
exit 1
fi
......
# Generate requriements.txt with pipenv.
if [[ -f Pipfile ]]; then
if [[ ! -f requirements.txt ]]; then
puts-step "Generating 'requirements.txt' with pipenv"
pip install pipenv --upgrade &> /dev/null
pipenv lock --requirements > requirements.txt 2> /dev/null
pipstrip requirements.txt
fi
fi
# Detect Python-version with Pipenv.
if [[ -f $BUILD_DIR/Pipfile.lock ]]; then
if [[ ! -f $BUILD_DIR/runtime.txt ]]; then
if [[ ! -f Pipfile.lock ]]; then
pipenv lock 2> /dev/null
fi
set +e
PYTHON=$(cat $BUILD_DIR/Pipfile.lock | jq '._meta.requires.python_version' -r)
set -e
if [ "$PYTHON" = 2.7 ]; then
echo "python-2.7.13" > $BUILD_DIR/runtime.txt
fi
if [ "$PYTHON" = 3.6 ]; then
echo "python-3.6.0" > $BUILD_DIR/runtime.txt
fi
fi
fi
vendor/jq 0 → 100755
File added
#!/usr/bin/env python
import sys
req_file = sys.argv[1]
lines = []
with open(req_file, 'r') as f:
r = f.readlines()
for l in r:
lines.append(l.split('--hash')[0])
with open(req_file, 'w') as f:
f.write('\n'.join(lines))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment