diff --git a/python/.gitignore b/python/.gitignore index 7a60b85e..23863055 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -1,2 +1,4 @@ __pycache__/ *.pyc +openlocationcode.egg-info/* +dist/* \ No newline at end of file diff --git a/python/BUILD b/python/BUILD index 885e7665..8b42e169 100644 --- a/python/BUILD +++ b/python/BUILD @@ -2,7 +2,7 @@ package(default_visibility = ["//visibility:public"]) py_library( name = "openlocationcode", - srcs = ["openlocationcode.py"], + srcs = ["openlocationcode/openlocationcode.py"], ) py_test( diff --git a/python/README.md b/python/README.md index 74f94c3b..e0888f0b 100644 --- a/python/README.md +++ b/python/README.md @@ -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 @@ -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. diff --git a/python/openlocationcode/__init__.py b/python/openlocationcode/__init__.py new file mode 100644 index 00000000..725b62df --- /dev/null +++ b/python/openlocationcode/__init__.py @@ -0,0 +1 @@ +from openlocationcode import * \ No newline at end of file diff --git a/python/openlocationcode.py b/python/openlocationcode/openlocationcode.py similarity index 100% rename from python/openlocationcode.py rename to python/openlocationcode/openlocationcode.py diff --git a/python/openlocationcode_test.py b/python/openlocationcode_test.py index 435b7541..8b9c0d1f 100644 --- a/python/openlocationcode_test.py +++ b/python/openlocationcode_test.py @@ -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' diff --git a/python/setup.py b/python/setup.py new file mode 100644 index 00000000..1149c988 --- /dev/null +++ b/python/setup.py @@ -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="open-location-code@googlegroups.com", + license="Apache 2.0", + classifiers=[ + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.6", + ], + packages=["openlocationcode"], + include_package_data=True, + install_requires=[], +) \ No newline at end of file