diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000..9be2a5fc --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,34 @@ +name: On pull request + +on: + pull_request: + branches: [ main ] + +jobs: + build_python: + runs-on: ubuntu-latest + + steps: + - name: Get current time + uses: gerred/actions/current-time@master + id: current-time + + - uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel build + + - name: Build package + run: | + set -e + set -x + export PYPI_MOMENTO_WIRE_TYPE_VERSION=0.0.devBuild + python -m build + shell: bash diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d93d06ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Compiled python modules. +src/*.pyc + +# Setuptools distribution folder. +/dist/ + +# Python egg metadata, regenerated from source files by setuptools. +src/*.egg-info + +# Don't checkin the virtual environemnt +client_sdk_python_env diff --git a/README.md b/README.md index 577fd9db..1e3b9545 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # client-sdk-python Python SDK for Momento + +# Requirements +* Python 3 +* [Virual environment setup](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv) + +# Setup pre-requisites +`./prepare_local_dev_env.sh` +The script creates a python virtual environment and installs dependencies + +## Setting up IDE +### Visual Studio Code +Use `Cmd` + `Shift` + `P` to search for `Python: Interpreter` and select: +`./client_sdk_python_env/bin/python` \ No newline at end of file diff --git a/prepare_local_dev_env.sh b/prepare_local_dev_env.sh new file mode 100755 index 00000000..59987a72 --- /dev/null +++ b/prepare_local_dev_env.sh @@ -0,0 +1,3 @@ +python3 -m venv client_sdk_python_env +source client_sdk_python_env/bin/activate +pip install -e . --extra-index-url https://momento.jfrog.io/artifactory/api/pypi/pypi-public/simple diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..374b58cb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..23a49f6c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +# requirements.txt is required to debug/run sdk locally. Pip needs requirements +# that must be installed to proceed. +# +# Since, SDK will be distributed via PyPi it is needed to provide installation +# requirements in setup.cfg. +# +# Instead of maintaining two different requirements, use setup.cfg as the +# primary source. Hence a '.' is provided here which signals pip to use +# dependencies from setup.cfg +. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..b0d073bd --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[metadata] +name = momento-sdk + +[options] +package_dir = + = src +packages = find: +python_requires = >=3.6 +install_requires = + momento-wire-types==0.3.0 + build + setuptools + +[options.packages.find] +where = src diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..2a836a9c --- /dev/null +++ b/setup.py @@ -0,0 +1,13 @@ +import setuptools +import os +import time + +version = os.getenv("PYPI_MOMENTO_WIRE_TYPE_VERSION") + +if [version == None]: + version = '0.0.dev' + +# version is the only dynamic configuration +setuptools.setup( + version=version, +) diff --git a/src/momento_sdk/__init__.py b/src/momento_sdk/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/momento_sdk/momento.py b/src/momento_sdk/momento.py new file mode 100644 index 00000000..a4b91ba0 --- /dev/null +++ b/src/momento_sdk/momento.py @@ -0,0 +1,13 @@ +import momento_wire_types.controlclient_pb2 as control_client + +class Momento: + def __init__(self, auth_token, endpoint_override=None): + self._auth_token__ = auth_token + self._endpoint_override = endpoint_override + + def create_cache(self, cache_name): + print("hello") + + +def init(auth_token): + return Momento(auth_token=auth_token)