ionelmc / cookiecutter-pylibrary

Enhanced cookiecutter template for Python libraries.
BSD 2-Clause "Simplified" License
1.25k stars 207 forks source link

Define block setup_requires_interior #149

Closed dHannasch closed 5 years ago

dHannasch commented 5 years ago

…that includes both pytest-runner and setuptools_scm as appropriate.

Resolves #147.

Note that this still has two Travis failures on ENV=pure-private (due to #146) and ENV=matrix-cext (that will be fixed by #145).

ionelmc commented 5 years ago

Oooof ... good catch. I don't really remember why I put it in setup.cfg.

ionelmc commented 5 years ago

@dHannasch I'm thinking now about moving that tests_require in setup.py as well - but with a briefer comment - what do you think?

dHannasch commented 5 years ago

@dHannasch I'm thinking now about moving that tests_require in setup.py as well - but with a briefer comment - what do you think?

Hrm. It looks like they generally recommend using setup.cfg when possible, or rather, they want to recommend that but are worried about older versions before setup.cfg was supported. https://github.com/pypa/packaging.python.org/issues/378 As long as we're using setup.cfg at all, it seems like it probably makes sense to prefer leaving settings in setup.cfg rather than setup.py.

(Of course setup_requires can't be in setup.cfg because setup.cfg isn't sophisticated enough to handle things like "require CFFI but only sometimes." But tests_require can be in setup.cfg.)

To be honest I'm not sure why they recommend that, but if I had to guess it's because setup.cfg is easier to read, because there's usually some "mess" in setup.py to handle all kinds of oddball problems.

ionelmc commented 5 years ago

Seems they are still talking about it (https://github.com/pypa/sampleproject/pull/57 and the mostly empty https://github.com/pypa/sampleproject/blob/master/setup.cfg). The license_files = LICENSE.txt is strange and out of place. They added that redundant thing (LICENSE* is already included) but didn't make a move on the other metadata.

I wouldn't trust them on anything regarding best practices tho, packaging.python.org is more of a cookbook that tries to give some overview on packaging.

Give then fact that duplicated metadata in setup.py and setup.cfg ain't merged I'm thinking it's a bad practice to spread it across the two files, and it's impossible to have everything in setup.cfg. Therefore it's logical to conclude that the best practice is ... the opposite of https://github.com/pypa/packaging.python.org/issues/378 :)

ionelmc commented 5 years ago

I'll merge this for now to avoid brokenness and we deal with the tests_require later maybe.

dHannasch commented 5 years ago

To clarify, you're talking about deleting setup.cfg entirely, right? Or maybe not.

I can see the logic of, when multiple places might hold settings, keeping the settings only in the highest-priority place. That applies to pretty much everything in setup.cfg, because setup.cfg is never the highest-priority place. E.g. pytest.ini overrides setup.cfg, and the settings are not merged. http://doc.pytest.org/en/latest/customize.html

I guess I had been wondering whether we might want separate files .flake8, pytest.ini, etc.

dHannasch commented 5 years ago

Incidentally, is your computer clock two days slow? The "Latest commit" 0bee7f32d7e876853cadf461a0872d2f4df0d3e5 says it's from two days ago. https://travis-ci.org/ionelmc/cookiecutter-pylibrary/builds/590801237?utm_source=github_status&utm_medium=notification

ionelmc commented 5 years ago

Oooof ... ntp service was hosed :\

ionelmc commented 5 years ago

Well I put what I could in setup.cfg to avoid dozens of root-level files. Coveragerc wasn't moved there because pytest-cov doesn't work nice with non-default file (it's messy and can't be fixed). I was suggesting moving out just the tests_require. Maybe we could move out all to separate files - don't know what to say - it's a try it and see how it looks thing.