Black: Installing black[d] from github misses aiohttp-cors dependency

Created on 31 Jan 2019  路  5Comments  路  Source: psf/black

My Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
black = {git = "https://github.com/ambv/black.git",editable = true, extras = ["d"]}
aiohttp-cors = "*"

[requires]
python_version = "3.7"

If I leave out "aiohttp-cors", the install process fails, complaining about the needed aiohttp-cors dependency.

Python 3.7.1, using pipenv install.

bug

Most helpful comment

@JohnVillalovos
I think you have to install _Blackd_ like this pip install black[d] --user to install the extra dependencies that _Blackd_ requires.

R:\>pip install black[d] --user
Requirement already satisfied: black[d] in c:\users\user\appdata\roaming\python\python38\site-packages (19.10b0)
Requirement already satisfied: toml>=0.9.4 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (0.10.0)
Requirement already satisfied: click>=6.5 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (7.1.2)
Requirement already satisfied: attrs>=18.1.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (19.3.0)
Requirement already satisfied: pathspec<1,>=0.6 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (0.8.0)
Requirement already satisfied: regex in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (2020.5.13)
Requirement already satisfied: typed-ast>=1.4.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (1.4.1)
Requirement already satisfied: appdirs in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (1.4.4)
Collecting aiohttp-cors; extra == "d"
  Downloading aiohttp_cors-0.7.0-py3-none-any.whl (27 kB)
