Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Byte-compiled / optimized / DLL files
__pycache__/*.*
*/__pycache__/
*.py[cod]
*$py.class

# PyCharm / Git folders
.idea/

# Script files
src/main/scripts/

# VS Code folders
.vscode/

# Unit test / coverage reports
.coverage
.coverage.*
nosetests.xml
coverage.xml
.pytest_cache/

# Sphinx documentation
docs/_build/
docs/_static/
docs/.doctrees/
docs/janusgraph_python*.rst
docs/modules.rst
docs/janusgraph_python.rst

# PyBuilder
target/

# pyenv
.python-version

# Environments
.env

# mkdocs documentation
site/
*/site/

# scripts files
src/main/scripts/*
src/main/scripts/*.*
60 changes: 60 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2018 JanusGraph Python Authors
#
# Licensed 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.

language: python

python:
- '3.6'
- '3.5'
- '3.4'
- '3.5-dev'
- '3.6-dev'
- '3.7-dev'

env:
global:
- ENV_NAME=tmpenv

install:
- pip install virtualenv
# Create Virtual env within which all packages will be installed. Default Python version is Travis' Python version
- virtualenv "${ENV_NAME}"

before_script:
# Install all pre-requisites for building library and docs
- bash before-script.sh "${ENV_NAME}"

script:
- bash build-library.sh "${ENV_NAME}"
- bash build-docs.sh "${ENV_NAME}"

after_script:
# Remove the virtualenv using pip
- pip uninstall virtualenv -y

# Deployment to PyPi configuration
# TODO: Update personal credentials for publishing to PyPi with JanusGraph user credentials.
branches:
only:
- master
before_deploy:
- cd target/dist/janusgraph_python
deploy:
provider: pypi
user:
password:
server: https://test.pypi.org/legacy/
skip_cleanup: true
on:
tags: true
69 changes: 69 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Building JanusGraph client for Python

- Building Library:

A set of scripts have been created to make the job of building the library easier for user, but the scripts
expects few pre requisites to be installed before hand.

- Pre-Requisites:
- Python needs to be installed on system. The library is currently tested against Python
3.4, 3.5 & 3.6 only.

- Python is added to system path. Make sure, the user can run the following commands from command line:
- python3/ python3.4/ python3.5/ python3.6 on Unix machines.
- python on Windows machines.

- Virtualenv needs to be installed. See [PyPi Page](https://pypi.org/project/virtualenv/) for installation steps.

- The automated build scripts are tested on following Operating Systems:
- Windows 7
- CentOS
- RHEL 7
- Ubuntu 18.04
- MacOS

- Building on Windows 7:
- A script build.cmd is created which accepts following keyword arguments:
- `d`: Specifies whether documents to be build. Set to true or false.
- `b`: Specifies whether library to be build. Set to true or false.

- If any of parameters are missing, the script exits with error message.
An appropriate way to invoke the script would be:
```bash
build.cmd "d=true" "b=true"
```
- The above example builds the docs, library and also installs to local global Python site-packages.

- Building on Unix System:
- A script named build.sh is created which accepts following parameters:
- `-d`: Default to true. Specifies if documentation is to be build.
- `-b`: Defaults to true. Specifies if library is to be build.
- `-p`: The path to Python interpreter on system. If not provided, the script expects python3 is installed\
and the command python3 works on shell and is used to generate virtualenv. If provided, the provided path is \
used to generate virtualenv.

**NOTE**: If you are building library on Max OS (OSx), then you will need to run by pre pending sudo -H.
Eg: sudo -H ./build.sh

If any of the defaults needs to be changed, the parameter needs to be specified explicitly while running the script.

- If you want to build just the documentation, without the library.
```bash
./build.sh -b false
```

- If you want to build just the library but aren't interested in building docs.
```bash
./build.sh -d false
```

- If you just want to build the library, and you have python interpreter installed at /usr/lib/python
```bash
./build.sh -d false -p /usr/lib/python
```

- And so on depending on your requirements.

Once done,
- You can see the built HTML files under `docs/_build/index.html` directory.
- You can see the build library under `target/dist/janusgraph-python/dist` directory.
82 changes: 80 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,84 @@
# JanusGraph Python driver
# JanusGraph-Python
## Python Client drivers for [JanusGraph](http://janusgraph.org)

## License
JanusGraph-Python is the Python drivers for connecting to JanusGraph.
It extends Apache TinkerPop™'s [Gremlin-Python](http://tinkerpop.apache.org/docs/current/reference/#_gremlin_python)
as its core dependency with additional support for JanusGraph-specific types and predicates.

### Pre-Requisites

The library has been tested with following Python versions:

- [Python 3.4](https://www.python.org/downloads/release/python-340/).
- [Python 3.5](https://www.python.org/downloads/release/python-350/).
- [Python 3.6](https://www.python.org/downloads/release/python-360/).

Once the required Python version is installed on system, please note the version number and the Python added
to Path. Make a note of the number, as that will be required during building of Library (on UNIX)
Try running either of following commands on CLI, and make a note of the version which works:

- python3 --version
- python3.4 --version
- python3.5 --version
- python3.6 --version

**NOTE**: The above checks aren't needed if installing the drivers from PyPi

### Building Library:

You can build the library yourself to test out the functionality of library. Refer to
[Building docs](BUILDING.md) for documentation on how to build the library.

### Installing the Library:

- Though Installation of library is built as a functionality of the automated build scripts provided,
but if needed, user can follow the bellow instructions to install the library to environment of their choice.

- To install library using Pip (It is not yet hosted):
```bash
# X is version number of JanusGraph Python client supported based on JanusGraph version chosen.
pip install janusgraph_python=X
```

- To install library from tarball, once it is built:
```bash
pip install target/dist/janusgraph_python/dist/janusgraph_python-X.tar.gz
# X is version number of JanusGraph Python client supported based on JanusGraph version chosen.
```

### Compatibility Matrix

| JanusGraph Version | Client Version |
|:------------------:|:--------------:|
|0.3.0 |0.1.0 |
|0.3.1 |0.1.0 |
|0.2.x |Not Released |

The JanusGraph client follows x.y.z version number, and according to [Semantic Versioning](https://semver.org/)
z is patch number. Hence, if a client is build using x.y against JanusGraph a.b.c,
irrespective of `.z` change, the client will remain compatible.

Example::

Version 1.0.0 is compatible with JanusGraph 0.3.0. Meaning that 1.0.1/1.0.2/..1.0.x will all be compatible with
JanusGraph 0.3.0

### Community

JanusGraph-Python uses the same communication channels as JanusGraph in general.
So, please refer to the
[Community section in JanusGraph's main repository](https://github.com/JanusGraph/janusgraph#community)
for more information about these various channels.


### Contributing

Please see
[`CONTRIBUTING.md` in JanusGraph's main repository](https://github.com/JanusGraph/janusgraph/blob/master/CONTRIBUTING.md)
for more information, including CLAs and best practices for working with GitHub.


### License

JanusGraph Python driver code is provided under the [Apache 2.0
license](APACHE-2.0.txt) and documentation is provided under the [CC-BY-4.0
Expand Down
39 changes: 39 additions & 0 deletions before-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# Copyright 2018 JanusGraph Python Authors
#
# Licensed 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.


if [ -z "${1:-}" ]; then
echo "Usage "$(basename "$0")" [Env Name]"
exit 1
else
ENV_NAME="${1}"
fi

case $(uname -s) in
MINGW*) python_path="${ENV_NAME}"/Scripts/activate;;
*) python_path="${ENV_NAME}"/bin/activate
esac

source "${python_path}"

python -m pip install pybuilder > /dev/null
python -m pip install sphinx > /dev/null
python -m pip install docker > /dev/null

case $(uname -s) in
MINGW*) source deactivate;;
*) deactivate
esac
52 changes: 52 additions & 0 deletions build-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

# Copyright 2018 JanusGraph Python Authors
#
# Licensed 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.


if [ -z "${1:-}" ]; then
echo "Usage "$(basename "$0")" [Env Name]"
exit 1
else
ENV_NAME="${1}"
fi

case $(uname -s) in
MINGW*) python_path="${ENV_NAME}"/Scripts/activate;;
*) python_path="${ENV_NAME}"/bin/activate
esac
#
source "${python_path}"
#pyenv activate "${ENV_NAME}"

# Auto-generate .rst files from docstrings of Python files. The .rst files are then used to generate html files
# for API docs
sphinx-apidoc -o docs/ src/main/python/janusgraph_python > /dev/null
# Generate HTML files from .rst files
pyb sphinx_generate_documentation

cd docs

# Remove auto-generated files to keep git history cleaner. They are anyways added to .gitignore also.
rm -rf janusgraph_python*.rst
rm -rf modules.rst

cd ../

#pyenv deactivate

case $(uname -s) in
MINGW*) source deactivate;;
*) deactivate
esac
39 changes: 39 additions & 0 deletions build-library.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# Copyright 2018 JanusGraph Python Authors
#
# Licensed 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.

if [ -z "${1:-}" ]; then
echo "Usage "$(basename "$0")" [Env Name]"
exit 1
else
ENV_NAME="${1}"
fi

# Build Library first
# Re-activate the Virtual environment
case $(uname -s) in
MINGW*) python_path="${ENV_NAME}"/Scripts/activate;;
*) python_path="${ENV_NAME}"/bin/activate
esac

source "${python_path}"

# For building the library
pyb -v

case $(uname -s) in
MINGW*) source deactivate;;
*) deactivate
esac
Loading