1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
import distutils.cmd
import os
import subprocess
from setuptools import find_packages, setup
exec(open("psqlextra/_version.py").read())
class BaseCommand(distutils.cmd.Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def create_command(text, commands):
"""Creates a custom setup.py command."""
class CustomCommand(BaseCommand):
description = text
def run(self):
for cmd in commands:
subprocess.check_call(cmd)
return CustomCommand
with open(
os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8"
) as readme:
README = readme.read().split("h1>\n", 2)[1]
setup(
name="django-postgres-extra",
version=__version__,
packages=find_packages(exclude=["tests"]),
package_data={"psqlextra": ["py.typed"]},
include_package_data=True,
license="MIT License",
description="Bringing all of PostgreSQL's awesomeness to Django.",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/SectorLabs/django-postgres-extra",
author="Sector Labs",
author_email="open-source@sectorlabs.ro",
keywords=["django", "postgres", "extra", "hstore", "ltree"],
classifiers=[
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
],
python_requires=">=3.6",
install_requires=[
"Django>=2.0,<6.0",
"python-dateutil>=2.8.0,<=3.0.0",
],
extras_require={
':python_version <= "3.6"': ["dataclasses"],
"docs": ["Sphinx==2.2.0", "sphinx-rtd-theme==0.4.3", "docutils<0.18"],
"test": [
"psycopg2>=2.8.4,<3.0.0",
"dj-database-url==0.5.0",
"pytest==6.2.5",
"pytest-benchmark==3.4.1",
"pytest-django==4.4.0",
"pytest-cov==3.0.0",
"pytest-lazy-fixture==0.6.3",
"pytest-freezegun==0.4.2",
"tox==3.24.4",
"freezegun==1.1.0",
"coveralls==3.3.0",
"snapshottest==0.6.0",
],
"analysis": [
"black==22.3.0",
"flake8==4.0.1",
"autoflake==1.4",
"autopep8==1.6.0",
"isort==5.10.0",
"docformatter==1.4",
"mypy==1.2.0; python_version > '3.6'",
"mypy==0.971; python_version <= '3.6'",
"django-stubs==1.16.0; python_version > '3.6'",
"django-stubs==1.9.0; python_version <= '3.6'",
"typing-extensions==4.5.0; python_version > '3.6'",
"typing-extensions==4.1.0; python_version <= '3.6'",
"types-dj-database-url==1.3.0.0",
"types-psycopg2==2.9.21.9",
"types-python-dateutil==2.8.19.12",
],
"publish": [
"build==0.7.0",
"twine==3.7.1",
],
},
cmdclass={
"lint": create_command(
"Lints the code",
[
[
"flake8",
"--builtin=__version__",
"setup.py",
"psqlextra",
"tests",
]
],
),
"lint_fix": create_command(
"Lints the code",
[
[
"autoflake",
"--remove-all",
"-i",
"-r",
"setup.py",
"psqlextra",
"tests",
],
["autopep8", "-i", "-r", "setup.py", "psqlextra", "tests"],
],
),
"lint_types": create_command(
"Type-checks the code",
[
[
"mypy",
"--package",
"psqlextra",
"--pretty",
"--show-error-codes",
],
],
),
"format": create_command(
"Formats the code", [["black", "setup.py", "psqlextra", "tests"]]
),
"format_verify": create_command(
"Checks if the code is auto-formatted",
[["black", "--check", "setup.py", "psqlextra", "tests"]],
),
"format_docstrings": create_command(
"Auto-formats doc strings", [["docformatter", "-r", "-i", "."]]
),
"format_docstrings_verify": create_command(
"Verifies that doc strings are properly formatted",
[["docformatter", "-r", "-c", "."]],
),
"sort_imports": create_command(
"Automatically sorts imports",
[
["isort", "setup.py"],
["isort", "psqlextra"],
["isort", "tests"],
],
),
"sort_imports_verify": create_command(
"Verifies all imports are properly sorted.",
[
["isort", "-c", "setup.py"],
["isort", "-c", "psqlextra"],
["isort", "-c", "tests"],
],
),
"fix": create_command(
"Automatically format code and fix linting errors",
[
["python", "setup.py", "format"],
["python", "setup.py", "format_docstrings"],
["python", "setup.py", "sort_imports"],
["python", "setup.py", "lint_fix"],
["python", "setup.py", "lint"],
["python", "setup.py", "lint_types"],
],
),
"verify": create_command(
"Verifies whether the code is auto-formatted and has no linting errors",
[
["python", "setup.py", "format_verify"],
["python", "setup.py", "format_docstrings_verify"],
["python", "setup.py", "sort_imports_verify"],
["python", "setup.py", "lint"],
["python", "setup.py", "lint_types"],
],
),
"test": create_command(
"Runs all the tests",
[
[
"pytest",
"--cov=psqlextra",
"--cov-report=term",
"--cov-report=xml:reports/xml",
"--cov-report=html:reports/html",
"--junitxml=reports/junit/tests.xml",
"--reuse-db",
]
],
),
},
)
|