A Python wrapper module for OpenTrep
Project description
OpenTrepWrapper
Refefences
- OpenTREP project: https://github.com/trep/opentrep
- This GitHub project: https://github.com/trep/wrapper
- PyPi artifacts: https://pypi.org/project/OpenTrepWrapper/
- OpenTravelData (OPTD) project: https://github.com/opentraveldata/opentraveldata
- How to install
pyenv
andpipenv
- Twine utility
Configuration
Installation of OpenTREP
This module does not install OpenTREP, you have to do that.
On RedHat/CentOS/Fedora, OpenTREP is packaged and can therefore easily
be installed with the native packager manager (dnf
or yum
).
On the platforms, it can be installed by following the instructions
in the README.md
file.
For the remaining of this document, it assumed that OpenTREP has been
installed from the sources in ${HOME}/dev/deliveries/opentrep-latest
.
You can easily customize the PYTHONPATH
and LD_LIBRARY_PATH
environment variables to suit your own settings.
- You may put the package created by
setuptools
in the repository with:
$ export TREP_DIR="${HOME}/dev/deliveries/opentrep-latest"
$ export PYTHONPATH="${TREP_DIR}/lib/python3.7/site-packages/pyopentrep:${TREP_DIR}/lib"
$ export LD_LIBRARY_PATH="${TREP_DIR}/lib"
$ export PATH="${TREP_DIR}/bin:${PATH}"
Installation of pyenv
and pipenv
- Install Python:
$ pyenv install 3.8.2
$ pyenv global 3.8.2 && pip install -U pip pipenv && pyenv global system
- Clone this Git repository:
$ mkdir -p ~/dev/geo/trep && git clone https://github.com/trep/wrapper.git ~/dev/geo/trep/wrapper
- Install the Python virtual environment:
$ cd ~/dev/geo/trep/wrapper
$ pipenv install && pipenv install --dev
Test the wrapper application
- In the following Python examples, it is assumed that an interactive Python Shell has been launched:
$ pipenv run python
Python 3.8.2 (default, Mar 1 2020, 10:21:42)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
- Or, on MacOS:
$ ASAN_OPTIONS=detect_container_overflow=0 \
DYLD_INSERT_LIBRARIES=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib \
/usr/local/Cellar/python\@3.8/3.8.2/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
Python 3.8.2 (default, Mar 11 2020, 00:29:50)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
- Import the module:
>>> from OpenTrepWrapper import main_trep, index_trep
>>> from OpenTrepWrapper import DEFAULT_LOG, DEFAULT_FMT, DEFAULT_DB
- Index the OPTD data file:
>>> index_trep (xapianDBPath = '/tmp/opentrep/xapian_traveldb', logFilePath = '/tmp/opentrep/opeentrep-indexer.log', verbose = False)
- Search:
>>> main_trep (searchString = 'nce sfo', outputFormat = 'S', xapianDBPath = '/tmp/opentrep/xapian_traveldb', logFilePath = '/tmp/opentrep/opeentrep-searcher.log', verbose = False)
([(89.8466, 'NCE'), (357.45599999999996, 'SFO')], '')
- End the Python session:
>>> quit()
- On MacOS, if there is an issue with the interceptors:
$ ASAN_OPTIONS=detect_container_overflow=0 \
DYLD_INSERT_LIBRARIES=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib \
/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python test.py
......
----------------------------------------------------------------------
Ran 6 tests in 2.832s
OK
Release OpenTrepWrapper to PyPi
- Build the Python artifacts for OpenTrepWrapper:
$ rm -rf dist && mkdir dist
$ pipenv run python setup.py sdist bdist_wheel bdist_egg
$ ls -lFh dist
total 56
-rw-r--r-- 1 user staff 7.7K Mar 2 11:14 OpenTrepWrapper-0.7.5.post1-py3-none-any.whl
-rw-r--r-- 1 user staff 7.3K Mar 2 11:14 OpenTrepWrapper-0.7.5.post1-py3.8.egg
-rw-r--r-- 1 user staff 8.4K Mar 2 11:14 OpenTrepWrapper-0.7.5.post1.tar.gz
- Publish to PyPi:
$ pipenv run twine upload -u __token__ dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for OpenTrepWrapper-0.7.6.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc84aeb0c32f650c72e9cb1732d335f36d78245c22227060c85bee22c35cba97 |
|
MD5 | 6ed6f4292bbcd2009124260dfb9e65a8 |
|
BLAKE2b-256 | 7f6a2ea4b8668f4d8521a7330d4f954d5f98f1d179359685421e8728806b2f00 |
Close
Hashes for OpenTrepWrapper-0.7.6.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9efa6a55188f184445964c8c51ba4afc549553ca9444d3099915b6428f41515a |
|
MD5 | 46cae64db0f3bda3c3d5cbb95f6d0835 |
|
BLAKE2b-256 | cde3b5a5dfb47ae27eac4e021d8f13e8b74c7618a4e019a6d364c497c13bb988 |