-
-
Notifications
You must be signed in to change notification settings - Fork 524
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
Allow setup.cfg
as an alternative configuration file
#297
Comments
Original comment by @bittner Would you guys prefer including all other test tools via |
Original comment by @RonnyPfannschmidt I'm fine with a single file, but setup.cfg very certainly is not that file due to legacy and breakage potential |
Original comment by @The-Compiler FWIW, in pytest abusing setup.cfg causes various kinds of pain (examples: 1311, 567), and there is some consensus to deprecate and drop This seems very much a technical reason and not just a personal preference to not go down that rabbit hole again. |
Original comment by @bittner Under the light of "move to a single config file for packaging and testing" (Holger): Allowing We must respect other arguments in this discussion, but as long as they are personal preference and clash with future benefits of python we should be able to agree on a common ground. (I know this is difficult, because the whole discussion is about personal preference.) |
Original comment by @RonnyPfannschmidt this will drag on a massive legacy, and now that pypa.json will come there will be another source of truth and setup.cfg might become obsolete |
Original comment by @hpk42 I understand that seing a "tox.ini" and "pytest.ini" signals useful information. On the other hand i'd like to see python move to a single config file for packaging and testing because i dislike the proliferation of config files. If we today say we want to have separate files we'll have |
Original comment by @warsaw @The-Compiler A couple of minor details in a moment, but I think you've nailed the essential bits. I do the same thing - when I see a tox.ini in an upstream project, there's no guessing as to how to run the test suite, and that is a huge win for Python in general. I've long pined for a consistent interface to test discovery, and there's more to be done with the newer metadata formats (i.e. it would be nice to have a declarative way to know), but as tox becomes more prevalent, it's becoming less mysterious how to run the tests. I used to thing A few details: our source package git branch does include the full upstream source, and during package build we also have the full source available, albeit with any Debian patches already applied (though with pytest 2.8.5 we have only one such patch left). However, we can't use tox for technical reasons in our build tools, something I plan on working to fix at some point. (Our recommended Python build helper supports tox, but it needs to plumb through additional argument passing, e.g. --sitepackages). So for now, what I generally do is pluck out the [testenv]commands bit and put that in our build rules file. That's what I did in the pytest case. I just missed that the [pytest] section of the tox.ini was relevant. You're spot on for that point. Unrelated to the issue we discussed (and for you help... thanks!) was that we cannot run the tests from the top-level source tree. I was doing that originally and got three mysterious failures in test_genscripts. I was about to give up on those tests (as I understand it, genscripts is deprecated anyway), but someone else in Debian helped debug this issue and now we cd to the temp directory when running the tests and they now pass. One last thing, I've noticed that the pytest suite doesn't clean up all its tempdirs. Normally, our builds run in overlays so can't mess with the host filesystem, but this isn't the case for /tmp. For this reason I mktemp a separate tempdir and export $TMPDIR to run the test suite. It still leaves cruft, but it's easier to clean up after the fact. Thanks for all your help! We now have 2.8.5 in Debian. |
Original comment by @The-Compiler Some other thoughts: Yesterday I helped @warsaw debug an issue where a pytest test failed when packaging for Debian. If I understood the issue correctly, Debian doesn't use tox to run the tests when packaging, so they didn't have the Also from my experience contributing to, say, about 20 python projects (quite possibly more), I see |
Original comment by @RonnyPfannschmidt i think its a considerable dirty and problematic solution to just drop random things into the namespace of a config file of a different tool, i already find i fairly problematic that pytest/flake8 configuration inside tox.init has no prefix for the configuration key a much more preferable solution would be a standardized folder that tools can choose adapt or a per tool convention on adding other tools to the configfile |
Original comment by @hpk42 ah. in any case i agree it's a good idea to have a single file configuring packaging and testing. Ronny why do you think it's a bad idea to have tox config in setup.cfg? I guess we should at some point make it more official, probably by starting to discuss on distutils-sig. |
Original comment by @bittner @hpk42 No, not tox. Only py.test does it. See _pytest/config.py (line 1121+). |
Original comment by @hpk42 not sure i follow. Isn't tox currently looking into setup.cfg already? I think you can define |
Original comment by @RonnyPfannschmidt Still a dirty solution that just makes something easy at first glance instead of simple |
Original comment by @bittner Maybe I should give some more background information, so people can understand my motivation (and the one of those that share my opinion): When you look at a typical Web development project you have tons of configuration files, the majority of them from frontend technologies (in agency projects I have participated with). The project repository root is polluted by files, which is just "noise" that makes your project less maintainable: bower.json
config.rb
.coveragerc
.csscomb.json
Dockerfile | Vagrantfile
.eslintrc
Gemfile
Gemfile.lock
gulpfile.js
lint.yml
package.json
pylintrc
scss.mustache
setup.cfg
spritesmith-retina-mixins.template.mustache
tox.ini I believe we "backend people" should know better. In projects that I do at least Yes, This way you can run your tests with So, what if in a typical project you have only a single file that you look into to find out what the test setup is like? That could be appealing to a couple of folks out there, myself included. For excessive use, like in Florian's qutebrowser project, you can still have this split up, which makes perfectly sense when you have such a huge amount of configuration data. |
Original comment by @The-Compiler Sure, see https://github.com/The-Compiler/qutebrowser
I see that, but I'm still questioning if it's worth having the additional complexity in all those tools ;) |
Original comment by @bittner Can you share what you have in a 243 lines Here is a working sample configuration for a bunch of test tools. 27 lines total; note that I have symlinks for Please keep in mind that I'm suggesting an alternative to the current approach, not a replacement. |
Original comment by @The-Compiler Something about our configurations is clearly different then ;)
|
Original comment by @RonnyPfannschmidt ftr. by now i also consider that py.test looks in more than pytest.ini a problem |
Original comment by @bittner @The-Compiler The "all-code-in-one-file" allegory is not correct. Configuration for testing in a single location, especially when several different tools are used on a single project, has a distict advantage: You can compare the settings of the different tools in use. You have all your test-related settings in a single place. I don't think this file will ever have more than 20 lines (i.e. half a screen page), even with a couple of tools using. |
Original comment by @bittner Doing this is a bit tricky, though. It requires giving up some elegance in |
Original comment by @The-Compiler I personally think this is a bad idea as well, especially for tools which typically require multiple sections.
|
@bittner Do you have an opinion about if and how we should move this discussion forward here or was it moved to distutils-sig as @hpk42 suggested? I am trying to shorten our backlog and I would tend to close this issue here as it's scope extends just tox and is more about the Python testing ecosystem as a whole. So maybe this discussion should be led e.g. in distutils-sig (if it not already has happened ... I am not on that list (yet)). |
@obestwalter PEP-518 introduced a file with a open namespace, however its not a ini file and currently the python parser available are not that good |
To me this means we should close this issue here, because the discussion was already taken elsewhere, right? |
@obestwalter the real issue as seen by @bittner and others is the massive overspill of config files in the project root ^^ just going pep-518 wint really help, since the structure of that file is contrary to basically all of tox |
I still see this this discussion as being wildly out of scope for tox. This is a problem with the general ecosystem even exceeding the Python ecosystem. There is also massive diversity in tastes as well, as some seem to think it's nice to be able to configure tox/pytest/flake etc. inside a tox.ini or a setup.cfg and others think that's plainly wrong. |
yes, from my pov the problem is not the number of files, but that everyone feels entitled to shit them into the root folder (i have been there and did the same) |
I don't see that this problem is "exceeding the Python ecosystem". At least with giving the choice of placing configuration data for testing and packaging into (various) places would help on the Python side. We won't solve the JavaScript flood of config files, but that's not our job. Personally, I've started to use I have a PR open with the behave project to make this come true for yet another tool. I think we should give the developers a choice. We don't have an isolated, clean approach to solve this problem domain anyway. Let's be pragmatic. |
@bittner note that tox uses iniparse (which is vendored in pylib and incompatible with configparser and other parsers) |
I'd really like to see a move in the Python world to separating things needed to build/deploy/install the package and things needed to test it. I once thought It means to me that |
@warsaw i like that idea, but i dislike the clutter because of lack of name-spacing |
Hum, not sure i can follow all comments here (also the bb-github move changed the order of some comments i guess). With @warsaw and @RonnyPfannschmidt strongly speaking against using It seems we all kind of agree that having pytest config (and maybe other testing tools config) in a tox.ini is less of a problem then putting it to If discussing the involved issues further i suggest to bring them up on testing-in-python and/or distutils-sig. |
@hpk42 Was this not done? Tox does pick up |
@jleclanche @hpk42 @obestwalter As I said, we could give developers a choice. In my eyes the advantages (in "freedom") outweigh the (technical) disadvantages by far. It wouldn't be hard to allow Note that I'm saying this as someone who has switched to using |
@bittner creating choices has maintenance cost, for choices that can be demonstrated as reasonably bad i dont see why a project should have to take the maintenance hit just because some want to engage in bad practices |
also please consider that there is not just "freedom to" but also "freedom of" - and as volunteer driving projects the freedom from maintaining bad miss features is a massive win |
(This issue comes from a comment in issue #185.) I'd love to see the tox configuration living in
setup.cfg
too in general, as an alternative.It would allow a more elegant Python package configuration for developers: You could put configuration of all your tools into a single file. The ini-style allows for separate sections. I've described some considerations in a comment on issue 13.
A few projects already look into
setup.cfg
. flake8, behave, py.test, among others. Pylint is a prominent exception (its maintainer considers this idea harmful; declined PR; discussion).The text was updated successfully, but these errors were encountered: