Skip to content

Commit 6611753

Browse files
committed
chore: add proj.py venv, document it, add one simple example sending two lines
1 parent f2c3bd8 commit 6611753

File tree

5 files changed

+80
-27
lines changed

5 files changed

+80
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ celerybeat.pid
107107
*.sage.py
108108

109109
# Environments
110+
.idea
110111
.env
111112
.venv
112113
env/

DEV_NOTES.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,36 @@ Install Rust as per https://rustup.rs/.
1919
2020
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2121
22-
Install Cython:
22+
Install your local Python3 environment **venv**
23+
24+
.. code-block:: bash
25+
26+
python3 -m venv venv
27+
venv/bin/python install -U pip
28+
venv/bin/python install -r dev_requirements.txt
29+
30+
# or simply:
31+
python3 proj.py venv
32+
33+
# either of the ^ ^ should be followed by:
34+
source venv/bin/activate
35+
36+
The development requirements are these if you prefer to install them one by one:
37+
38+
- Install Cython:
2339

2440
.. code-block:: bash
2541
2642
python3 -m pip install cython
2743
28-
Documentation
29-
-------------
44+
- Documentation
3045

3146
.. code-block:: bash
3247
3348
python3 -m pip install sphinx
3449
python3 -m pip install sphinx_rtd_theme
3550
36-
37-
Packaging and releasing
38-
-----------------------
51+
- Packaging and releasing
3952

4053
.. code-block:: bash
4154
@@ -87,7 +100,7 @@ MacOS Apple Silicon, run:
87100
.. code-block:: bash
88101
89102
python3 proj.py sdist # source distribution
90-
python3 proj.py cibuildwheel
103+
python3 proj.py cibuildwheel # the order of these two lines does not matter
91104
92105
This will end up putting everything in the ``dist/`` directory.
93106

dev_requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
setuptools>=45.2.0
2+
Cython>=0.29.24
3+
wheel>=0.34.2
4+
cibuildwheel>=2.8.0
5+
Sphinx>=5.0.2
6+
sphinx-rtd-theme>=1.0.0
7+
twine>=4.0.1
8+
bump2version>=1.0.1

examples/line_sender_example.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from questdb.ilp import Sender, TimestampNanos
2+
3+
if __name__ == '__main__':
4+
with Sender('localhost', 9009) as sender:
5+
sender.row(
6+
'line_sender_example',
7+
symbols={'id': 'OMEGA'},
8+
columns={'price': '111222233333i', 'qty': 3.5}
9+
)
10+
sender.row(
11+
'line_sender_example',
12+
symbols={'id': 'OMEGA'},
13+
columns={'price': '111222233330i', 'qty': 2.5}
14+
)
15+
sender.flush()

proj.py

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import sys
4+
45
sys.dont_write_bytecode = True
56
import os
67
import shutil
@@ -10,7 +11,6 @@
1011
import glob
1112
import platform
1213

13-
1414
PROJ_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

5959
def 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
7779
def 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+
136152
def main():
137153
if len(sys.argv) < 2:
138154
sys.stderr.write('Usage: python3 proj.py <command>\n')

0 commit comments

Comments
 (0)