1
1
"""PyQ - Python for kdb+
2
2
3
- |Documentation Status| |PyPI Version|
3
+ PyQ brings the Python programming language to the kdb+ database. It allows
4
+ developers to seamlessly integrate Python and q codes in one application.
5
+ This is achieved by bringing the Python and q interpreters in the same
6
+ process so that codes written in either of the languages operate on the same
7
+ data. In PyQ, Python and q objects live in the same memory space and share
8
+ the same data.
4
9
5
- PyQ_ brings the `Python programming language`_ to the `kdb+ database`_. It
6
- allows developers to seamlessly integrate Python and q codes in one
7
- application. This is achieved by bringing the Python and q interpreters in
8
- the same process so that codes written in either of the languages operate on
9
- the same data. In PyQ, Python and q objects live in the same memory space
10
- and share the same data.
11
-
12
- .. |Documentation Status|
13
- image:: https://readthedocs.org/projects/pyq/badge/?version=latest
14
- :target: http://pyq.readthedocs.io/en/latest/?badge=latest
15
-
16
- .. |PyPI Version| image:: https://img.shields.io/pypi/v/pyq.svg
17
- :target: https://pypi.python.org/pypi/pyq
18
-
19
- .. _PyQ: https://code.kx.com/q/interfaces/pyq/
20
- .. _`Python programming language`: https://www.python.org/about
21
- .. _`kdb+ database`: https://kx.com
22
10
"""
23
11
import os
24
12
import platform
25
13
import subprocess
26
14
import sys
27
15
16
+ try :
17
+ from setuptools import setup
18
+ except ImportError :
19
+ from distutils .core import setup
20
+
21
+ from distutils .core import Command , Distribution , Extension
28
22
from distutils .command .build import build
29
23
from distutils .command .build_ext import build_ext
30
24
from distutils .command .config import config
35
29
import sysconfig
36
30
37
31
WINDOWS = platform .system () == 'Windows'
38
- if WINDOWS :
39
- from setuptools import Command , Distribution , Extension , setup
40
- else :
41
- from distutils .core import Command , Distribution , Extension , setup
42
-
43
- VERSION = '4.2.1'
44
- IS_RELEASE = True
45
32
VERSION_FILE = 'src/pyq/version.py'
46
- VERSION_PY = """\
47
- # generated by setup.py
48
- version = '{}'
49
- """
50
-
51
33
CFLAGS = ['/WX' , '/wd4090' ] if WINDOWS else ['-fno-strict-aliasing' ]
52
34
53
35
if sys .version_info >= (3 , ) and not WINDOWS :
@@ -131,8 +113,6 @@ def split_replace(string, a, b, sep):
131
113
'Operating System :: POSIX :: Linux' ,
132
114
'Operating System :: Microsoft :: Windows :: Windows 10' ,
133
115
'Programming Language :: C' ,
134
- 'Programming Language :: Python :: 2.7' ,
135
- 'Programming Language :: Python :: 3.5' ,
136
116
'Programming Language :: Python :: 3.6' ,
137
117
'Programming Language :: Python :: 3.7' ,
138
118
'Programming Language :: Python :: Implementation :: CPython' ,
@@ -154,34 +134,6 @@ def add_data_file(data_files, target, source):
154
134
f .append (source )
155
135
156
136
157
- def get_version ():
158
- write_version_file = True
159
- if IS_RELEASE :
160
- version = VERSION
161
- elif os .path .exists ('.git' ):
162
- try :
163
- out = subprocess .check_output (['git' , 'describe' ])
164
- _ , commits , revision = decode (out ).strip ().split ('-' )
165
- version = '{}.dev{}+{}' .format (VERSION , commits , revision [1 :])
166
- except (OSError , ValueError ):
167
- version = VERSION + '.dev0+unknown'
168
- else :
169
- try :
170
- f = open (VERSION_FILE )
171
- except OSError :
172
- version = VERSION + '.dev0+unknown'
173
- else :
174
- with f :
175
- g = {}
176
- exec (f .read (), g )
177
- version = g ['version' ]
178
- write_version_file = False
179
- if write_version_file :
180
- with open (VERSION_FILE , 'w' ) as f :
181
- f .write (VERSION_PY .format (version ))
182
- return version
183
-
184
-
185
137
def get_q_home (env ):
186
138
"""Derive q home from the environment"""
187
139
q_home = env .get ('QHOME' )
@@ -453,17 +405,13 @@ def run(self):
453
405
dry_run = self .dry_run ,
454
406
force = self .force )
455
407
customize_compiler (compiler )
456
- define = self .define [:]
457
- if sys .version_info >= (3 ,):
458
- py3k = '{:d}{:d}' .format (* sys .version_info [:2 ])
459
- define .append (('PY3K' , py3k ))
460
408
if WINDOWS :
461
409
compiler .initialize ()
462
410
compiler .compile_options .remove ('/MD' )
463
411
extra_args = ext .extra_compile_args or []
464
412
objects = compiler .compile (sources ,
465
413
output_dir = self .build_temp ,
466
- macros = define ,
414
+ macros = self . define ,
467
415
extra_postargs = extra_args ,
468
416
include_dirs = include_dirs )
469
417
extra_args = conf .extra_link_args [:] + ext .extra_link_args
@@ -661,12 +609,14 @@ class PyqDistribution(Distribution):
661
609
662
610
def run_setup (metadata ):
663
611
summary , details = __doc__ .split ('\n \n ' , 1 )
664
- rst_description = '\n ' .join ([summary , '=' * len (summary ), '\n ' + details ])
612
+ with open ('README.md' ) as f :
613
+ long_description = f .read ()
665
614
keywords = metadata .copy ()
666
615
keywords .update (
667
- version = get_version () ,
616
+ use_scm_version = { 'write_to' : VERSION_FILE } ,
668
617
description = summary ,
669
- long_description = rst_description ,
618
+ long_description = long_description ,
619
+ long_description_content_type = 'text/markdown' ,
670
620
distclass = PyqDistribution ,
671
621
cmdclass = {
672
622
'config' : Config ,
@@ -686,26 +636,10 @@ def run_setup(metadata):
686
636
'all' : TEST_REQUIREMENTS + IPYTHON_REQUIREMENTS + [
687
637
'py' , 'numpy' , 'prompt-toolkit' , 'pygments-q' ],
688
638
}
689
- if (sys .version_info >= (3 ,) and not WINDOWS and
690
- 'CONDA_PREFIX' not in os .environ and
691
- os .path .exists ('embedPy/p.q' )):
692
- try :
693
- import numpy
694
- except ImportError :
695
- pass
696
- else :
697
- add_embedpy_components (keywords )
639
+ keywords ['setup_requires' ] = ['setuptools_scm' ]
698
640
699
641
setup (** keywords )
700
642
701
643
702
- def add_embedpy_components (keywords ):
703
- keywords ['qlib_scripts' ].append ('../../embedPy/p.q' )
704
- keywords ['qext_modules' ].append (
705
- Extension ('p' , sources = ['embedPy/py.c' , ]),
706
- )
707
- add_data_file (keywords ['data_files' ], 'q' , 'embedPy/p.q' )
708
-
709
-
710
644
if __name__ == '__main__' :
711
645
run_setup (METADATA )
0 commit comments