Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blackd Packaging #1688

Closed
mlucool opened this issue Sep 8, 2020 · 5 comments · Fixed by #1761
Closed

Blackd Packaging #1688

mlucool opened this issue Sep 8, 2020 · 5 comments · Fixed by #1761
Assignees
Labels
C: packaging Installation and packaging of Black T: bug Something isn't working

Comments

@mlucool
Copy link

mlucool commented Sep 8, 2020

Describe the bug

The blackd documenation states:

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 blackd is included in packages for black.

To Reproduce Steps to reproduce the behavior:

$ python3 -m venv venv; source venv/bin/activate
$ pip install black
$ which blackd
/path/to/venv/bin/blackd

Expected behavior

No binary named blackd is installed because its webserver dependencies are not installed.

Environment (please complete the following information):

  • Version: master
  • OS and Python version: Linux

Does this bug also happen on master?
Yes, see above

@mlucool mlucool added the T: bug Something isn't working label Sep 8, 2020
@cooperlees cooperlees self-assigned this Sep 30, 2020
@cooperlees
Copy link
Collaborator

cooperlees commented Sep 30, 2020

Does anyone have suggestions here? I’m trying to read docs on how to do this and not finding many answers. I’ll keep digging. We do have ‘[d]’ in the console_scripts entry ...

@zsol
Copy link
Collaborator

zsol commented Sep 30, 2020

I'm fairly sure this used to work as described in the docs. Has something changed in or around pip?

@zsol
Copy link
Collaborator

zsol commented Sep 30, 2020

From the python packaging guide:

Using extras for an entry point is no longer recommended. Consumers should support parsing them from existing distributions, but may then ignore them. New publishing tools need not support specifying extras. The functionality of handling extras was tied to setuptools’ model of managing ‘egg’ packages, but newer tools such as pip and virtualenv use a different model.

It's unclear to me what this different model is, but we should probably use that.

@cooperlees
Copy link
Collaborator

I did see this too, but I can't work out what it is. I'll call in favors from friends to try work this out.

@hugovk
Copy link
Contributor

hugovk commented Sep 30, 2020

That was added to the guide in pypa/packaging.python.org#390.

I've not read through it, but it also adds an "entry points specification", perhaps there's something useful in there? Could also ask someone from that PR?

@ichard26 ichard26 added the C: packaging Installation and packaging of Black label Oct 5, 2020
cooperlees added a commit that referenced this issue Oct 13, 2020
- If no aiohttp* deps exist nicely print a helpful message and exit
- There seems to be no nice way to optionally install the entry point, so lets make the entry point nicer

Test:
```
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install  to obtain aiohttp_cors: `pip install black[d]`
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .[d]
...
Successfully installed aiohttp-3.6.3 aiohttp-cors-0.7.0 black
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
blackd version 20.8b2.dev31+gdd2f86a.d20201013 listening on localhost port 45484
```

Fixes #1688
JelleZijlstra pushed a commit that referenced this issue Oct 13, 2020
- If no aiohttp* deps exist nicely print a helpful message and exit
- There seems to be no nice way to optionally install the entry point, so lets make the entry point nicer

Test:
```
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install  to obtain aiohttp_cors: `pip install black[d]`
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .[d]
...
Successfully installed aiohttp-3.6.3 aiohttp-cors-0.7.0 black
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
blackd version 20.8b2.dev31+gdd2f86a.d20201013 listening on localhost port 45484
```

Fixes #1688
noxan pushed a commit to noxan/black that referenced this issue Jun 6, 2021
- If no aiohttp* deps exist nicely print a helpful message and exit
- There seems to be no nice way to optionally install the entry point, so lets make the entry point nicer

Test:
```
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install  to obtain aiohttp_cors: `pip install black[d]`
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .[d]
...
Successfully installed aiohttp-3.6.3 aiohttp-cors-0.7.0 black
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
blackd version 20.8b2.dev31+gdd2f86a.d20201013 listening on localhost port 45484
```

Fixes psf#1688
ichard26 added a commit that referenced this issue Aug 24, 2021
The fix for #1688 in #1761 breaks help("modules") introspection and also leads
to unhappy results when inadvertently importing blackd from Python. Basically
the sys.exit(-1) causes the whole Python REPL to exit -- not great to suffice.

Commit history before merge:

* Change sys.exit to Raise.
* Add #2440 to changelog.
* Fix lint error from prettier
* Remove exception chain for more helpful user message.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: packaging Installation and packaging of Black T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants