]> 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:

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