]> git.madduck.net Git - etc/vim.git/blob - setup.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Load .gitignore and exclude regex at time of use
[etc/vim.git] / setup.py
1 # Copyright (C) 2020 Łukasz Langa
2 import os
3 import sys
4
5 from setuptools import find_packages, setup
6
7 assert sys.version_info >= (3, 6, 2), "black requires Python 3.6.2+"
8 from pathlib import Path  # noqa E402
9 from typing import List  # noqa: E402
10
11 CURRENT_DIR = Path(__file__).parent
12 sys.path.insert(0, str(CURRENT_DIR))  # for setuptools.build_meta
13
14
15 def get_long_description() -> str:
16     return (
17         (CURRENT_DIR / "README.md").read_text(encoding="utf8")
18         + "\n\n"
19         + (CURRENT_DIR / "CHANGES.md").read_text(encoding="utf8")
20     )
21
22
23 def find_python_files(base: Path) -> List[Path]:
24     files = []
25     for entry in base.iterdir():
26         if entry.is_file() and entry.suffix == ".py":
27             files.append(entry)
28         elif entry.is_dir():
29             files.extend(find_python_files(entry))
30
31     return files
32
33
34 USE_MYPYC = False
35 # To compile with mypyc, a mypyc checkout must be present on the PYTHONPATH
36 if len(sys.argv) > 1 and sys.argv[1] == "--use-mypyc":
37     sys.argv.pop(1)
38     USE_MYPYC = True
39 if os.getenv("BLACK_USE_MYPYC", None) == "1":
40     USE_MYPYC = True
41
42 if USE_MYPYC:
43     from mypyc.build import mypycify
44
45     src = CURRENT_DIR / "src"
46     # TIP: filepaths are normalized to use forward slashes and are relative to ./src/
47     # before being checked against.
48     blocklist = [
49         # Not performance sensitive, so save bytes + compilation time:
50         "blib2to3/__init__.py",
51         "blib2to3/pgen2/__init__.py",
52         "black/output.py",
53         "black/concurrency.py",
54         "black/files.py",
55         "black/report.py",
56         # Breaks the test suite when compiled (and is also useless):
57         "black/debug.py",
58         # Compiled modules can't be run directly and that's a problem here:
59         "black/__main__.py",
60     ]
61     discovered = []
62     # There's no good reason for blackd to be compiled.
63     discovered.extend(find_python_files(src / "black"))
64     discovered.extend(find_python_files(src / "blib2to3"))
65     mypyc_targets = [
66         str(p) for p in discovered if p.relative_to(src).as_posix() not in blocklist
67     ]
68
69     opt_level = os.getenv("MYPYC_OPT_LEVEL", "3")
70     debug_level = os.getenv("MYPYC_DEBUG_LEVEL", "3")
71     ext_modules = mypycify(
72         mypyc_targets, opt_level=opt_level, debug_level=debug_level, verbose=True
73     )
74 else:
75     ext_modules = []
76
77 setup(
78     name="black",
79     use_scm_version={
80         "write_to": "src/_black_version.py",
81         "write_to_template": 'version = "{version}"\n',
82     },
83     description="The uncompromising code formatter.",
84     long_description=get_long_description(),
85     long_description_content_type="text/markdown",
86     keywords="automation formatter yapf autopep8 pyfmt gofmt rustfmt",
87     author="Łukasz Langa",
88     author_email="lukasz@langa.pl",
89     url="https://github.com/psf/black",
90     project_urls={"Changelog": "https://github.com/psf/black/blob/main/CHANGES.md"},
91     license="MIT",
92     py_modules=["_black_version"],
93     ext_modules=ext_modules,
94     packages=find_packages(where="src"),
95     package_dir={"": "src"},
96     package_data={
97         "blib2to3": ["*.txt"],
98         "black": ["py.typed"],
99     },
100     python_requires=">=3.6.2",
101     zip_safe=False,
102     install_requires=[
103         "click>=8.0.0",
104         "platformdirs>=2",
105         "tomli>=1.1.0; python_full_version < '3.11.0a7'",
106         "typed-ast>=1.4.2; python_version < '3.8' and implementation_name == 'cpython'",
107         "pathspec>=0.9.0",
108         "dataclasses>=0.6; python_version < '3.7'",
109         "typing_extensions>=3.10.0.0; python_version < '3.10'",
110         "mypy_extensions>=0.4.3",
111     ],
112     extras_require={
113         "d": ["aiohttp>=3.7.4"],
114         "colorama": ["colorama>=0.4.3"],
115         "uvloop": ["uvloop>=0.15.2"],
116         "jupyter": ["ipython>=7.8.0", "tokenize-rt>=3.2.0"],
117     },
118     classifiers=[
119         "Development Status :: 5 - Production/Stable",
120         "Environment :: Console",
121         "Intended Audience :: Developers",
122         "License :: OSI Approved :: MIT License",
123         "Operating System :: OS Independent",
124         "Programming Language :: Python",
125         "Programming Language :: Python :: 3.6",
126         "Programming Language :: Python :: 3.7",
127         "Programming Language :: Python :: 3.8",
128         "Programming Language :: Python :: 3.9",
129         "Programming Language :: Python :: 3.10",
130         "Programming Language :: Python :: 3.11",
131         "Programming Language :: Python :: 3 :: Only",
132         "Topic :: Software Development :: Libraries :: Python Modules",
133         "Topic :: Software Development :: Quality Assurance",
134     ],
135     entry_points={
136         "console_scripts": [
137             "black=black:patched_main",
138             "blackd=blackd:patched_main [d]",
139         ]
140     },
141 )