11#!/usr/bin/env python3
22
33import sys
4+
45sys .dont_write_bytecode = True
56import os
67import shutil
1011import glob
1112import platform
1213
13-
1414PROJ_ROOT = pathlib .Path (__file__ ).parent
1515
1616
@@ -53,11 +53,11 @@ def _arg2bool(arg):
5353 return arg .lower () in ('true' , 'yes' , '1' )
5454
5555
56- COMMANDS = set ()
56+ COMMANDS = []
5757
5858
5959def command (fn ):
60- COMMANDS .add (fn .__name__ )
60+ COMMANDS .append (fn .__name__ )
6161 return fn
6262
6363
@@ -67,28 +67,28 @@ def build():
6767
6868
6969@command
70- def serve (port = None ):
71- port = port or 8000
72- docs_dir = PROJ_ROOT / 'build' / 'docs'
73- _run ('python3' , '-m' , 'http.server' , port , cwd = docs_dir )
70+ def test (all = False , patch_path = '1' , * args ):
71+ env = {'TEST_QUESTDB_PATCH_PATH' : patch_path }
72+ if _arg2bool (all ):
73+ env ['TEST_QUESTDB_INTEGRATION' ] = '1'
74+ _run ('python3' , 'test/test.py' , '-v' , * args ,
75+ env = env )
7476
7577
7678@command
7779def doc (http_serve = False , port = None ):
7880 _run ('python3' , '-m' , 'sphinx.cmd.build' ,
79- '-b' , 'html' , 'docs' , 'build/docs' ,
80- env = {'PYTHONPATH' : str (PROJ_ROOT / 'src' )})
81+ '-b' , 'html' , 'docs' , 'build/docs' ,
82+ env = {'PYTHONPATH' : str (PROJ_ROOT / 'src' )})
8183 if _arg2bool (http_serve ):
8284 serve (port )
8385
8486
8587@command
86- def test (all = False , patch_path = '1' , * args ):
87- env = {'TEST_QUESTDB_PATCH_PATH' : patch_path }
88- if _arg2bool (all ):
89- env ['TEST_QUESTDB_INTEGRATION' ] = '1'
90- _run ('python3' , 'test/test.py' , '-v' , * args ,
91- env = env )
88+ def serve (port = None ):
89+ port = port or 8000
90+ docs_dir = PROJ_ROOT / 'build' / 'docs'
91+ _run ('python3' , '-m' , 'http.server' , port , cwd = docs_dir )
9292
9393
9494@command
@@ -105,11 +105,16 @@ def cibuildwheel(*args):
105105 # Python version.
106106 python = '/Library/Frameworks/Python.framework/Versions/3.8/bin/python3'
107107 _run (python , '-m' ,
108- 'cibuildwheel' ,
109- '--platform' , plat ,
110- '--output-dir' , 'dist' ,
111- '--archs' , platform .machine (),
112- * args )
108+ 'cibuildwheel' ,
109+ '--platform' , plat ,
110+ '--output-dir' , 'dist' ,
111+ '--archs' , platform .machine (),
112+ * args )
113+
114+
115+ @command
116+ def cw (* args ):
117+ cibuildwheel (args )
113118
114119
115120@command
@@ -133,6 +138,17 @@ def clean():
133138 _rm (PROJ_ROOT / 'src' , '**/*.html' )
134139
135140
141+ @command
142+ def venv ():
143+ if pathlib .Path ('venv' ).exists ():
144+ sys .stderr .write ('venv already exists, delete it, or run command clean\n ' )
145+ return
146+ _run ('python3' , '-m' , 'venv' , 'venv' )
147+ _run ('venv/bin/python3' , '-m' , 'pip' , 'install' , '-U' , 'pip' )
148+ _run ('venv/bin/python3' , '-m' , 'pip' , 'install' , '-r' , 'dev_requirements.txt' )
149+ sys .stdout .write ('NOTE: remember to activate the environment: source venv/bin/activate\n ' )
150+
151+
136152def main ():
137153 if len (sys .argv ) < 2 :
138154 sys .stderr .write ('Usage: python3 proj.py <command>\n ' )
0 commit comments