Python: Support pypi distribution for Python Client (#623)

* Python: move rpc to iotdb.rpc; support pypi distribution
This commit is contained in:
Xiangdong Huang 2019-12-07 14:41:42 +08:00 committed by GitHub
parent 4325ae4dc5
commit 4a60924efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 170 additions and 4 deletions

View File

@ -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

View File

@ -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,

View File

@ -868,7 +868,7 @@
<generator>py</generator>
<thriftExecutable>${thrift.exec.absolute.path}</thriftExecutable>
<thriftSourceRoot>${basedir}/src/main/thrift</thriftSourceRoot>
<outputDirectory>${project.build.directory}/generated-sources-python</outputDirectory>
<outputDirectory>${project.build.directory}/generated-sources-python/iotdb</outputDirectory>
</configuration>
</execution>
<execution>

View File

@ -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>

View File

@ -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.

View File

@ -0,0 +1,55 @@
# 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.
#
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/incubator-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',
website='https://iotdb.apache.org',
)