Skip to content

Commit 28e589a

Browse files
Merge pull request #58 from bradmwilliams/official-packaging
Adding setup.py for pypi distribution
2 parents 1d1f6f6 + dcabd7d commit 28e589a

File tree

2 files changed

+62
-12
lines changed

2 files changed

+62
-12
lines changed

readme.md renamed to README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ the CLI documentation to find the pass-through arguments a given interaction req
6262
Setup-Prerequisites
6363
1. You will require certain pip packages, use the following command to install them when at the root folder of the repository.
6464

65-
```editorconfig
65+
```bash
6666
sudo pip install -r requirements.txt
6767
```
6868
2. Download and install the OpenShift [command-line Tools](https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/) needed to access your OpenShift cluster.
@@ -111,7 +111,7 @@ with oc.project('openshift-infra'), oc.timeout(10*60):
111111
for owner in pod_model.metadata.ownerReferences: # ownerReferences == oc.Missing if not present in resource
112112
# elements of a Model are also instances of Model or ListModel
113113
if owner.kind is not oc.Missing: # Compare as singleton
114-
print ' pod owned by a {}'.format(owner.kind) # e.g. pod was created by a StatefulSet
114+
print(' pod owned by a {}'.format(owner.kind)) # e.g. pod was created by a StatefulSet
115115
116116
```
117117
@@ -127,10 +127,10 @@ used again and again to select rows from a database.
127127
project_selector = oc.selector("projects")
128128
129129
# Print the qualified name (i.e. "kind/name") of each resource selected.
130-
print "Project names: " + str(project_selector.qnames())
130+
print("Project names: " + project_selector.qnames())
131131
132132
# Count the number of projects on the server.
133-
print "Number of projects: " + str(project_selector.count_existing())
133+
print("Number of projects: " + project_selector.count_existing())
134134
135135
# Selectors can also be created with a list of names.
136136
sa_selector = oc.selector(["serviceaccount/deployer", "serviceaccount/builder"])
@@ -143,7 +143,7 @@ sa_selector.label({"mylabel" : "myvalue"})
143143
sa_label_selector = oc.selector("sa", labels={"mylabel":"myvalue"})
144144
145145
# We should find the service accounts we just labeled.
146-
print("Found labeled serviceaccounts: " + str(sa_label_selector.names()))
146+
print("Found labeled serviceaccounts: " + sa_label_selector.names())
147147
148148
# Create a selector for a set of kinds.
149149
print(oc.selector(['dc', 'daemonset']).describe())
@@ -169,7 +169,7 @@ projects_sel = oc.selector("projects")
169169
# which model the selected resources.
170170
projects = projects_sel.objects()
171171
172-
print("Selected " + str(len(projects)) + " projects")
172+
print("Selected " + len(projects) + " projects")
173173
174174
# Let's store one of the project APIObjects for easy access.
175175
project = projects[0]
@@ -306,7 +306,7 @@ with oc.tracking() as tracker:
306306
print('Error acquiring current username')
307307
308308
# Print out details about the invocations made within this context.
309-
print tracker.get_result()
309+
print(tracker.get_result())
310310
```
311311
312312
In this case, the tracking output would look something like:
@@ -385,10 +385,10 @@ def node_is_ready(node):
385385
return ready
386386
387387
388-
print "Waiting for up to 15 minutes for at least 6 nodes to be ready..."
388+
print("Waiting for up to 15 minutes for at least 6 nodes to be ready...")
389389
with oc.timeout(15 * 60):
390390
oc.selector('nodes').until_all(6, success_func=node_is_ready)
391-
print "All detected nodes are reporting ready"
391+
print("All detected nodes are reporting ready")
392392
```
393393
394394
You will be able to see in `tracking` context results that a timeout occurred for an affected
@@ -404,10 +404,10 @@ context information.
404404
with oc.api_server('https:///....'): # use the specified api server for nested oc invocations.
405405
406406
with oc.token('abc..'): # --server=... --token=abc... will be included in inner oc invocations.
407-
print "Current project: " + oc.get_project_name()
407+
print("Current project: " + oc.get_project_name())
408408
409409
with oc.token('def..'): # --server=... --token=def... will be included in inner oc invocations.
410-
print "Current project: " + oc.get_project_name()
410+
print("Current project: " + oc.get_project_name())
411411
```
412412
413413
You can control the loglevel specified for `oc` invocations.
@@ -443,7 +443,7 @@ appropriate to the target client host.
443443
```python
444444
with openshift.client_host(hostname="my.cluster.com", username="root", auto_add_host=True):
445445
# oc invocations will take place on my.cluster.com host as the root user.
446-
print "Current project: " + oc.get_project_name()
446+
print("Current project: " + oc.get_project_name())
447447
```
448448
449449
Using this model, your Python script will run exactly where you launch it, but all oc invocations will

setup.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/python
2+
3+
from setuptools import setup, find_packages
4+
5+
6+
def get_requirements(filename="requirements.txt"):
7+
"""Extract requirements from a pip formatted requirements file."""
8+
9+
with open(filename, "r") as requirements_file:
10+
return requirements_file.read().splitlines()
11+
12+
13+
def get_long_description():
14+
"""Returns README.md content."""
15+
return open("README.md", "r").read()
16+
17+
18+
setup(
19+
name="openshift-client",
20+
version="0.1.0",
21+
author="Justin Pierce",
22+
author_email="[email protected]",
23+
maintainer="Brad Williams",
24+
maintainer_email="[email protected]",
25+
url="https://github.com/openshift/openshift-client-python",
26+
description="OpenShift python client",
27+
packages=find_packages(include="openshift"),
28+
package_dir={"": "packages"},
29+
install_requires=get_requirements(),
30+
keywords=["OpenShift"],
31+
include_package_data=True,
32+
data_files=[
33+
("requirements.txt", ["requirements.txt"]),
34+
],
35+
long_description=get_long_description(),
36+
long_description_content_type="text/markdown",
37+
classifiers=[
38+
"Development Status :: 4 - Beta",
39+
"Topic :: Utilities",
40+
"Intended Audience :: Developers",
41+
"Intended Audience :: Information Technology",
42+
"License :: OSI Approved :: Apache Software License",
43+
"Operating System :: OS Independent",
44+
"Programming Language :: Python",
45+
"Programming Language :: Python :: 2",
46+
"Programming Language :: Python :: 2.7",
47+
"Programming Language :: Python :: 3",
48+
"Programming Language :: Python :: 3.5",
49+
],
50+
)

0 commit comments

Comments
 (0)