Skip to content

Commit 2c7115d

Browse files
authored
Publish Python library to PyPi. (#356)
1 parent 970ccfd commit 2c7115d

File tree

7 files changed

+52
-2
lines changed

7 files changed

+52
-2
lines changed

python/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
__pycache__/
22
*.pyc
3+
openlocationcode.egg-info/*
4+
dist/*

python/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package(default_visibility = ["//visibility:public"])
22

33
py_library(
44
name = "openlocationcode",
5-
srcs = ["openlocationcode.py"],
5+
srcs = ["openlocationcode/openlocationcode.py"],
66
)
77

88
py_test(

python/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
This is the Python Open Location Code library. It is tested for both python 2.7
44
and python 3.6.
55

6+
## Installing the library
7+
8+
The python library is available on PyPi. You can install it using pip:
9+
10+
```
11+
pip install openlocationcode
12+
```
13+
614
## Formatting
715

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

59+
60+
## Releasing to PyPi
61+
62+
We release the python library to PyPi so users can install it using pip.
63+
64+
Pre-reqs:
65+
66+
```
67+
pip install setuptools
68+
pip install twine
69+
```
70+
71+
To release a new version to PyPi, make sure you update the version number in setup.py. Then run:
72+
73+
```
74+
python setup.py sdist
75+
twine upload dist/*
76+
```
77+
78+
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.

python/openlocationcode/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from openlocationcode import *

python/openlocationcode_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import random
66
import time
77
import unittest
8-
import openlocationcode as olc
8+
from openlocationcode import openlocationcode as olc
99

1010
# Location of test data files.
1111
_TEST_DATA = 'test_data'

python/setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from setuptools import setup
2+
3+
# This call to setup() does all the work
4+
setup(
5+
name="openlocationcode",
6+
version="1.0.1",
7+
description="Python library for Open Location Code (Plus Codes)",
8+
url="https://github.com/google/open-location-code",
9+
author="Google",
10+
author_email="[email protected]",
11+
license="Apache 2.0",
12+
classifiers=[
13+
"Programming Language :: Python :: 2.7",
14+
"Programming Language :: Python :: 3.6",
15+
],
16+
packages=["openlocationcode"],
17+
include_package_data=True,
18+
install_requires=[],
19+
)

0 commit comments

Comments
 (0)