Skip to content

Commit

Permalink
Update setup script for publishing to PyPi.
Browse files Browse the repository at this point in the history
Update docs.
  • Loading branch information
muety committed Nov 7, 2019
1 parent 54efaa2 commit 6df831a
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ nosetests.xml
# Virtualenv
venv/

.idea
.idea/

site/
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ This library requires **Python 3.6** or higher. To compile it by yourself, Cytho
### Using Pip
* `pip3 install pyquadkey2`

Currently, there are pre-built `linux_x86_64` for Python 3.6, 3.7 and 3.8. If you're on a Linux system, you can simply use pip without any additional requirements.
On other systems, you might need to install Cython first (`pip3 install cython`). If you encounter problems while installing, please report them as a new issue.

### From Source
* `git clone https://github.com/n1try/pyquadkey2`
* `pip3 install cython`
* `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../`
* `pip3 install .`
If you encounter problems while installing, please report them as a new issue.

### From archive
* Download the latest [release](https://github.com/n1try/pyquadkey2/releases) as archive (`.tar.gz`) or wheel (`.whl`), e.g. `0.1.1.tar.gz`
* Install it with pip: `pip3 install 0.1.1.tar.gz`

### From source
* Clone repository: `git clone https://github.com/n1try/pyquadkey2`
* Make sure Cython is installed: `pip3 install cython`
* Compile Cython modules: `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../`
* Install the library with Pip: `pip3 install .`

### Troubleshooting
* `ImportError: cannot import name 'tilesystem'`: Simply try `pip3 install --upgrade pyquadkey2` once again. Second time usually works, as required build extensions are installed then. This is a known issue and will be fixed in the future.
Expand Down
21 changes: 13 additions & 8 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Installation

## Requirements
This library requires **Python 3.6** or higher. To compile it by yourself, Cython is required in addition.

## Using Pip
* `pip3 install pyquadkey2`

Currently, there are pre-built `linux_x86_64` for Python 3.6, 3.7 and 3.8. If you're on a Linux system, you can simply use pip without any additional requirements.
On other systems, you might need to install Cython first (`pip3 install cython`). If you encounter problems while installing, please report them as a new issue.
If you encounter problems while installing, please report them as a new issue.

## From archive
* Download the latest [release](https://github.com/n1try/pyquadkey2/releases) as archive (`.tar.gz`) or wheel (`.whl`), e.g. `0.1.1.tar.gz`
* Install it with pip: `pip3 install 0.1.1.tar.gz`

## From Source
* `git clone https://github.com/n1try/pyquadkey2`
* `pip3 install cython`
* `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../`
* `pip3 install .`
## From source
* Clone repository: `git clone https://github.com/n1try/pyquadkey2`
* Make sure Cython is installed: `pip3 install cython`
* Compile Cython modules: `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../`
* Install the library with Pip: `pip3 install .`

## Troubleshooting
* `ImportError: cannot import name 'tilesystem'`: Simply try `pip3 install --upgrade pyquadkey2` once again. Second time usually works, as required build extensions are installed then. This is a known issue and will be fixed in the future.
* `ImportError: cannot import name 'tilesystem'`: Simply try `pip3 install --upgrade pyquadkey2` once again. Second time usually works, as required build extensions are installed then. This is a known issue and will be fixed in the future.
21 changes: 19 additions & 2 deletions docs/instantiation.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
# Instantiation

There are **three ways** of instantiating a QuadKey.

## From string representation
Creates a new `QuadKey` object from a tile's string representation.

`from_str(qk_str: str) -> 'QuadKey'`

**Example:**
```
```python
import quadkey
qk = quadkey.from_str('010302121') # -> 010302121
```

## From integer representation
Creates a new `QuadKey` object from a tile's integer representation

`from_int(qk_int: int) -> 'QuadKey'`

**Example:**
```
```python
import quadkey
qk = quadkey.from_int(1379860704579813385) # -> 010302121
```

## From coordinates
Creates a new `QuadKey` object from geo / GNSS coordinates

`from_geo(geo: Tuple[float, float], level: int) -> 'QuadKey'`

**Example:**
```python
import quadkey
qk = quadkey.from_geo((49.011011, 8.414971), 9) # -> 120203233
```
2 changes: 2 additions & 0 deletions docs/methods.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Methods

## children
`children(self, at_level: int = -1) -> List['QuadKey']`

Expand Down
6 changes: 5 additions & 1 deletion quadkey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from enum import IntEnum
from typing import Tuple, List, Iterable, Generator, Dict

from .tilesystem import tilesystem
try:
from pyquadkey2 import tilesystem
except ModuleNotFoundError:
from .tilesystem import tilesystem

from .util import precondition

LAT_STR: str = 'lat'
Expand Down
40 changes: 21 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
#!/usr/bin/env python
# https://packaging.python.org/tutorials/packaging-projects/
import os
# python3 setup.py sdist bdist_wheel
# python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*.tar.gz
# mkdocs build

from setuptools import Extension
from setuptools import setup, find_packages
from setuptools.glob import glob

try:
from Cython.Distutils.extension import Extension
from Cython.Build import build_ext
except ImportError:
from setuptools import Extension

USING_CYTHON = False
else:
USING_CYTHON = True

ext = 'pyx' if USING_CYTHON else 'c'
sources = glob('quadkey/tilesystem/*.%s' % (ext,))
extensions = [Extension(source.split('.')[0].replace(os.path.sep, '.'), sources=[source]) for source in sources]
cmdclass = {'build_ext': build_ext} if USING_CYTHON else {}
with open('README.md', 'r') as fh:
long_description = fh.read()

setup(
name='pyquadkey2',
version='0.1.0',
version='0.1.1',
description='Python implementation of geographical tiling using QuadKeys as proposed by Microsoft',
long_description=long_description,
long_description_content_type='text/markdown',
author='Ferdinand Mütsch',
author_email='[email protected]',
url='https://github.com/n1try/pyquadkey2',
packages=find_packages(),
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python :: 3',
'Programming Language :: Cython',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Natural Language :: English',
'Topic :: Scientific/Engineering :: GIS',
'Typing :: Typed'
],
project_urls={
'Bug Tracker': 'https://github.com/n1try/pyquadkey2/issues',
'Source Code': 'https://github.com/n1try/pyquadkey2',
},
keywords='tiling quadkey quadtile geospatial geohash',
python_requires='>=3.6',
ext_modules=extensions,
cmdclass=cmdclass
ext_modules=[Extension('tilesystem', ['quadkey/tilesystem/tilesystem.c'])],
ext_package='pyquadkey2'
)

0 comments on commit 6df831a

Please sign in to comment.