Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 0994559

Browse files
authored
Set up Python packaging for PyPI release. (#197)
* Set up Python packaging for PyPI release. * Remove namespace packages for */v1. * Remove redundant dependency. * Use Python style version and update commands. * Add PyPI badge to README.
1 parent d4d9f63 commit 0994559

File tree

23 files changed

+394
-11
lines changed

23 files changed

+394
-11
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ OpenCensus Proto - Language Independent Interface Types For OpenCensus
55
[![Maven Central][maven-image]][maven-url]
66
[![Javadocs][javadoc-image]][javadoc-url]
77
[![GoDoc][godoc-image]][godoc-url]
8+
[![PyPI][pypi-image]][pypi-url]
89

910
Census provides a framework to define and collect stats against metrics and to
1011
break those stats down across user-defined dimensions.
@@ -53,6 +54,8 @@ compile 'io.opencensus:opencensus-proto:0.2.0'
5354
[javadoc-url]: https://www.javadoc.io/doc/io.opencensus/opencensus-proto
5455
[godoc-image]: https://godoc.org/github.com/census-instrumentation/opencensus-proto?status.svg
5556
[godoc-url]: https://godoc.org/github.com/census-instrumentation/opencensus-proto
57+
[pypi-image]: https://badge.fury.io/py/opencensus-proto.svg
58+
[pypi-url]: https://pypi.org/project/opencensus-proto/
5659

5760
### Add the dependencies to Bazel project
5861

RELEASING.md

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ Then run the following commands to re-generate the gen-python files:
6161

6262
```bash
6363
$ git checkout -b update-gen-python # Assume you're under opencensus-proto/
64-
$ rm -rf gen-python
6564
$ cd src
6665
$ ./mkpygen.sh
6766
$ git add -A
@@ -84,10 +83,8 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the
8483

8584
```bash
8685
$ MAJOR=0 MINOR=4 PATCH=0 # Set appropriately for new release
87-
$ VERSION_FILES=(
88-
build.gradle
89-
pom.xml
90-
)
86+
$ JAVA_VERSION_FILES=(build.gradle)
87+
$ PYTHON_VERSION_FILES=(gen-python/version.py)
9188
$ git checkout -b v$MAJOR.$MINOR.x master
9289
$ git push upstream v$MAJOR.$MINOR.x
9390
```
@@ -117,9 +114,11 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the
117114
118115
```bash
119116
$ git checkout -b bump-version master
120-
# Change version to next minor (and keep -SNAPSHOT)
117+
# Change version to next minor (and keep -SNAPSHOT and .dev0)
121118
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \
122-
"${VERSION_FILES[@]}"
119+
"${JAVA_VERSION_FILES[@]}"
120+
$ sed -i 's/[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$((MINOR+1))'\1/' \
121+
"${PYTHON_VERSION_FILES[@]}"
123122
$ ./gradlew build
124123
$ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle"
125124
```
@@ -139,8 +138,9 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the
139138
140139
```bash
141140
$ git checkout -b release v$MAJOR.$MINOR.x
142-
# Change version to remove -SNAPSHOT
143-
$ sed -i 's/-SNAPSHOT\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/\1/' "${VERSION_FILES[@]}"
141+
# Change version to remove -SNAPSHOT and .dev0
142+
$ sed -i 's/-SNAPSHOT\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/\1/' "${JAVA_VERSION_FILES[@]}"
143+
$ sed -i 's/dev0\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'0'\1/' "${PYTHON_VERSION_FILES[@]}"
144144
$ ./gradlew build
145145
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH"
146146
$ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH"
@@ -150,9 +150,11 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the
150150
`0.4.1-SNAPSHOT`). Commit the result:
151151
152152
```bash
153-
# Change version to next patch and add -SNAPSHOT
153+
# Change version to next patch and add -SNAPSHOT and .dev1
154154
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \
155-
"${VERSION_FILES[@]}"
155+
"${JAVA_VERSION_FILES[@]}"
156+
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$MINOR.dev$((PATCH+1))'\1/' \
157+
"${PYTHON_VERSION_FILES[@]}"
156158
$ ./gradlew build
157159
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT"
158160
```
@@ -217,6 +219,36 @@ Central (the staging repository will be destroyed in the process). You can see
217219
the complete process for releasing to Maven Central on the [OSSRH
218220
site](http://central.sonatype.org/pages/releasing-the-deployment.html).
219221

222+
## Push Python package to PyPI
223+
224+
We follow the same package distribution process outlined at
225+
[Python Packaging User Guide](https://packaging.python.org/tutorials/packaging-projects/).
226+
227+
### Prerequisites
228+
229+
If you haven't already, install the latest versions of setuptools, wheel and twine:
230+
```bash
231+
$ python3 -m pip install --user --upgrade setuptools wheel twine
232+
```
233+
234+
### Branch
235+
236+
Before building/deploying, be sure to switch to the appropriate tag. The tag
237+
must reference a commit that has been pushed to the main repository, i.e., has
238+
gone through code review. For the current release use:
239+
240+
```bash
241+
$ git checkout -b v$MAJOR.$MINOR.$PATCH tags/v$MAJOR.$MINOR.$PATCH
242+
```
243+
244+
### Generate and upload the distribution archives
245+
246+
```bash
247+
$ cd gen-python
248+
$ python3 setup.py sdist bdist_wheel
249+
$ python3 -m twine upload dist/*
250+
```
251+
220252
## Announcement
221253
222254
Once deployment is done, go to Github [release

gen-python/README.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
OpenCensus Proto
2+
============================================================================
3+
4+
|pypi|
5+
6+
.. |pypi| image:: https://badge.fury.io/py/opencensus-proto.svg
7+
:target: https://pypi.org/project/opencensus-proto/
8+
9+
Python library generated from OpenCensus cross-language protos.
10+
11+
Installation
12+
------------
13+
14+
::
15+
16+
pip install opencensus-proto
17+
18+
Usage
19+
-----
20+
21+
.. code:: python
22+
23+
# TBD

gen-python/opencensus/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
16+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
16+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+

0 commit comments

Comments
 (0)