From c2b02695d16b212287096454f75282e9f7ff0dd4 Mon Sep 17 00:00:00 2001 From: Benjamin Braatz Date: Mon, 15 Jul 2019 11:53:57 +0200 Subject: [PATCH] Add infrastructure to make project installable by pip. --- LICENSE | 19 +++++++++++++++++++ README.md | 7 +++++++ doc/index.md | 25 ++++++++++++++----------- graph/__init__.py | 2 ++ graph.py => graph/connection_raw.py | 2 +- setup.py | 24 ++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 graph/__init__.py rename graph.py => graph/connection_raw.py (99%) create mode 100644 setup.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ea428a2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019 Graph-IT GmbH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4588af3 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Python Graph API + +This is a minimal Python API for the [Graph](https://graph-it.com/). +It works with Python 2 as well as Python 3. + +A more detailed documentation can be found in [doc/index.md](doc/index.md), +which can also be found at [http://docs.graph-it.com/graphit/graph-client-py](http://docs.graph-it.com/graphit/graph-client-py). diff --git a/doc/index.md b/doc/index.md index feedf61..0a79771 100644 --- a/doc/index.md +++ b/doc/index.md @@ -1,22 +1,17 @@ # Python Graph API -This is a minimal Python API for the Graph. +This is a minimal Python API for the [Graph](https://graph-it.com/). It works with Python 2 as well as Python 3. -## Prerequisites +## Installation -The Graph API uses [msgpack](https://msgpack.org/). -So, the Python binding for it has to be installed. - -For Debian-based distributions these can be done by: +The Python Graph API can be installed with `pip` directly from our git repository: ```sh -# apt install python-msgpack python3-msgpack +$ pip install git://git.graph-it.com/graphit/graph-client-py.git ``` -With pip, it can be done by: -```sh -# pip install msgpack -``` +The Graph API uses [msgpack](https://msgpack.org/). +So, the Python binding for it will be installed as a dependency. In order to use TLS connections to graphs, a client certificate chain has to be available in a file. @@ -58,3 +53,11 @@ The `test.py` script reads the configuration of a main graph from `config.json`, queries this main graph for remote graphs configured in it, prints a summary of all graph modules in the main graph and all remote graphs and downloads stationeries in all the graphs if they are configured there. + +## Plans + +Up to now, only a raw connection is implemented, +i.e., the Python implementation does not know anything about the actual API calls and just passes them to the graph server. + +We should add implementation and documentation for these actual API calls. +This would also allow to do at least some of the necessary conversions already in the library. diff --git a/graph/__init__.py b/graph/__init__.py new file mode 100644 index 0000000..f5b6299 --- /dev/null +++ b/graph/__init__.py @@ -0,0 +1,2 @@ +from graph.connection_raw import RawConnection as Connection +__all__ = ["Connection"] diff --git a/graph.py b/graph/connection_raw.py similarity index 99% rename from graph.py rename to graph/connection_raw.py index 4f03051..4349844 100644 --- a/graph.py +++ b/graph/connection_raw.py @@ -10,7 +10,7 @@ except ImportError: from msgpack import packb, unpackb -class Connection: +class RawConnection: def __init__(self, url, crt_filename=''): self.__url = url self.__crt_filename = crt_filename diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f5abc08 --- /dev/null +++ b/setup.py @@ -0,0 +1,24 @@ +import setuptools + +with open("README.md", "r") as readme_file: + long_description = readme_file.read() + +setuptools.setup( + name="graph-graphit", + version="0.0.1", + author="Graph-IT GmbH", + author_email="info@graph-it.com", + description="Python implementation of the Graph API", + long_description=long_description, + long_description_content_type="text/markdown", + url="http://docs.graph-it.com/graphit/graph-client-py", + packages=setuptools.find_packages(), + install_requires=[ + "msgpack" + ], + classifiers=[ + "Programming Language :: Python", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], +) -- 2.34.1