Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-python
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-python
Commits
af58f322
Commit
af58f322
authored
Feb 05, 2016
by
Kenneth Reitz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:heroku/heroku-buildpack-python
parents
e4bcc68c
9a024b85
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
21 deletions
+53
-21
Readme.md
Readme.md
+2
-2
compile
bin/compile
+2
-0
collectstatic
bin/steps/collectstatic
+45
-19
utils
bin/utils
+4
-0
No files found.
Readme.md
View file @
af58f322
# Heroku
b
uildpack: Python
# Heroku
B
uildpack: Python

This is a
[
Heroku buildpack
](
http://devcenter.heroku.com/articles/buildpacks
)
for Python apps, powered by
[
pip
](
http://www.pip-installer.org/
)
.
...
...
@@ -42,7 +42,7 @@ Specify a Runtime
You can also provide arbitrary releases Python with a
`runtime.txt`
file.
$ cat runtime.txt
python-3.5.
0
python-3.5.
1
Runtime options include:
...
...
bin/compile
View file @
af58f322
...
...
@@ -48,6 +48,8 @@ export PATH=$PATH:$ROOT_DIR/vendor/pip-pop
# Sanitizing environment variables.
unset
GIT_DIR PYTHONHOME PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH
unset
RECEIVE_DATA SOURCE_VERSION RUN_KEY BUILD_INFO DEPLOY
unset
LOG_TOKEN DYNO CYTOKINE_LOG_FILE GEM_PATH
bpwatch init
$LOGPLEX_KEY
bpwatch build python
$BUILDPACK_VERSION
$REQUEST_ID
...
...
bin/steps/collectstatic
View file @
af58f322
#!/usr/bin/env bash
# Django Collectstatic runner. If you have Django installed, collectstatic will
# automatically be executed as part of the build process. If collectstatic
# fails, your build fails.
# This functionality will only activate if Django is in requirements.txt.
# Runtime arguments:
# - $DISABLE_COLLECTSTATIC: disables this functionality.
# - $DEBUG_COLLECTSTATIC: upon failure, print out environment variables.
source
$BIN_DIR
/utils
# Location of 'manage.py', if it exists.
MANAGE_FILE
=
$(
find
.
-maxdepth
3
-type
f
-name
'manage.py'
-printf
'%d\t%P\n'
|
sort
-nk1
|
cut
-f2
|
head
-1
)
MANAGE_FILE
=
${
MANAGE_FILE
:-
fakepath
}
# Legacy file-based support for $DISABLE_COLLECTSTATIC
[
-f
.heroku/collectstatic_disabled
]
&&
DISABLE_COLLECTSTATIC
=
1
bpwatch start collectstatic
# Ensure that Django is explicitily specified in requirments.txt
pip-grep
-s
requirements.txt django Django
&&
DJANGO_INSTALLED
=
1
if
[
!
"
$DISABLE_COLLECTSTATIC
"
]
&&
[
-f
"
$MANAGE_FILE
"
]
;
then
set
+e
bpwatch start collectstatic
# metrics collection
echo
"-----> Preparing static assets"
# Check if collectstatic is configured properly.
python
$MANAGE_FILE
collectstatic
--dry-run
--noinput
&> /dev/null
&&
RUN_COLLECTSTATIC
=
true
if
[
!
"
$DISABLE_COLLECTSTATIC
"
]
&&
[
-f
"
$MANAGE_FILE
"
]
&&
[
"
$DJANGO_INSTALLED
"
]
;
then
set
+e
# Compile assets if collectstatic appears to be kosher.
if
[
"
$RUN_COLLECTSTATIC
"
]
;
then
echo
"-----> Preparing static assets with 'collectstatic'"
echo
" Running collectstatic..."
python
$MANAGE_FILE
collectstatic
--noinput
2>&1 |
sed
'/^Post-processed/d;/^Copying/d;/^$/d;/^ /d'
| indent
# Run collectstatic, cleanup some of the noisy output.
python
$MANAGE_FILE
collectstatic
--noinput
--traceback
2>&1 |
sed
'/^Copying/d;/^$/d;/^ /d'
| indent
echo
python
$MANAGE_FILE
collectstatic 2>&1 |
sed
'/^Copying/d;/^$/d'
| indent
COLLECTSTATIC_STATUS
=
"
${
PIPESTATUS
[0]
}
"
set
-e
# Display a warning if collectstatic failed.
[
$COLLECTSTATIC_STATUS
-ne
0
]
&&
{
echo
echo
" ! Error while runnning '
$
python
$MANAGE_FILE
collectstatic --noinput'."
echo
" See traceback above for more details."
echo
" More info: http://devcenter.heroku.com/articles/django-assets"
# Additionally, dump out the environment, if debug mode is on.
if
[
"
$DEBUG_COLLECTSTATIC
"
]
;
then
echo
echo
"****** Collectstatic environment variables:"
echo
env
| indent
fi
# Abort the build.
exit
1
}
[
$?
-ne
0
]
&&
{
echo
" ! Error running 'manage.py collectstatic'. More info:"
echo
" http://devcenter.heroku.com/articles/django-assets"
}
else
echo
" Collectstatic configuration error. To debug, run:"
echo
"
$
heroku run python
$MANAGE_FILE
collectstatic --noinput"
fi
echo
fi
bpwatch stop collectstatic
bpwatch stop collectstatic
# metrics collection
bin/utils
View file @
af58f322
...
...
@@ -88,6 +88,10 @@ sub-env() {
WHITELIST=${2:-''}
BLACKLIST=${3:-'^(GIT_DIR|PYTHONHOME|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)$'}
# Python-specific variables.
export PYHONHOME=$BUILD_DIR/.heroku/python
export PYTHONPATH=$BUILD_DIR/
(
if [ -d "$ENV_DIR" ]; then
for e in $(ls $ENV_DIR); do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment