|
1 | 1 | """Pyscopg and asyncpg helpers to work with PostGIS.""" |
2 | 2 |
|
3 | | -import glob |
4 | | -from setuptools import setup, find_packages, Extension |
5 | | -from codecs import open # To use a consistent encoding |
6 | | -from os import path |
7 | 3 | import sys |
| 4 | +from pathlib import Path |
8 | 5 |
|
9 | | -HERE = path.abspath(path.dirname(__file__)) |
10 | | - |
11 | | -# Get the long description from the relevant file |
12 | | -with open(path.join(HERE, 'README.md'), encoding='utf-8') as f: |
13 | | - long_description = f.read() |
14 | | - |
15 | | - |
16 | | -def is_pkg(line): |
17 | | - return line and not line.startswith(('--', 'git', '#')) |
| 6 | +from setuptools import Extension, find_packages, setup |
18 | 7 |
|
19 | 8 |
|
20 | 9 | def list_modules(dirname): |
21 | | - filenames = glob.glob(path.join(dirname, '*.py')) |
22 | | - |
23 | | - module_names = [] |
24 | | - for name in filenames: |
25 | | - module, ext = path.splitext(path.basename(name)) |
26 | | - if module != '__init__': |
27 | | - module_names.append(module) |
28 | | - |
29 | | - return module_names |
| 10 | + paths = Path(dirname).glob("*.py") |
| 11 | + return [p.stem for p in paths if p.stem != "__init__"] |
30 | 12 |
|
31 | 13 |
|
32 | 14 | try: |
33 | 15 | from Cython.Distutils import build_ext |
| 16 | + |
34 | 17 | CYTHON = True |
35 | 18 | except ImportError: |
36 | | - sys.stdout.write('\nNOTE: Cython not installed. python-postgis will ' |
37 | | - 'still work fine, but may run a bit slower.\n\n') |
| 19 | + sys.stdout.write( |
| 20 | + "\nNOTE: Cython not installed. python-postgis will " |
| 21 | + "still work fine, but may run a bit slower.\n\n" |
| 22 | + ) |
38 | 23 | CYTHON = False |
39 | 24 | cmdclass = {} |
40 | 25 | ext_modules = [] |
41 | 26 | else: |
42 | 27 | ext_modules = [ |
43 | | - Extension('postgis.' + ext, [path.join('postgis', ext + '.py')]) |
44 | | - for ext in list_modules(path.join(HERE, 'postgis'))] |
| 28 | + Extension("postgis." + ext, [str(Path("postgis") / f"{ext}.py")]) |
| 29 | + for ext in list_modules(Path("postgis")) |
| 30 | + ] |
45 | 31 |
|
46 | | - cmdclass = {'build_ext': build_ext} |
| 32 | + cmdclass = {"build_ext": build_ext} |
47 | 33 |
|
48 | 34 |
|
49 | 35 | VERSION = (1, 0, 4) |
50 | 36 |
|
51 | 37 | setup( |
52 | | - name='postgis', |
| 38 | + name="postgis", |
53 | 39 | version=".".join(map(str, VERSION)), |
54 | 40 | description=__doc__, |
55 | | - long_description=long_description, |
56 | | - url="https://github.com/yohanboniface/python-postgis", |
57 | | - author='Yohan Boniface', |
58 | | - author_email='yohan.boniface@data.gouv.fr', |
59 | | - license='WTFPL', |
60 | | - |
| 41 | + long_description=Path("README.md").read_text(), |
| 42 | + url="https://github.com/tilery/python-postgis", |
| 43 | + author="Yohan Boniface", |
| 44 | + author_email="yohanboniface@free.fr", |
| 45 | + license="WTFPL", |
61 | 46 | # See https://pypi.python.org/pypi?%3Aaction=list_classifiers |
62 | 47 | classifiers=[ |
63 | | - 'Development Status :: 4 - Beta', |
64 | | - |
65 | | - 'Intended Audience :: Developers', |
66 | | - 'Topic :: Scientific/Engineering :: GIS', |
67 | | - |
68 | | - 'Programming Language :: Python :: 3', |
69 | | - 'Programming Language :: Python :: 3.5', |
70 | | - 'Programming Language :: Python :: 3.6', |
| 48 | + "Development Status :: 4 - Beta", |
| 49 | + "Intended Audience :: Developers", |
| 50 | + "Topic :: Scientific/Engineering :: GIS", |
| 51 | + "Programming Language :: Python :: 3", |
| 52 | + "Programming Language :: Python :: 3.5", |
| 53 | + "Programming Language :: Python :: 3.6", |
| 54 | + "Programming Language :: Python :: 3.7", |
| 55 | + "Programming Language :: Python :: 3.8", |
71 | 56 | ], |
72 | | - keywords='psycopg postgis gis asyncpg', |
73 | | - packages=find_packages(exclude=['tests']), |
74 | | - extras_require={'test': ['pytest'], 'docs': 'mkdocs'}, |
| 57 | + keywords="psycopg postgis gis asyncpg", |
| 58 | + packages=find_packages(exclude=["tests"]), |
| 59 | + extras_require={ |
| 60 | + "test": ["pytest", "pytest-asyncio", "psycopg2", "asyncpg"], |
| 61 | + "docs": "mkdocs", |
| 62 | + }, |
75 | 63 | include_package_data=True, |
76 | 64 | cmdclass=cmdclass, |
77 | 65 | ext_modules=ext_modules, |
|
0 commit comments