Skip to content

Commit d6337f6

Browse files
committed
Update Python library setup
1 parent 3485e1b commit d6337f6

File tree

7 files changed

+54
-74
lines changed

7 files changed

+54
-74
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ sdk/js/package-lock.json
77
sdk/python/dist/
88
sdk/python/libopenstorage_openstorage.egg-info/
99
sdk/python/setup.py
10+
api.proto

sdk/python/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ APIDIR := ../..
22
VEDIR := build
33
PYTHON := python3
44
PIP := pip3
5+
PATCH :=
56
all: grpc
67

78
ifndef APIVER
89
$(error Must provide an APIVER value)
910
endif
1011

1112
grpc:
13+
-sudo rm -rf $(VEDIR) > /dev/null 2>&1
1214
$(PYTHON) -m venv $(VEDIR)
1315
bash -c "source $(VEDIR)/bin/activate && \
16+
$(PIP) install --upgrade pip && \
1417
$(PIP) install -r requirements.txt && \
1518
$(PYTHON) -m grpc_tools.protoc \
1619
-I$(APIDIR) \
@@ -34,10 +37,17 @@ grpc:
3437
--grpc_python_out=. \
3538
$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api/http.proto"
3639
sed -i -e "s#^import api_pb2 as api__pb2#from openstorage import api_pb2 as api__pb2#" openstorage/api_pb2_grpc.py
37-
sed -e "s#%%APIVER%%#$(APIVER)#" setup.py.tmpl > setup.py
40+
sed -e "s#%%APIVER%%#$(APIVER)$(PATCH)#" setup.py.tmpl > setup.py
3841
bash -c "source $(VEDIR)/bin/activate && \
3942
$(PYTHON) setup.py sdist bdist_egg"
4043

44+
release:
45+
$(PYTHON) -m venv release
46+
bash -c "source release/bin/activate && \
47+
python3 -m pip install --upgrade pip && \
48+
python3 -m pip install --upgrade twine"
49+
50+
4151
clean:
4252
sudo rm -rf $(VEDIR) setup.py dist libopenstorage_openstorage.egg-info
4353

sdk/python/README.md

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
# Python gRPC Client Library
1+
# Python gRPC Client Library for OpenStorage SDK
22

3-
# Build
4-
5-
Type `make`.
6-
7-
# Installing
8-
9-
Installing through pip is now supported:
10-
11-
```
12-
python3 -m venv sdk
13-
source sdk/bin/activate
14-
pip3 install libopenstorage-openstorage
15-
```
16-
17-
> NOTE: Python 2.7 is no longer supported. This is for Python3 only.
3+
For more information please see https://libopenstorage.github.io
184

195
# Example
206

217
```python
22-
#
23-
# More info: https://grpc.io/docs/quickstart/python.html
24-
#
258
import grpc
269

2710
from openstorage import api_pb2
@@ -48,11 +31,6 @@ try:
4831
))
4932
print('Volume id is {0}'.format(v_resp.volume_id))
5033
except grpc.RpcError as e:
51-
print('Failed: code={0} msg={1}'.format(e.code(), e.details()))(build)
34+
print('Failed: code={0} msg={1}'.format(e.code(), e.details()))
5235
```
5336

54-
# PyPi
55-
56-
See https://dzone.com/articles/executable-package-pip-install
57-
58-

sdk/python/dev.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Pypi Release
2+
3+
* Read https://packaging.python.org/en/latest/tutorials/packaging-projects/
4+
5+
* Type: `make release` to setup the venv
6+
* Type: `source release/bin/activate`
7+
8+
Then follow the documentation from the page above to push your change to the
9+
testpypi server.
10+
11+
Once you have tested that you can install from testpypi, then you can push
12+
to normal pypi with the command:
13+
14+
```
15+
python3 -m twine upload dist/*
16+
```
17+
18+
> NOTE: You will need to setup your $HOME/.pypirc with the API tokens for both
19+
> the testpypi and pypi servers.
20+
21+
22+
## Patch Number
23+
24+
If during the testing you find an error and fix it, then you will want to add
25+
a PATCH number of ".1", and so on to the value of PATCH in the Makefile. This is
26+
due to pypi or testpypi not allowing uploads to get overwritten.

sdk/python/pypi.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

sdk/python/requirements.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
cachetools==5.2.0
2-
certifi==2022.6.15
3-
charset-normalizer==2.1.0
4-
google-auth==2.9.1
5-
grpcio==1.26.0
6-
grpcio-tools==1.26.0
2+
certifi==2022.6.15.1
3+
charset-normalizer==2.1.1
4+
google-auth==2.11.0
5+
grpcio==1.48.1
6+
grpcio-tools==1.48.1
77
idna==3.3
88
kubernetes==24.2.0
9-
oauthlib==3.2.0
9+
oauthlib==3.2.1
1010
protobuf==3.20.1
1111
pyasn1==0.4.8
1212
pyasn1-modules==0.2.8
@@ -16,5 +16,5 @@ requests==2.28.1
1616
requests-oauthlib==1.3.1
1717
rsa==4.9
1818
six==1.16.0
19-
urllib3==1.26.11
20-
websocket-client==1.3.3
19+
urllib3==1.26.12
20+
websocket-client==1.4.1

sdk/python/setup.py.tmpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import setuptools
22

3-
with open("pypi.md", "r") as fh:
4-
long_description = fh.read()
3+
def read(fname):
4+
with open(fname, "r") as fh:
5+
return fh.read()
56

67
setuptools.setup(
78
name="libopenstorage-openstorage",
89
version="%%APIVER%%",
910
author="Portworx",
1011
author_email="lpabon@purestorage.com",
1112
description="OpenStorage SDK Python gRPC Client Library",
12-
long_description=long_description,
13+
long_description=read("README.md"),
1314
long_description_content_type="text/markdown",
1415
url="https://github.com/libopenstorage/openstorage-sdk-clients",
1516
packages=setuptools.find_packages(),
@@ -19,6 +20,6 @@ setuptools.setup(
1920
"License :: OSI Approved :: Apache Software License",
2021
"Operating System :: OS Independent",
2122
],
22-
python_requires='>=3.0',
23+
python_requires='>=3.5',
2324
)
2425

0 commit comments

Comments
 (0)