Add basic win32 support for dev bootstrap
This commit is contained in:
parent
4980e5784b
commit
f6cf02bcaf
|
@ -12,10 +12,13 @@ here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
def bootstrap():
|
def bootstrap():
|
||||||
|
|
||||||
if not inside_virtualenv():
|
if not inside_virtualenv():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# install wheel
|
||||||
|
subprocess.run(['pip', 'install', 'wheel'],
|
||||||
|
check=True)
|
||||||
|
|
||||||
# install invoke, sphinx
|
# install invoke, sphinx
|
||||||
subprocess.run(['pip', 'install', 'invoke', 'Sphinx'],
|
subprocess.run(['pip', 'install', 'invoke', 'Sphinx'],
|
||||||
check=True)
|
check=True)
|
||||||
|
@ -23,6 +26,9 @@ def bootstrap():
|
||||||
# run bootstrap task
|
# run bootstrap task
|
||||||
os.chdir(here)
|
os.chdir(here)
|
||||||
try:
|
try:
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
completed = subprocess.run(['invoke', 'bootstrap'])
|
||||||
|
else:
|
||||||
completed = subprocess.run(['invoke', '--echo', 'bootstrap'])
|
completed = subprocess.run(['invoke', '--echo', 'bootstrap'])
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(130) # 128 + SIGINT
|
sys.exit(130) # 128 + SIGINT
|
||||||
|
@ -33,10 +39,18 @@ def bootstrap():
|
||||||
def inside_virtualenv():
|
def inside_virtualenv():
|
||||||
if not (hasattr(sys, 'real_prefix') or
|
if not (hasattr(sys, 'real_prefix') or
|
||||||
(hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)):
|
(hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)):
|
||||||
print("\nNot running inside a virtual environment!\n\n"
|
print("")
|
||||||
"Please create and activate that first, e.g. like:\n\n"
|
print("Not running inside a virtual environment!")
|
||||||
" python -m venv /srv/envs/theo\n"
|
print("")
|
||||||
" source /srv/envs/theo/bin/activate\n")
|
print("Please create and activate that first, e.g. like:")
|
||||||
|
print("")
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
print(" py -m venv C:\\envs\\theo")
|
||||||
|
print(" C:\\envs\\theo\\Scripts\\activate.bat")
|
||||||
|
else:
|
||||||
|
print(" python -m venv /srv/envs/theo")
|
||||||
|
print(" source /srv/envs/theo/bin/activate")
|
||||||
|
print("")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
[rattail]
|
[rattail]
|
||||||
timezone.default = America/Chicago
|
timezone.default = America/Chicago
|
||||||
datadir = <ENVDIR>/app/data
|
datadir = <ENVDIR><SEP>app<SEP>data
|
||||||
batch.files = <ENVDIR>/app/data/batch
|
batch.files = <ENVDIR><SEP>app<SEP>data<SEP>batch
|
||||||
workdir = <ENVDIR>/app/work
|
workdir = <ENVDIR><SEP>app<SEP>work
|
||||||
|
|
||||||
[rattail.config]
|
[rattail.config]
|
||||||
# include = /etc/rattail/rattail.conf
|
# include = /etc/rattail/rattail.conf
|
||||||
|
@ -39,7 +39,7 @@ default.to = root@localhost
|
||||||
pictures.gtin.root_url = https://rattailproject.org/pod/pictures/gtin
|
pictures.gtin.root_url = https://rattailproject.org/pod/pictures/gtin
|
||||||
|
|
||||||
[rattail.upgrades]
|
[rattail.upgrades]
|
||||||
files = <ENVDIR>/app/data/upgrades
|
files = <ENVDIR><SEP>app<SEP>data<SEP>upgrades
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
# alembic
|
# alembic
|
||||||
|
@ -106,7 +106,7 @@ handlers =
|
||||||
|
|
||||||
[handler_file]
|
[handler_file]
|
||||||
class = handlers.RotatingFileHandler
|
class = handlers.RotatingFileHandler
|
||||||
args = ('<ENVDIR>/app/log/rattail.log', 'a', 1000000, 100, 'utf_8')
|
args = (r'<ENVDIR><SEP>app<SEP>log<SEP>rattail.log', 'a', 1000000, 100, 'utf_8')
|
||||||
formatter = generic
|
formatter = generic
|
||||||
|
|
||||||
[handler_console]
|
[handler_console]
|
||||||
|
|
46
dev/tasks.py
46
dev/tasks.py
|
@ -47,6 +47,9 @@ def bootstrap(c):
|
||||||
print("start your development web app with this command:")
|
print("start your development web app with this command:")
|
||||||
print()
|
print()
|
||||||
print(" cd {}".format(envdir))
|
print(" cd {}".format(envdir))
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
print(r" Scripts\pserve --reload file+ini:app\web.conf")
|
||||||
|
else:
|
||||||
print(" bin/pserve --reload file+ini:app/web.conf")
|
print(" bin/pserve --reload file+ini:app/web.conf")
|
||||||
print()
|
print()
|
||||||
print("then check out your development web app at:")
|
print("then check out your development web app at:")
|
||||||
|
@ -100,6 +103,9 @@ def upgrade_pip(c):
|
||||||
"""
|
"""
|
||||||
Upgrade pip and friends
|
Upgrade pip and friends
|
||||||
"""
|
"""
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
c.run('python -m pip install -U pip')
|
||||||
|
else:
|
||||||
c.run('pip install -U pip')
|
c.run('pip install -U pip')
|
||||||
c.run('pip install -U setuptools wheel')
|
c.run('pip install -U setuptools wheel')
|
||||||
|
|
||||||
|
@ -119,7 +125,13 @@ def make_appdir(c, envdir):
|
||||||
"""
|
"""
|
||||||
appdir = os.path.join(envdir, 'app')
|
appdir = os.path.join(envdir, 'app')
|
||||||
if not os.path.exists(appdir):
|
if not os.path.exists(appdir):
|
||||||
c.run('{} make-appdir'.format(os.path.join(envdir, 'bin', 'rattail')))
|
if sys.platform == 'win32':
|
||||||
|
c.run('{} make-appdir --path {}'.format(
|
||||||
|
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||||
|
appdir))
|
||||||
|
else:
|
||||||
|
c.run('{}/bin/rattail make-appdir --path {}'.format(
|
||||||
|
envdir, appdir))
|
||||||
return appdir
|
return appdir
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,6 +144,7 @@ def make_configs(c, envdir, appdir, info):
|
||||||
with open('rattail.conf') as f:
|
with open('rattail.conf') as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
contents = contents.replace('<ENVDIR>', envdir)
|
contents = contents.replace('<ENVDIR>', envdir)
|
||||||
|
contents = contents.replace('<SEP>', os.sep)
|
||||||
contents = contents.replace('<DBHOST>', info['dbhost'])
|
contents = contents.replace('<DBHOST>', info['dbhost'])
|
||||||
contents = contents.replace('<DBNAME>', info['dbname'])
|
contents = contents.replace('<DBNAME>', info['dbname'])
|
||||||
contents = contents.replace('<DBUSER>', info['dbuser'])
|
contents = contents.replace('<DBUSER>', info['dbuser'])
|
||||||
|
@ -141,13 +154,20 @@ def make_configs(c, envdir, appdir, info):
|
||||||
|
|
||||||
# quiet.conf
|
# quiet.conf
|
||||||
if not os.path.exists(os.path.join(appdir, 'quiet.conf')):
|
if not os.path.exists(os.path.join(appdir, 'quiet.conf')):
|
||||||
c.run('{}/bin/rattail make-config -T quiet -O {}'.format(envdir, appdir))
|
if sys.platform == 'win32':
|
||||||
|
c.run('{} make-config -T quiet -O {}'.format(
|
||||||
|
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||||
|
appdir))
|
||||||
|
else:
|
||||||
|
c.run('{}/bin/rattail make-config -T quiet -O {}'.format(
|
||||||
|
envdir, appdir))
|
||||||
|
|
||||||
# web.conf
|
# web.conf
|
||||||
if not os.path.exists(os.path.join(appdir, 'web.conf')):
|
if not os.path.exists(os.path.join(appdir, 'web.conf')):
|
||||||
with open('web.conf') as f:
|
with open('web.conf') as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
contents = contents.replace('<ENVDIR>', envdir)
|
contents = contents.replace('<ENVDIR>', envdir)
|
||||||
|
contents = contents.replace('<SEP>', os.sep)
|
||||||
with open(os.path.join(appdir, 'web.conf'), 'w') as f:
|
with open(os.path.join(appdir, 'web.conf'), 'w') as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
|
||||||
|
@ -156,19 +176,37 @@ def check_db(c, envdir, appdir):
|
||||||
"""
|
"""
|
||||||
Do basic sanity checks for Theo database
|
Do basic sanity checks for Theo database
|
||||||
"""
|
"""
|
||||||
c.run('{}/bin/rattail -c {}/quiet.conf --no-versioning checkdb'.format(envdir, appdir))
|
if sys.platform == 'win32':
|
||||||
|
c.run('{} -c {} --no-versioning checkdb'.format(
|
||||||
|
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||||
|
os.path.join(appdir, 'quiet.conf')))
|
||||||
|
else:
|
||||||
|
c.run('{}/bin/rattail -c {}/quiet.conf --no-versioning checkdb'.format(
|
||||||
|
envdir, appdir))
|
||||||
|
|
||||||
|
|
||||||
def install_db_schema(c, envdir, appdir):
|
def install_db_schema(c, envdir, appdir):
|
||||||
"""
|
"""
|
||||||
Install the schema for Theo database
|
Install the schema for Theo database
|
||||||
"""
|
"""
|
||||||
c.run('{}/bin/alembic -c {}/rattail.conf upgrade heads'.format(envdir, appdir))
|
if sys.platform == 'win32':
|
||||||
|
c.run('{} -c {} upgrade heads'.format(
|
||||||
|
os.path.join(envdir, 'Scripts', 'alembic'),
|
||||||
|
os.path.join(appdir, 'rattail.conf')))
|
||||||
|
else:
|
||||||
|
c.run('{}/bin/alembic -c {}/rattail.conf upgrade heads'.format(
|
||||||
|
envdir, appdir))
|
||||||
|
|
||||||
|
|
||||||
def make_admin_user(c, envdir, appdir, info):
|
def make_admin_user(c, envdir, appdir, info):
|
||||||
"""
|
"""
|
||||||
Make an admin user in the Theo database
|
Make an admin user in the Theo database
|
||||||
"""
|
"""
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
c.run('{} -c {} make-user --admin {} --password {}'.format(
|
||||||
|
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||||
|
os.path.join(appdir, 'quiet.conf'),
|
||||||
|
info['theouser'], info['theopass']))
|
||||||
|
else:
|
||||||
c.run('{}/bin/rattail -c {}/quiet.conf make-user --admin {} --password {}'.format(
|
c.run('{}/bin/rattail -c {}/quiet.conf make-user --admin {} --password {}'.format(
|
||||||
envdir, appdir, info['theouser'], info['theopass']))
|
envdir, appdir, info['theouser'], info['theopass']))
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
##############################
|
##############################
|
||||||
|
|
||||||
[rattail.config]
|
[rattail.config]
|
||||||
include = %(here)s/rattail.conf
|
include = %(here)s<SEP>rattail.conf
|
||||||
|
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
|
@ -53,4 +53,4 @@ port = 9080
|
||||||
level = INFO
|
level = INFO
|
||||||
|
|
||||||
[handler_file]
|
[handler_file]
|
||||||
args = ('<ENVDIR>/app/log/web.log', 'a', 1000000, 100, 'utf_8')
|
args = (r'<ENVDIR><SEP>app<SEP>log<SEP>web.log', 'a', 1000000, 100, 'utf_8')
|
||||||
|
|
Loading…
Reference in a new issue