Collecting aiohttp>=3.3.2; extra == "d"
  Downloading aiohttp-3.6.2-py3-none-any.whl (441 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 441 kB 121 kB/s
Collecting yarl<2.0,>=1.0
  Downloading yarl-1.4.2-cp38-cp38-win_amd64.whl (126 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 126 kB 50 kB/s
Collecting multidict<5.0,>=4.5
  Downloading multidict-4.7.5-cp38-cp38-win_amd64.whl (48 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 48 kB 453 kB/s
Collecting async-timeout<4.0,>=3.0
  Downloading async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Requirement already satisfied: chardet<4.0,>=2.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from aiohttp>=3.3.2; extra == "d"->black[d]) (3.0.4)
Requirement already satisfied: idna>=2.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from yarl<2.0,>=1.0->aiohttp>=3.3.2; extra == "d"->black[d]) (2.8)
Installing collected packages: multidict, yarl, async-timeout, aiohttp, aiohttp-cors
Successfully installed aiohttp-3.6.2 aiohttp-cors-0.7.0 async-timeout-3.0.1 multidict-4.7.5 yarl-1.4.2

The extra dependencies are defined here in setup.py (link):

    extras_require={
        "d": ["aiohttp>=3.3.2", "aiohttp-cors"],
        "colorama": ["colorama>=0.4.3"],
    },

You will have to tell pip install those extra dependencies with whatever_package[whatever_is_the extra_string_key_in_extra_require]. In this case, it would be black[d].

Environment:

  • Python version: Python 3.8.1
  • Pip version: pip 20.0.2
  • OS: Windows 10 Home Edition Build 18363

All 5 comments

Looks like 0b40a7badf82c53c8a23b3a03273619f8440855d added aiohttp-cors to Pipfile instead of setup.py -- should be an easy fix if you'd like to take it through:

diff --git a/Pipfile b/Pipfile
index ffb31aa..8e9ad1e 100644
--- a/Pipfile
+++ b/Pipfile
@@ -10,7 +10,6 @@ click = ">=6.5"
 appdirs = "*"
 toml = ">=0.9.4"
 black = {editable = true, path = ".", extras = ["d"]}
-aiohttp-cors = "*"

 [dev-packages]
 pre-commit = "*"
diff --git a/setup.py b/setup.py
index 096be9e..620124f 100644
--- a/setup.py
+++ b/setup.py
@@ -42,7 +42,7 @@ setup(
     python_requires=">=3.6",
     zip_safe=False,
     install_requires=["click>=6.5", "attrs>=18.1.0", "appdirs", "toml>=0.9.4"],
-    extras_require={"d": ["aiohttp>=3.3.2"]},
+    extras_require={"d": ["aiohttp>=3.3.2", "aiohttp-cors"]},
     test_suite="tests.test_black",
     classifiers=[
         "Development Status :: 4 - Beta",

(something like this?) I'm not familiar with Pipfile myself so you'd probably need to gen the lockfile or whatever

I just attempted to run blackd after install. And I get an error:

$ pip install --user --force-reinstall black
Collecting black
  Using cached https://files.pythonhosted.org/packages/fd/bb/ad34bbc93d1bea3de086d7c59e528d4a503ac8fe318bd1fa48605584c3d2/black-19.10b0-py36-none-any.whl
Collecting typed-ast>=1.4.0
  Using cached https://files.pythonhosted.org/packages/77/49/51308e8c529e14bb2399ff6d22998583aa9ae189ec191e6f7cbb4679f7d5/typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl
Collecting appdirs
  Using cached https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl
Collecting attrs>=18.1.0
  Using cached https://files.pythonhosted.org/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl
Collecting toml>=0.9.4
  Using cached https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl
Collecting pathspec<1,>=0.6
  Using cached https://files.pythonhosted.org/packages/5d/d0/887c58853bd4b6ffc7aa9cdba4fc57d7b979b45888a6bd47e4568e1cf868/pathspec-0.8.0-py2.py3-none-any.whl
Collecting regex
  Downloading https://files.pythonhosted.org/packages/75/b7/01765b30274b6a79e3d5c0147432295ec815bb7f2023f7951afaedf1bd6a/regex-2020.5.13-cp38-cp38-manylinux2010_x86_64.whl (689kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 696kB 2.6MB/s
Collecting click>=6.5
  Using cached https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl
Installing collected packages: typed-ast, appdirs, attrs, toml, pathspec, regex, click, black
Successfully installed appdirs-1.4.4 attrs-19.3.0 black-19.10b0 click-7.1.2 pathspec-0.8.0 regex-2020.5.13 toml-0.10.0 typed-ast-1.4.1
$ blackd
Traceback (most recent call last):
  File "/home/testing/.local/bin/blackd", line 5, in <module>
    from blackd import patched_main
  File "/home/testing/.local/lib/python3.8/site-packages/blackd.py", line 10, in <module>
    import aiohttp_cors
ModuleNotFoundError: No module named 'aiohttp_cors'

@JohnVillalovos
I think you have to install _Blackd_ like this pip install black[d] --user to install the extra dependencies that _Blackd_ requires.

R:\>pip install black[d] --user
Requirement already satisfied: black[d] in c:\users\user\appdata\roaming\python\python38\site-packages (19.10b0)
Requirement already satisfied: toml>=0.9.4 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (0.10.0)
Requirement already satisfied: click>=6.5 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (7.1.2)
Requirement already satisfied: attrs>=18.1.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (19.3.0)
Requirement already satisfied: pathspec<1,>=0.6 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (0.8.0)
Requirement already satisfied: regex in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (2020.5.13)
Requirement already satisfied: typed-ast>=1.4.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (1.4.1)
Requirement already satisfied: appdirs in c:\users\user\appdata\roaming\python\python38\site-packages (from black[d]) (1.4.4)
Collecting aiohttp-cors; extra == "d"
  Downloading aiohttp_cors-0.7.0-py3-none-any.whl (27 kB)
Collecting aiohttp>=3.3.2; extra == "d"
  Downloading aiohttp-3.6.2-py3-none-any.whl (441 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 441 kB 121 kB/s
Collecting yarl<2.0,>=1.0
  Downloading yarl-1.4.2-cp38-cp38-win_amd64.whl (126 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 126 kB 50 kB/s
Collecting multidict<5.0,>=4.5
  Downloading multidict-4.7.5-cp38-cp38-win_amd64.whl (48 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 48 kB 453 kB/s
Collecting async-timeout<4.0,>=3.0
  Downloading async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Requirement already satisfied: chardet<4.0,>=2.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from aiohttp>=3.3.2; extra == "d"->black[d]) (3.0.4)
Requirement already satisfied: idna>=2.0 in c:\users\user\appdata\roaming\python\python38\site-packages (from yarl<2.0,>=1.0->aiohttp>=3.3.2; extra == "d"->black[d]) (2.8)
Installing collected packages: multidict, yarl, async-timeout, aiohttp, aiohttp-cors
Successfully installed aiohttp-3.6.2 aiohttp-cors-0.7.0 async-timeout-3.0.1 multidict-4.7.5 yarl-1.4.2

The extra dependencies are defined here in setup.py (link):

    extras_require={
        "d": ["aiohttp>=3.3.2", "aiohttp-cors"],
        "colorama": ["colorama>=0.4.3"],
    },

You will have to tell pip install those extra dependencies with whatever_package[whatever_is_the extra_string_key_in_extra_require]. In this case, it would be black[d].

Environment:

  • Python version: Python 3.8.1
  • Pip version: pip 20.0.2
  • OS: Windows 10 Home Edition Build 18363

@ichard26

Thanks. I guess I assumed since it put a 'blackd' executable in my path that it would install what is needed for it to run ... 馃槈

Agree with @JohnVillalovos here. It's confusing that the documentation says that "black[d]" is a separate package

blackd is not packaged alongside Black by default because it has additional dependencies. You will need to execute pip install black[d] to install it.

but at the same time, blackd executable is available directly after black installation, though with broken dependencies.

Was this page helpful?
0 / 5 - 0 ratings