Created
April 26, 2013 09:30
-
-
Save rukeba/5466054 to your computer and use it in GitHub Desktop.
Templates for Django project with virtualenv & deploy powered by Helicon Zoo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assume that: | |
- virtual enviroment located in 'venv' folder | |
- django project located in 'project' folder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import os.path | |
VIRTUALENV_EXE = os.path.join(os.path.dirname(sys.executable), 'scripts\\virtualenv.exe') | |
VIRTUALENV_NAME = 'venv' | |
DJANGO_PROJECT_NAME = 'project' | |
PROJECT_DIR = os.path.dirname(__file__) | |
def run(command, exit_on_error=True): | |
print('\nRunning command: '+command) | |
status = os.system(command) | |
if status != 0: | |
sys.exit(status) | |
def django_manage(command): | |
run(DJANGO_PROJECT_NAME + '\\manage.py ' + command) | |
def main(): | |
os.chdir(PROJECT_DIR) | |
# update APPDATA env for pip | |
#os.environ['APPDATA'] = os.path.join(PROJECT_DIR, PYTHON_MODULES_DIR) | |
# create virtual environment | |
if not os.path.exists(VIRTUALENV_NAME): | |
run(VIRTUALENV_EXE+' '+VIRTUALENV_NAME) | |
# install requirements to local folder | |
run('pip install --requirement=requirements.txt') | |
# run manage.py syncdb --noinput | |
django_manage('syncdb --noinput') | |
# run manage.py migrate | |
django_manage('migrate') | |
# collect static | |
django_manage('collectstatic --noinput') | |
# that's all | |
print "Bye!" | |
if __name__=='__main__': | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<heliconZoo> | |
<application name="python.project" > | |
<environmentVariables> | |
<add name="VIRTUAL_ENV" value="%APPL_PHYSICAL_PATH%\venv" /> | |
<add name="PATH" value="%APPL_PHYSICAL_PATH%\venv\Scripts;%PATH%" /> | |
<add name="PYTHONPATH" value="%APPL_PHYSICAL_PATH%\venv\lib\site-packages;%APPL_PHYSICAL_PATH%\venv\lib;%APPL_PHYSICAL_PATH%;%APPL_PHYSICAL_PATH%\project" /> | |
<!-- django project --> | |
<add name="DJANGO_SETTINGS_MODULE" value="project.settings" /> | |
<!-- application deployment --> | |
<add name="DEPLOY_FILE" value="deploy.py" /> | |
<!-- <add name="DEPLOY_LOG" value="deploy.log" /> --> | |
<!-- logging --> | |
<add name="ERROR_LOG_DIR" value="log" /> | |
<!-- reload on files changes --> | |
<!-- <add name="WATCH_FILE_CHANGES_MASK" value="*.py" /> --> | |
</environmentVariables> | |
</application> | |
</heliconZoo> | |
<handlers> | |
<!-- Django or WSGI application over fastcgi --> | |
<add name="python.project#x86" scriptProcessor="python.2.7.wsgi" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" /> | |
<add name="python.project#x64" scriptProcessor="python.2.7.wsgi" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" /> | |
</handlers> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment