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
9a69793d
Commit
9a69793d
authored
14 years ago
by
Noah Zoschke
Browse files
Options
Downloads
Patches
Plain Diff
slug-compiler lp import
parent
6944c178
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/compile
+70
-0
70 additions, 0 deletions
bin/compile
bin/detect
+8
-0
8 additions, 0 deletions
bin/detect
bin/release
+29
-0
29 additions, 0 deletions
bin/release
with
107 additions
and
0 deletions
bin/compile
0 → 100755
+
70
−
0
View file @
9a69793d
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>
set
-e
BIN_DIR
=
$(
dirname
$0
)
BUILD_DIR
=
$1
CACHE_DIR
=
$2
NAME
=
$(
$BIN_DIR
/detect
$BUILD_DIR
)
PIP_DOWNLOAD_CACHE
=
${
PIP_DOWNLOAD_CACHE
:-
$CACHE_DIR
/pip_downloads
}
VIRTUALENV_DIRS
=
"bin include lib"
function
sed
()
{
# prefer GNU sed over BSD sed on OS X
$(
which gsed
||
which
sed
)
"
$@
"
}
cd
$BUILD_DIR
# copy artifacts out of cache if exists
mkdir
-p
$CACHE_DIR
for
dir
in
$VIRTUALENV_DIRS
;
do
cp
-R
$CACHE_DIR
/
$dir
.
&> /dev/null
||
true
done
echo
"-----> Preparing virtualenv"
virtualenv
--no-site-packages
.
|
sed
-u
's/^/ /'
[
"
${
PIPESTATUS
[*]
}
"
==
"0 0"
]
echo
"-----> Byte-compiling code"
find
.
-name
"*.py"
| xargs bin/python
-m
py_compile
[
"
${
PIPESTATUS
[*]
}
"
==
"0 0"
]
# if Django, inject psycopg and append settings
if
[
"
$NAME
"
=
"Django"
]
;
then
grep
-q
^psycopg2 requirements.txt
||
(
echo
"-----> Injecting psycopg2 into requirements for PostgreSQL support"
echo
"psycopg2==2.3.1"
>>
requirements.txt
)
SETTINGS_FILE
=
$(
ls
**
/settings.py |
head
-1
)
echo
"-----> Appending code to
$SETTINGS_FILE
to read from DATABASE_URL"
cat
>>
$SETTINGS_FILE
<<
EOF
import os, urlparse
if os.environ.has_key('DATABASE_URL'):
urlparse.uses_netloc.append('postgres')
url = urlparse.urlparse(os.environ['DATABASE_URL'])
DATABASES['default'] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': url.path[1:],
'USER': url.username,
'PASSWORD': url.password,
'HOST': url.hostname,
'PORT': url.port,
}
EOF
fi
echo
"-----> Installing dependencies with pip"
PIP_DOWNLOAD_CACHE
=
$PIP_DOWNLOAD_CACHE
bin/pip
install
-r
requirements.txt |
sed
-u
's/^/ /'
[
"
${
PIPESTATUS
[*]
}
"
==
"0 0"
]
# store new artifacts in cache
for
dir
in
$VIRTUALENV_DIRS
;
do
rm
-rf
$CACHE_DIR
/
$dir
cp
-R
$dir
$CACHE_DIR
/
done
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bin/detect
0 → 100755
+
8
−
0
View file @
9a69793d
#!/usr/bin/env bash
# bin/name <build-dir>
BUILD_DIR
=
$1
[
-f
$BUILD_DIR
/requirements.txt
]
||
exit
1
# fail fast if no requirements.txt
# 'Django' if there is a [mysite]/settings.py file present; otherwise 'Python'
ls
$BUILD_DIR
/
**
/settings.py &> /dev/null
&&
echo
Django
||
echo
Python
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bin/release
0 → 100755
+
29
−
0
View file @
9a69793d
#!/usr/bin/env bash
# bin/release <build-dir>
BIN_DIR
=
$(
dirname
$0
)
BUILD_DIR
=
$1
NAME
=
$(
$BIN_DIR
/detect
$BUILD_DIR
)
||
exit
1
cd
$BUILD_DIR
cat
<<
EOF
---
config_vars:
PYTHONUNBUFFERED: true
EOF
[
"
$NAME
"
=
"Django"
]
||
exit
0
SETTINGS_FILE
=
$(
ls
**
/settings.py |
head
-1
)
PROJECT
=
$(
dirname
$SETTINGS_FILE
)
cat
<<
EOF
addons:
shared-database:5mb
default_process_types:
web: bin/python
$PROJECT
/manage.py runserver 0.0.0.0:
\$
PORT --noreload
console: bin/python
$PROJECT
/manage.py shell
EOF
\ No newline at end of file
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