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

Commit

Permalink
Set up Python packaging for PyPI release. (#197)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
songy23 authored Apr 12, 2019
1 parent d4d9f63 commit 0994559
Show file tree
Hide file tree
Showing 23 changed files with 394 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ OpenCensus Proto - Language Independent Interface Types For OpenCensus
[![Maven Central][maven-image]][maven-url]
[![Javadocs][javadoc-image]][javadoc-url]
[![GoDoc][godoc-image]][godoc-url]
[![PyPI][pypi-image]][pypi-url]

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

### Add the dependencies to Bazel project

Expand Down
54 changes: 43 additions & 11 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ Then run the following commands to re-generate the gen-python files:

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

```bash
$ MAJOR=0 MINOR=4 PATCH=0 # Set appropriately for new release
$ VERSION_FILES=(
build.gradle
pom.xml
)
$ JAVA_VERSION_FILES=(build.gradle)
$ PYTHON_VERSION_FILES=(gen-python/version.py)
$ git checkout -b v$MAJOR.$MINOR.x master
$ git push upstream v$MAJOR.$MINOR.x
```
Expand Down Expand Up @@ -117,9 +114,11 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the
```bash
$ git checkout -b bump-version master
# Change version to next minor (and keep -SNAPSHOT)
# Change version to next minor (and keep -SNAPSHOT and .dev0)
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \
"${VERSION_FILES[@]}"
"${JAVA_VERSION_FILES[@]}"
$ sed -i 's/[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$((MINOR+1))'\1/' \
"${PYTHON_VERSION_FILES[@]}"
$ ./gradlew build
$ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle"
```
Expand All @@ -139,8 +138,9 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the
```bash
$ git checkout -b release v$MAJOR.$MINOR.x
# Change version to remove -SNAPSHOT
$ sed -i 's/-SNAPSHOT\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/\1/' "${VERSION_FILES[@]}"
# Change version to remove -SNAPSHOT and .dev0
$ sed -i 's/-SNAPSHOT\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/\1/' "${JAVA_VERSION_FILES[@]}"
$ sed -i 's/dev0\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'0'\1/' "${PYTHON_VERSION_FILES[@]}"
$ ./gradlew build
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH"
$ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH"
Expand All @@ -150,9 +150,11 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the
`0.4.1-SNAPSHOT`). Commit the result:
```bash
# Change version to next patch and add -SNAPSHOT
# Change version to next patch and add -SNAPSHOT and .dev1
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \
"${VERSION_FILES[@]}"
"${JAVA_VERSION_FILES[@]}"
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPENCENSUS_PROTO_VERSION\)/'$MAJOR.$MINOR.dev$((PATCH+1))'\1/' \
"${PYTHON_VERSION_FILES[@]}"
$ ./gradlew build
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT"
```
Expand Down Expand Up @@ -217,6 +219,36 @@ Central (the staging repository will be destroyed in the process). You can see
the complete process for releasing to Maven Central on the [OSSRH
site](http://central.sonatype.org/pages/releasing-the-deployment.html).

## Push Python package to PyPI

We follow the same package distribution process outlined at
[Python Packaging User Guide](https://packaging.python.org/tutorials/packaging-projects/).

### Prerequisites

If you haven't already, install the latest versions of setuptools, wheel and twine:
```bash
$ python3 -m pip install --user --upgrade setuptools wheel twine
```
### Branch
Before building/deploying, be sure to switch to the appropriate tag. The tag
must reference a commit that has been pushed to the main repository, i.e., has
gone through code review. For the current release use:
```bash
$ git checkout -b v$MAJOR.$MINOR.$PATCH tags/v$MAJOR.$MINOR.$PATCH
```
### Generate and upload the distribution archives
```bash
$ cd gen-python
$ python3 setup.py sdist bdist_wheel
$ python3 -m twine upload dist/*
```
## Announcement
Once deployment is done, go to Github [release
Expand Down
23 changes: 23 additions & 0 deletions gen-python/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
OpenCensus Proto
============================================================================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opencensus-proto.svg
:target: https://pypi.org/project/opencensus-proto/

Python library generated from OpenCensus cross-language protos.

Installation
------------

::

pip install opencensus-proto

Usage
-----

.. code:: python
# TBD
16 changes: 16 additions & 0 deletions gen-python/opencensus/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/agent/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

14 changes: 14 additions & 0 deletions gen-python/opencensus/proto/agent/common/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/agent/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

14 changes: 14 additions & 0 deletions gen-python/opencensus/proto/agent/metrics/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/agent/trace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

14 changes: 14 additions & 0 deletions gen-python/opencensus/proto/agent/trace/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

14 changes: 14 additions & 0 deletions gen-python/opencensus/proto/metrics/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/resource/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

14 changes: 14 additions & 0 deletions gen-python/opencensus/proto/resource/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/stats/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

14 changes: 14 additions & 0 deletions gen-python/opencensus/proto/stats/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

16 changes: 16 additions & 0 deletions gen-python/opencensus/proto/trace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

Loading

0 comments on commit 0994559

Please sign in to comment.