Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
heroku-buildpack-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evili del Rio i Silvan
heroku-buildpack-python
Commits
581177b2
Commit
581177b2
authored
9 years ago
by
Kenneth Reitz
Browse files
Options
Downloads
Plain Diff
Merge pull request #273 from heroku/collectstatic
Collectstatic revamp
parents
3b35c2c2
669f0b0e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/compile
+2
-0
2 additions, 0 deletions
bin/compile
bin/steps/collectstatic
+45
-19
45 additions, 19 deletions
bin/steps/collectstatic
bin/utils
+4
-0
4 additions, 0 deletions
bin/utils
with
51 additions
and
19 deletions
bin/compile
+
2
−
0
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
...
...
This diff is collapsed.
Click to expand it.
bin/steps/collectstatic
+
45
−
19
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
This diff is collapsed.
Click to expand it.
bin/utils
+
4
−
0
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment