-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Offer option other than pyproject.toml for config #683
Comments
Sorry for the issues you saw! #688 suggests also supporting |
There's been a lot of follow up discussion pypa/setuptools#1642 and pypa/pip#6163. I followed in the beginning but can't really give a summary anymore, sorry. It might be worth reading up on where they are going with all this, or maybe it's not and just having another config-file option is appropriate. I personally don't use black (yet?) so I was mostly just trying to point out the scenario for consideration. |
I believe the latest plan is to roll back |
As I wrote in #688 (comment),
|
I'd really like to avoid supporting multiple configuration styles. I think if we go with |
I can give it a try if nobody has started working on it. However, I'd try to keep both Is that what everybody wants? |
In general, is embedding into something else's config a good thing? Why? Why not a separate file just for black? Yes, coverage can use setup.cfg, it can also use its own file. |
I guess having a A while ago the Pythonic world converge in putting everything related to a python project tooling config into setup.cfg (flake8, coverage, wheel, zest.releaser) the whole ecosystem. Somehow that also a feature of I am not convinced that we should force people into a way of doing things. I wish we could handle INI config files for black, we don't even need to have a default file. We could put black config in any INI files and add a black command argument such as |
@zsol, just to clarify, are you only against multiple formats? Or also against multiple possible files? For example, would you consider checking for @Natim, I haven't really followed the convergence. Is there anything formal in that regard I/we should read? It looks like coverage and flake8 anyways both offer |
I like this approach very much! It would allow black to fit in most existing projects without imposing too much beyond code formatting ;) Also since it is close to flake8 in terms of tooling, I believe it makes sense to follow their approach and allow both configs to be close to each other! |
I'm against multiple formats as well as multiple possible files. My understanding is that flake8 isn't very happy with how their configuration story looks like today. See #65 (comment) |
https://github.com/altendky/tempexample/tree/f680fc866c6cf80ed3824b92926e0585e5e0143d I updated the example failure I provided over in pypa/setuptools#1642. It no longer fails with |
Full switch to Since you are a major contributor to this project, I'm now wondering how big are the chances to see this issue being resolved :) Is there any exploration/study that we could do so that you change your mind? |
I'm wondering, too – a |
Hi, This ends up fracturing the config on a lot of projects, unfortunately. I'd like to keep python configs in one spot. This is one area where setup.cfg makes sense. No other projects I'm aware of (flake8, pytest, isort) require pyproject.toml. In fact, out of all the python plugins I'm using (in open source projects and private ones) black is the only one that requires pyproject.toml. P.S. I'm not against pyproject.toml (I'm 👍 for it!) |
It's worth adding that as of pip 19.1, the mere existence of a I'd (and probably others would?) be willing to have a shot at writing the patch to add such support if it stood a chance of being included, but obv don't want to look at doing this if it's not welcome in the project in the first place. |
The mere existance of pyproject.toml is also breaking tox builds due to pip 19.1 and black configs needing to exist in pyproject.toml I would very much look forward to being able to config black in a different file (I still think keeping the pyproject.toml implementation along side a new location would make sense for projects that specifically use pyptoject.toml for different build-backends, etc) |
Ack, 19.0 broke everything and now 19.1 too? It seems like the build process agnostic choice is a separate file ( |
Did you mean |
@Natim quite so, thanks |
Would adding a diff --git a/black.py b/black.py
index 0ea9b9a..303702c 100644
--- a/black.py
+++ b/black.py
@@ -205,10 +205,15 @@ def read_pyproject_toml(
assert not isinstance(value, (int, bool)), "Invalid parameter type passed"
if not value:
root = find_project_root(ctx.params.get("src", ()))
- path = root / "pyproject.toml"
- if path.is_file():
- value = str(path)
- else:
+ # Attempt to find black.toml or pyproject.toml
+ paths = (root / "black.toml", root / "pyproject.toml")
+ found = False
+ for path in paths:
+ if path.is_file():
+ value = str(path)
+ found = True
+ break
+ if not found:
return None
try:
@@ -3239,6 +3244,9 @@ def find_project_root(srcs: Iterable[str]) -> Path:
if (directory / ".hg").is_dir():
return directory
+ if (directory / "black.toml").is_file():
+ return directory
+
if (directory / "pyproject.toml").is_file():
return directory |
You can already run |
Big +1 for using |
pip 19.1.1 fixes this issue. We're keeping |
Does it? As far as I understood pip 19.1.1 only addresses the issue with develop mode pypa/pip#6434 that was broken, it doesn't change the fact adding It is maybe less problematic with pure python packages, but for scientific computing this appears to install a separate version numpy and scipy for the build when those used at runtime (e.g. installed with conda) which can be unacceptable¹. This in turns becomes a blocker for using black. ¹ For instance, in the case where no binary wheels exist on PyPi (e.g. ARM), I think it will try compile numpy & scipy from sources even when these packages are already installed from other sources. |
For more context here are some of unresolved issues in pip related to the use of |
+1 for setup.cfg, way more widely used. |
Among the projects that currently have a |
Apparently in order to use pyproject.toml, you have to use poetry? Is that correct? |
If "not creating even more confusion about the Python packaging landscape" is not a good enough argument for black to switch to |
No. Black stores its config in pyproject.toml. Poetry stores its config in pyproject.toml. You can put info into pyproject.toml for pip to build your project instead of using setup.py. The issue was that Pip for a bit there was using the mere existence of pyproject.toml to change how installation of projects worked. I think they may have ironed that out now. |
pyproject.toml is the standard for configuration. Every *.ini, *.cfg, *rc, and last but not least setup.py will go away at some point in the future. Tool maintainers not wanting to add support for pyproject.toml are therefore making a bad decision, and black adding support for another config file would be pointless and increase maintenance costs. |
As far as I know, today the default Python packaging tools don't support pyproject.toml except for a hack with Poetry. Source: |
The links you quoted as sources aren’t saying anything about what supports PEP 518. Also why did you say “hack”? Poetry is a first-class packaging tool and no less or more a hack than any other. I made an overview here: https://github.com/flying-sheep/awesome-python-packaging#readme Please note how 4/5 package development tools / package managers (exception: pipenv) support pyproject.toml: poetry, flit, pip, and dephell. |
Please do not derail this into a discussion on the relative merits of Python packaging tools. |
Right, good point, I rephrased. |
fwiw, until pytest and mypy support pyproject.toml, I'm stuck keeping around a setup.cfg, so I've got both. seems odd that pep518 has been out for 2 years and more things haven't added support. |
Here's a summary of which tools do support |
pylint added pyproject.toml support! So if one don’t need to configure pytest, they can have all their config in pyproject.toml, e.g. using tox, black, pylint, isort, and poetry |
I'm a bit confused as to why this issue remains closed despite lots of reactions showing 👍s for additionally supporting |
Yes, it's unwelcome. We are not adding setup.cfg as source of configuration, sorry. |
pypa/pip#6163
pypa/setuptools#1642
It seems that
pyproject.toml
is a trigger for enabling PEP 517 isolated builds. This seems a not good thing to tie to configuration of black. It broke pyinstaller and others with the pip-19.0 release.The text was updated successfully, but these errors were encountered: