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
581177b2
Commit
581177b2
authored
Feb 05, 2016
by
Kenneth Reitz
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #273 from heroku/collectstatic
Collectstatic revamp
parents
3b35c2c2
669f0b0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
19 deletions
+51
-19
compile
bin/compile
+2
-0
collectstatic
bin/steps/collectstatic
+45
-19
utils
bin/utils
+4
-0
No files found.
bin/compile
View file @
581177b2
...
@@ -48,6 +48,8 @@ export PATH=$PATH:$ROOT_DIR/vendor/pip-pop
...
@@ -48,6 +48,8 @@ export PATH=$PATH:$ROOT_DIR/vendor/pip-pop
# Sanitizing environment variables.
# Sanitizing environment variables.
unset
GIT_DIR PYTHONHOME PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH
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 init
$LOGPLEX_KEY
bpwatch build python
$BUILDPACK_VERSION
$REQUEST_ID
bpwatch build python
$BUILDPACK_VERSION
$REQUEST_ID
...
...
bin/steps/collectstatic
View file @
581177b2
#!/usr/bin/env bash
#!/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
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
=
$(
find
.
-maxdepth
3
-type
f
-name
'manage.py'
-printf
'%d\t%P\n'
|
sort
-nk1
|
cut
-f2
|
head
-1
)
MANAGE_FILE
=
${
MANAGE_FILE
:-
fakepath
}
MANAGE_FILE
=
${
MANAGE_FILE
:-
fakepath
}
# Legacy file-based support for $DISABLE_COLLECTSTATIC
[
-f
.heroku/collectstatic_disabled
]
&&
DISABLE_COLLECTSTATIC
=
1
[
-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
bpwatch start collectstatic
# metrics collection
set
+e
echo
"-----> Preparing static assets"
if
[
!
"
$DISABLE_COLLECTSTATIC
"
]
&&
[
-f
"
$MANAGE_FILE
"
]
&&
[
"
$DJANGO_INSTALLED
"
]
;
then
# Check if collectstatic is configured properly.
set
+e
python
$MANAGE_FILE
collectstatic
--dry-run
--noinput
&> /dev/null
&&
RUN_COLLECTSTATIC
=
true
# Compile assets if collectstatic appears to be kosher.
echo
"-----> Preparing static assets with 'collectstatic'"
if
[
"
$RUN_COLLECTSTATIC
"
]
;
then
echo
" Running collectstatic..."
# Run collectstatic, cleanup some of the noisy output.
python
$MANAGE_FILE
collectstatic
--noinput
2>&1 |
sed
'/^Copying/d;/^$/d;/^ /d'
| indent
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
echo
fi
fi
bpwatch stop collectstatic
bpwatch stop collectstatic
# metrics collection
bin/utils
View file @
581177b2
...
@@ -88,6 +88,10 @@ sub-env() {
...
@@ -88,6 +88,10 @@ sub-env() {
WHITELIST=${2:-''}
WHITELIST=${2:-''}
BLACKLIST=${3:-'^(GIT_DIR|PYTHONHOME|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)$'}
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
if [ -d "$ENV_DIR" ]; then
for e in $(ls $ENV_DIR); do
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