Skip to content

Commit

Permalink
Publish Python library to PyPi. (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
zongweil authored Jul 23, 2019
1 parent 970ccfd commit 2c7115d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
__pycache__/
*.pyc
openlocationcode.egg-info/*
dist/*
2 changes: 1 addition & 1 deletion python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package(default_visibility = ["//visibility:public"])

py_library(
name = "openlocationcode",
srcs = ["openlocationcode.py"],
srcs = ["openlocationcode/openlocationcode.py"],
)

py_test(
Expand Down
28 changes: 28 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
This is the Python Open Location Code library. It is tested for both python 2.7
and python 3.6.

## Installing the library

The python library is available on PyPi. You can install it using pip:

```
pip install openlocationcode
```

## Formatting

Code must be formatted according to the
Expand Down Expand Up @@ -48,3 +56,23 @@ Run the unit tests and benchmarks locally with:
bazel test python:openlocationcode_test
```


## Releasing to PyPi

We release the python library to PyPi so users can install it using pip.

Pre-reqs:

```
pip install setuptools
pip install twine
```

To release a new version to PyPi, make sure you update the version number in setup.py. Then run:

```
python setup.py sdist
twine upload dist/*
```

Make sure any older versions are cleared out from dist before uploading. twine will prompt you for your PyPi credentials, which will need to be a collaborator on the project.
1 change: 1 addition & 0 deletions python/openlocationcode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from openlocationcode import *
File renamed without changes.
2 changes: 1 addition & 1 deletion python/openlocationcode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import random
import time
import unittest
import openlocationcode as olc
from openlocationcode import openlocationcode as olc

# Location of test data files.
_TEST_DATA = 'test_data'
Expand Down
19 changes: 19 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from setuptools import setup

# This call to setup() does all the work
setup(
name="openlocationcode",
version="1.0.1",
description="Python library for Open Location Code (Plus Codes)",
url="https://github.com/google/open-location-code",
author="Google",
author_email="[email protected]",
license="Apache 2.0",
classifiers=[
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
],
packages=["openlocationcode"],
include_package_data=True,
install_requires=[],
)

0 comments on commit 2c7115d

Please sign in to comment.