@@ -30,97 +30,205 @@ Dependency Management Toolkit for Google Cloud Python Projects
3030 :widths: 20, 30
3131
3232 "Self Compatibility", |self_compatibility |
33+ "Google Compatibility", |google_compatibility |
34+ "Dependency Version Status", |dependency_version_status |
3335
3436.. |self_compatibility | image :: http://35.226.8.89/self_compatibility_badge/image?package=compatibility_lib
3537 :target: http://35.226.8.89/self_compatibility_badge/target?package=compatibility_lib
38+ .. |google_compatibility | image :: http://35.226.8.89/google_compatibility_badge/image?package=compatibility_lib
39+ :target: http://35.226.8.89/google_compatibility_badge/target?package=compatibility_lib
40+ .. |dependency_version_status | image :: http://35.226.8.89/self_dependency_badge/image?package=compatibility_lib
41+ :target: http://35.226.8.89/self_dependency_badge/target?package=compatibility_lib
3642
37- Development Workflow (Linux)
38- ---------------------------------
43+ -----------------
44+ Compatibility Lib
45+ -----------------
46+
47+ `Compatibility Lib `_ is a library to get compatibility status and dependency information of Python packages.
48+ It contains three tools: compatibility checker, outdated dependency highlighter and deprecated dependency finder.
49+ And it also provides utilities to query data from the BigQuery tables (external user will need to set up tables
50+ with the same schema that this library is using).
51+
52+ .. _Compatibility Lib : https://pypi.org/project/compatibility-lib/
53+
54+ Installation:
55+
56+ .. code-block :: bash
57+
58+ pip install compatibility-lib
59+
60+
61+ Compatibility Checker
62+ ---------------------
63+
64+ Compatibility checker gets the compatibility data by sending requests to the Compatibility Server endpoint,
65+ or by querying the BigQuery table (if the given package is listed in our configs, which are pre-computed).
66+
67+ Usage like below,
68+
69+ .. code-block :: python
70+
71+ import itertools
72+ from compatibility_lib import compatibility_checker
73+
74+ packages = [' package1' , ' package2' , ' package3' ]
75+ package_pairs = itertools.combinations(packages, 2 )
76+ checker = compatibility_checker.CompatibilityChecker()
77+
78+ # Get self compatibility data
79+ checker.get_self_compatibility(python_version = ' 3' , packages = packages)
80+
81+ # Get pairwise compatibility data
82+ checker.get_pairwise_compatibility(
83+ python_version = ' 3' , pkg_sets = package_pairs)
84+
85+ Outdated Dependency Highlighter
86+ -------------------------------
87+
88+ Outdated Dependency Highlighter finds out the outdated dependencies of a Python package, and determines
89+ the priority of updating the dependency version based on a set of criteria below:
90+
91+ - Mark “High Priority” if dependencies have widely adopted major release. (e.g 1.0.0 -> 2.0.0)
92+ - Mark “High Priority” if a new version has been available for more than 6 months.
93+ - Mark “High Priority” if dependencies are 3 or more sub-versions behind the newest one. (e.g 1.0.0 -> 1.3.0)
94+ - Mark “Low Priority” for other dependency updates.
95+
96+ Usage:
97+
98+ .. code-block :: python
99+
100+ from compatibility_lib import dependency_highlighter
101+
102+ packages = [' package1' , ' package2' , ' package3' ]
103+ highlighter = dependency_highlighter.DependencyHighlighter()
104+ highlighter.check_packages(packages)
105+
106+ Deprecated Dependency Finder
107+ ----------------------------
108+
109+ Deprecated Dependency Finder can find out the deprecated dependencies that a Python package
110+ depends on.
111+
112+ Usage:
113+
114+ .. code-block :: python
115+
116+ from compatibility_lib import deprecated_dep_finder
117+
118+ packages = [' package1' , ' package2' , ' package3' ]
119+ finder = deprecated_dep_finder.DeprecatedDepFinder()
120+ for res in finder.get_deprecated_deps(packages):
121+ print (res)
122+
123+ ------------
124+ Badge Server
125+ ------------
126+
127+ Displaying the compatibility status for your package as a Github Badge.
128+
129+ Types of badges
130+ ---------------
39131
40- Set Up Python Environment
132+ 1. Self Compatibility
133+ 2. Compatibility with Google OSS Python packages
134+ 3. Dependency version status
135+
136+ Usage
137+ -----
138+
139+ See the usage `here `_.
140+
141+ .. _here : https://github.com/GoogleCloudPlatform/cloud-opensource-python/blob/master/badge_server/README.rst
142+
143+ ------------
144+ Contributing
145+ ------------
146+
147+ Set up environment
148+ ------------------
149+
150+ - Set Up Python Environment
41151
42152https://cloud.google.com/python/setup
43153
44154
45- Install py 3.6 (may not be included in previous step)
155+ - Install py 3.6 (may not be included in previous step)
46156
47157.. code-block :: bash
48158
49159 sudo apt install python3.6
50160
51161
52- Clone the cloud-opensource-python project and cd to project
162+ - Clone the cloud-opensource-python project and cd to project
53163
54164.. code-block :: bash
55165
56166 git clone git@github.com:GoogleCloudPlatform/cloud-opensource-python.git
57167 cd cloud-opensource-python
58168
59169
60- Fork project and configure git remote settings
170+ - Fork project and configure git remote settings
61171
62172.. code-block :: bash
63173
64174 git remote add upstream git@github.com:GoogleCloudPlatform/cloud-opensource-python.git
65175 git config --global user.email " email@example.com"
66176
67177
68- Install tox, create a virtualenv, and source
178+ - Create a virtualenv, and source
69179
70180.. code-block :: bash
71181
72- pip install tox
73182 tox -e py36
74183 source .tox/py36/bin/activate
75184
76- Build compatibility_lib library from source and install
185+ - Install gcloud SDK and initialize
77186
78187.. code-block :: bash
79188
80- python compatibility_lib/setup.py bdist_wheel
81- pip install compatibility_lib/dist/*
82-
83- Install Nox for testing
189+ curl https://sdk.cloud.google.com | bash
190+ gcloud init
84191
85- .. code-block :: bash
192+ Set up credentials
193+ ------------------
86194
87- pip install nox-automation
195+ - Create new service account key
88196
89- Install gcloud SDK and initialize
197+ 1. In your browser, navigate to Cloud Console
90198
91- .. code-block :: bash
199+ 2. menu > IAM & admin > Service accounts
92200
93- curl https://sdk.cloud.google.com | bash
94- gcloud init
201+ 3. under bigquery-admin, actions > create new key
95202
96- Install google-cloud-bigquery
203+ - Set GOOGLE_APPLICATION_CREDENTIALS
97204
98205.. code-block :: bash
206+
207+ export GOOGLE_APPLICATION_CREDENTIALS=”path/to/service/key.json”
99208
100- pip install google-cloud-bigquery
209+ Contributing to compatibility_lib
210+ ---------------------------------
101211
102- Create new service account key (** do this on the workstation **)
212+ - Build compatibility_lib library from source and install
103213
104- - in chrome browser, navigate to pantheon/
214+ .. code-block :: bash
105215
106- - menu > IAM & admin > Service accounts
216+ python compatibility_lib/setup.py bdist_wheel
217+ pip install compatibility_lib/dist/*
107218
108- - under bigquery-admin, actions > create new key
219+ -------
220+ Testing
221+ -------
109222
110- Set GOOGLE_APPLICATION_CREDENTIALS
223+ We use nox test suite for running tests.
111224
112- .. code-block :: bash
113-
114- export GOOGLE_APPLICATION_CREDENTIALS=”path/to/service/key.json”
225+ - Install Nox for testing
115226
116- Test credentials within python interpreter (no errors means it’s working)
227+ .. code-block :: bash
117228
118- .. code-block :: python
119-
120- from google.cloud import bigquery
121- bigquery.client.Client()
229+ pip install nox-automation
122230
123- Run tests:
231+ - Run the tests
124232
125233.. code-block :: bash
126234
@@ -130,12 +238,13 @@ Run tests:
130238 nox -l # see available options
131239 nox # run everything
132240
133-
241+ -------
134242License
135243-------
136244
137245Apache 2.0 - See `LICENSE <LICENSE >`__ for more information.
138246
247+ ----------
139248Disclaimer
140249----------
141250
0 commit comments