thriftpy 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
thriftpy/__init__.py ADDED
@@ -0,0 +1,51 @@
1
+ """thriftpy is now a thin alias for thriftpy2.
2
+
3
+ Every ``thriftpy[.*]`` import resolves to the same object as its ``thriftpy2``
4
+ twin, so legacy ``import thriftpy`` code runs on the maintained thriftpy2.
5
+ """
6
+
7
+ import importlib
8
+ import sys
9
+ from importlib.abc import Loader, MetaPathFinder
10
+ from importlib.util import spec_from_loader
11
+
12
+ import thriftpy2
13
+
14
+ _SRC = "thriftpy2"
15
+ _DST = "thriftpy"
16
+
17
+
18
+ class _AliasLoader(Loader):
19
+ def __init__(self, real_name):
20
+ self.real_name = real_name
21
+
22
+ def create_module(self, spec):
23
+ return importlib.import_module(self.real_name)
24
+
25
+ def exec_module(self, module):
26
+ pass
27
+
28
+
29
+ class _AliasFinder(MetaPathFinder):
30
+ def find_spec(self, fullname, path=None, target=None):
31
+ if fullname != _DST and not fullname.startswith(_DST + "."):
32
+ return None
33
+ return spec_from_loader(fullname, _AliasLoader(_SRC + fullname[len(_DST):]))
34
+
35
+
36
+ # Intercept thriftpy.* before the default finders look on disk.
37
+ if not any(isinstance(f, _AliasFinder) for f in sys.meta_path):
38
+ sys.meta_path.insert(0, _AliasFinder())
39
+
40
+ from thriftpy2 import ( # noqa: E402
41
+ install_import_hook,
42
+ load,
43
+ load_fp,
44
+ load_module,
45
+ remove_import_hook,
46
+ )
47
+
48
+ __version__ = thriftpy2.__version__
49
+ __python__ = sys.version_info
50
+ __all__ = ["install_import_hook", "remove_import_hook", "load", "load_module",
51
+ "load_fp"]
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: thriftpy
3
+ Version: 0.6.0
4
+ Summary: Compatibility shim that exposes thriftpy2 under the historical thriftpy name.
5
+ Home-page: https://github.com/Thriftpy/thriftpy
6
+ Author: Lx Yu
7
+ Author-email: i@lxyu.net
8
+ License: MIT
9
+ Keywords: thrift python thriftpy thriftpy2
10
+ Classifier: Topic :: Software Development
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
17
+ Requires-Python: >=3.7
18
+ License-File: LICENSE
19
+ Requires-Dist: thriftpy2==0.6.0
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: keywords
26
+ Dynamic: license
27
+ Dynamic: license-file
28
+ Dynamic: requires-dist
29
+ Dynamic: requires-python
30
+ Dynamic: summary
31
+
32
+ ========
33
+ ThriftPy
34
+ ========
35
+
36
+ **thriftpy is now a thin shim around** `thriftpy2 <https://github.com/Thriftpy/thriftpy2>`_.
37
+ The actual implementation lives in thriftpy2, and installing thriftpy just re-exports it under the historical ``thriftpy`` name.
38
+ The two packages are released in sync and contain identical functionality at the same version, so you can pick whichever name you prefer.
39
+
40
+
41
+ .. image:: http://img.shields.io/travis/eleme/thriftpy/develop.svg?style=flat
42
+ :target: https://travis-ci.org/eleme/thriftpy
43
+
44
+ .. image:: http://img.shields.io/github/release/eleme/thriftpy.svg?style=flat
45
+ :target: https://github.com/eleme/thriftpy/releases
46
+
47
+ .. image:: http://img.shields.io/pypi/v/thriftpy.svg?style=flat
48
+ :target: https://pypi.python.org/pypi/thriftpy
49
+
50
+ .. image:: http://img.shields.io/pypi/dm/thriftpy.svg?style=flat
51
+ :target: https://pypi.python.org/pypi/thriftpy
52
+
53
+ ThriftPy is a pure python implementation of
54
+ `Apache Thrift <http://thrift.apache.org/>`_ in a pythonic way.
55
+
56
+ Documentation: https://thriftpy.readthedocs.org/
57
+
58
+
59
+ Installation
60
+ ============
61
+
62
+ Install with pip.
63
+
64
+ .. code:: bash
65
+
66
+ $ pip install thriftpy
67
+
68
+ You may also install cython first to build cython extension locally.
69
+
70
+ .. code:: bash
71
+
72
+ $ pip install cython thriftpy
73
+
74
+
75
+ Code Demo
76
+ =========
77
+
78
+ ThriftPy make it super easy to write server/client code with thrift. Let's
79
+ checkout this simple pingpong service demo.
80
+
81
+ We need a 'pingpong.thrift' file:
82
+
83
+ ::
84
+
85
+ service PingPong {
86
+ string ping(),
87
+ }
88
+
89
+ Then we can make a server:
90
+
91
+ .. code:: python
92
+
93
+ import thriftpy
94
+ pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
95
+
96
+ from thriftpy.rpc import make_server
97
+
98
+ class Dispatcher(object):
99
+ def ping(self):
100
+ return "pong"
101
+
102
+ server = make_server(pingpong_thrift.PingPong, Dispatcher(), '127.0.0.1', 6000)
103
+ server.serve()
104
+
105
+ And a client:
106
+
107
+ .. code:: python
108
+
109
+ import thriftpy
110
+ pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
111
+
112
+ from thriftpy.rpc import make_client
113
+
114
+ client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6000)
115
+ print(client.ping())
116
+
117
+ See, it's that easy!
118
+
119
+ You can refer to 'examples' and 'tests' directory in source code for more
120
+ usage examples.
121
+
122
+
123
+
124
+ Features
125
+ ========
126
+
127
+ Currently ThriftPy have these features (also advantages over the upstream
128
+ python lib):
129
+
130
+ - Supports Python 2.7, Python 3.4+, PyPy and PyPy3.
131
+
132
+ - Pure python implementation. No longer need to compile & install the 'thrift'
133
+ package. All you need is thriftpy and thrift file.
134
+
135
+ - Compatible with Apache Thrift. You can use ThriftPy together with the
136
+ official implementation servers and clients, such as a upstream server with
137
+ a thriftpy client or the opposite.
138
+
139
+ Currently implemented protocols and transports:
140
+
141
+ * binary protocol (python and cython)
142
+
143
+ * compact protocol (python and cython)
144
+
145
+ * json protocol
146
+
147
+ * buffered transport (python & cython)
148
+
149
+ * framed transport
150
+
151
+ * tornado server and client (with tornado 4.0)
152
+
153
+ * http server and client
154
+
155
+ - Can directly load thrift file as module, the sdk code will be generated on
156
+ the fly.
157
+
158
+ For example, ``pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")``
159
+ will load 'pingpong.thrift' as 'pingpong_thrift' module.
160
+
161
+ Or, when import hook enabled by ``thriftpy.install_import_hook()``, you can
162
+ directly use ``import pingpong_thrift`` to import the 'pingpong.thrift' file
163
+ as module, you may also use ``from pingpong_thrift import PingService`` to
164
+ import specific object from the thrift module.
165
+
166
+ - Easy RPC server/client setup.
167
+
168
+
169
+
170
+ Contribute
171
+ ==========
172
+
173
+ 1. Fork the repo and make changes.
174
+
175
+ 2. Write a test which shows a bug was fixed or the feature works as expected.
176
+
177
+ 3. Make sure ``travis-ci`` or ``tox`` tests succeed.
178
+
179
+ 4. Send pull request.
180
+
181
+
182
+ Contributors
183
+ ============
184
+
185
+ https://github.com/eleme/thriftpy/graphs/contributors
186
+
187
+
188
+ Changelog
189
+ =========
190
+
191
+ https://github.com/eleme/thriftpy/blob/master/CHANGES.rst
@@ -0,0 +1,6 @@
1
+ thriftpy/__init__.py,sha256=czCMjoAYKLHGvLbKRc5uMiISUYS-t947N9--NJyrY2A,1371
2
+ thriftpy-0.6.0.dist-info/licenses/LICENSE,sha256=Au5_tZpe5Sgc_DKFaOwo7xiAjTyM5CTgb-KVS24zPok,1081
3
+ thriftpy-0.6.0.dist-info/METADATA,sha256=NzvupyIML8zZo3iqPwJXJlSKYS4UroZCArq23Six0bc,4933
4
+ thriftpy-0.6.0.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
5
+ thriftpy-0.6.0.dist-info/top_level.txt,sha256=lbN45Tlp1vpOM3hKEH59_n3dxPHGp-NTFItHD8MgvJM,9
6
+ thriftpy-0.6.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <2014> <Eleme Inc.>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ thriftpy