You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2019/12/07 06:42:29 UTC

[incubator-iotdb] 01/04: Python: move rpc to iotdb.rpc; support pypi distribution

This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch rel/0.9
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit a601b069d3acad7fb8748b19995e077a0363a761
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Wed Dec 4 09:41:15 2019 +0800

    Python: move rpc to iotdb.rpc; support pypi distribution
---
 client-py/readme.md             |  2 +-
 client-py/src/client_example.py |  4 +--
 service-rpc/pom.xml             | 48 +++++++++++++++++++++++++++++++
 service-rpc/src/pypi/README.md  | 63 +++++++++++++++++++++++++++++++++++++++++
 service-rpc/src/pypi/setup.py   | 36 +++++++++++++++++++++++
 5 files changed, 150 insertions(+), 3 deletions(-)

diff --git a/client-py/readme.md b/client-py/readme.md
index 492b25c..7fb4718 100644
--- a/client-py/readme.md
+++ b/client-py/readme.md
@@ -42,7 +42,7 @@ locate the thrift source file by relative path, so if you move the scripts else
 no longer valid.
 
 Optionally, if you know the basic usage of thrift, you can only download the thrift source file in
-`service-rpc\src\main\thrift\rpc.thrift`, and simply use `thrift -gen py -out ./target rpc.thrift` 
+`service-rpc\src\main\thrift\rpc.thrift`, and simply use `thrift -gen py -out ./target/iotdb rpc.thrift` 
 to generate the python library.
 
 ## Example
diff --git a/client-py/src/client_example.py b/client-py/src/client_example.py
index 6926e17..8749d74 100644
--- a/client-py/src/client_example.py
+++ b/client-py/src/client_example.py
@@ -23,12 +23,12 @@ sys.path.append("../target")
 from thrift.protocol import TBinaryProtocol
 from thrift.transport import TSocket, TTransport
 
-from rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertionReq, \
+from iotdb.rpc.TSIService import Client, TSCreateTimeseriesReq, TSInsertionReq, \
     TSBatchInsertionReq, TSExecuteStatementReq, \
     TS_SessionHandle, TSHandleIdentifier, TSOpenSessionReq, TSQueryDataSet, \
     TSFetchResultsReq, TSCloseOperationReq, \
     TSCloseSessionReq
-from rpc.ttypes import TSProtocolVersion
+from iotdb.rpc.ttypes import TSProtocolVersion
 
 TSDataType = {
     'BOOLEAN': 0,
diff --git a/service-rpc/pom.xml b/service-rpc/pom.xml
index c1df159..4eaa09b 100644
--- a/service-rpc/pom.xml
+++ b/service-rpc/pom.xml
@@ -70,6 +70,54 @@
                     <skipITs>${rpc.it.skip}</skipITs>
                 </configuration>
             </plugin>
+            <!-- for pypi distribution -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.4.3</version>
+                <configuration>
+                    <encoding>${project.build.sourceEncoding}</encoding>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>copy-pypi-resources</id>
+                        <!-- here the phase you need -->
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <encoding>utf-8</encoding>
+                            <outputDirectory>${project.build.directory}/generated-sources-python</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>${basedir}/src/pypi</directory>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>copy-license-resources</id>
+                        <!-- here the phase you need -->
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <encoding>utf-8</encoding>
+                            <outputDirectory>${project.build.directory}/generated-sources-python</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>${basedir}/../</directory>
+                                    <includes>
+                                        <include>LICENSE</include>
+                                    </includes>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
     <profiles>
diff --git a/service-rpc/src/pypi/README.md b/service-rpc/src/pypi/README.md
new file mode 100644
index 0000000..34cd717
--- /dev/null
+++ b/service-rpc/src/pypi/README.md
@@ -0,0 +1,63 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+
+# Apache IoTDB
+
+[![Build Status](https://www.travis-ci.org/apache/incubator-iotdb.svg?branch=master)](https://www.travis-ci.org/apache/incubator-iotdb)
+[![codecov](https://codecov.io/gh/thulab/incubator-iotdb/branch/master/graph/badge.svg)](https://codecov.io/gh/thulab/incubator-iotdb)
+[![GitHub release](https://img.shields.io/github/release/apache/incubator-iotdb.svg)](https://github.com/apache/incubator-iotdb/releases)
+[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
+![](https://github-size-badge.herokuapp.com/apache/incubator-iotdb.svg)
+![](https://img.shields.io/github/downloads/apache/incubator-iotdb/total.svg)
+![](https://img.shields.io/badge/platform-win10%20%7C%20macox%20%7C%20linux-yellow.svg)
+![](https://img.shields.io/badge/java--language-1.8-blue.svg)
+[![IoTDB Website](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=iotdb-website)](https://iotdb.apache.org/)
+
+
+Apache IoTDB (incubating) (Database for Internet of Things) is an integrated data management engine designed for
+timeseries data. It provides users with services for data collection, storage and analysis. Due to its light-weight
+architecture, high performance and rich feature set together with its deep integration with Apache Hadoop and Spark,
+Apache IoTDB (incubating) can meet the requirements of massive data storage, high-speed data ingestion and complex data
+analysis in the IoT industrial fields.
+
+Apache IoTDB (incubating) was initially developed by Prof. Wang's Team of School of Software at Tsinghua University.
+Now it is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Incubator.
+
+# Apache IoTDB Python Client API
+
+Using the package, you can write data to IoTDB, read data from IoTDB and maintain the schema of IoTDB.
+
+## Requirements
+
+You have to install thrift (>=0.13) before using the package.
+
+## How to use (Example)
+
+You can get an example of using the package to read and write data at here: [Example](https://github.com/apache/incubator-iotdb/blob/release%2F0.9.0/client-py/src/client_example.py)
+
+# DISCLAIMER
+
+Apache IoTDB is an effort undergoing incubation at The Apache Software Foundation (ASF).
+Incubation is required of all newly accepted projects until a further review indicates that the
+infrastructure, communications, and decision making process have stabilized in a manner consistent
+with other successful ASF projects. While incubation status is not necessarily a reflection of the
+completeness or stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
\ No newline at end of file
diff --git a/service-rpc/src/pypi/setup.py b/service-rpc/src/pypi/setup.py
new file mode 100644
index 0000000..8cfffb4
--- /dev/null
+++ b/service-rpc/src/pypi/setup.py
@@ -0,0 +1,36 @@
+import setuptools
+import io
+
+
+try:
+    with io.open('README.md', encoding='utf-8') as f:
+        long_description = f.read()
+except FileNotFoundError:
+    long_description = ''
+
+
+print long_description
+
+setuptools.setup(
+    name="apache-iotdb", # Replace with your own username
+    version="0.9.0",
+    author=" Apache Software Foundation",
+    author_email="dev@iotdb.apache.org",
+    description="Apache IoTDB (incubating) client API",
+    long_description=long_description,
+    long_description_content_type="text/markdown",
+    url="https://github.com/apache/incuabtor-iotdb",
+    packages=setuptools.find_packages(),
+    install_requires=[
+              'thrift',
+          ],
+    classifiers=[
+        "Programming Language :: Python :: 3",
+        "License :: OSI Approved :: Apache Software License",
+        "Operating System :: OS Independent",
+        "Topic :: Software Development :: Libraries",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+    ],
+    python_requires='>=3.7',
+    license='Apache License, Version 2.0',
+)
\ No newline at end of file