-
Notifications
You must be signed in to change notification settings - Fork 196
Support Pipfile #168
Support Pipfile #168
Changes from all commits
e9f551a
fad2e71
c9eb9f4
01334f7
8ceabad
0665e11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ export GIMME_CGO_ENABLED=true | |
export NVM_DIR="$HOME/.nvm" | ||
export RVM_DIR="$HOME/.rvm" | ||
|
||
# Pipenv configuration | ||
export PIPENV_RUNTIME=2.7 | ||
export PIPENV_VENV_IN_PROJECT=1 | ||
export PIPENV_DEFAULT_PYTHON_VERSION=2.7 | ||
|
||
YELLOW="\033[0;33m" | ||
NC="\033[0m" # No Color | ||
|
||
|
@@ -25,6 +30,7 @@ mkdir -p $NETLIFY_CACHE_DIR/ruby_version | |
mkdir -p $NETLIFY_CACHE_DIR/node_modules | ||
mkdir -p $NETLIFY_CACHE_DIR/.bundle | ||
mkdir -p $NETLIFY_CACHE_DIR/bower_components | ||
mkdir -p $NETLIFY_CACHE_DIR/.venv | ||
|
||
# HOME caches | ||
mkdir -p $NETLIFY_CACHE_DIR/.yarn_cache | ||
|
@@ -159,6 +165,10 @@ install_dependencies() { | |
echo "Please see https://github.com/netlify/build-image/#included-software for current versions" | ||
exit 1 | ||
fi | ||
elif [ -f Pipfile ] | ||
then | ||
echo "Found Pipfile restoring Pipenv virtualenv" | ||
restore_cwd_cache ".venv" "python virtualenv" | ||
else | ||
source $HOME/python2.7/bin/activate | ||
fi | ||
|
@@ -323,6 +333,24 @@ install_dependencies() { | |
echo "Error installing pip dependencies" | ||
exit 1 | ||
fi | ||
elif [ -f Pipfile ] | ||
then | ||
echo "Installing dependencies from Pipfile" | ||
if $HOME/python$PIPENV_RUNTIME/bin/pipenv install | ||
then | ||
echo "Pipenv dependencies installed" | ||
if source $($HOME/python$PIPENV_RUNTIME/bin/pipenv --venv)/bin/activate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fwiw, doing this instead of https://github.com/pypa/pipenv/blob/master/docs/advanced.rst#-automatic-loading-of-env Note that it isnt even possible to use As a result, probably a good idea to set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! It seems to me that ENV variables are meant to be handled some other way on production. E.g. using https://www.netlify.com/docs/continuous-deployment/#build-environment-variables. Based on discussion in pypa/pipenv#773 (comment) |
||
then | ||
echo "Python version set to $(python -V)" | ||
else | ||
echo "Error activating Pipenv environment" | ||
exit 1 | ||
fi | ||
else | ||
echo "Error installing Pipenv dependencies" | ||
echo "Please see https://github.com/netlify/build-image/#included-software for current versions" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# NPM Dependencies | ||
|
@@ -494,6 +522,7 @@ cache_artifacts() { | |
cache_cwd_directory ".bundle" "ruby gems" | ||
cache_cwd_directory "bower_components" "bower components" | ||
cache_cwd_directory "node_modules" "node modules" | ||
cache_cwd_directory ".venv" "python virtualenv" | ||
|
||
cache_home_directory ".yarn_cache" "yarn cache" | ||
cache_home_directory ".cache" "pip cache" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be useful to set
PIPENV_VENV_IN_PROJECT
as multiple venvs are not needed on Netlify builds. setting that might improve performance a little.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks! 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move this (and the
export
lines from above) to theDockerfile
if possible. I'd ratherpipenv
be installed already, rather than done every build on-demand.