Chris McDonough <chr...@plope.com> writes: > FWIW, this particular use case (retrieving the version by importing it > or a function that returns it after it reads a file or whatever), is > dodgy. It's way better that code that needs version info inside the > package consult pkg_resources or some similar system: > > import pkg_resources > version = pkg_resources.get_distribution('mydistro').version
That's all fine once the distribution is *installed*, and I agree ‘pkg_resources’ is appropriate for querying the version of an already-installed Python distribution. But the whole point here (AIUI) is that the ‘setup.py’ is responsible for storing that information in the distribution. And ‘setup.py’ may need to import third-party modules in order to get the version information. For many projects, the version information is best stored in a central place and ‘setup.py’ is just one consumer of many for that information. Getting the version information may itself need distributions installed (e.g. in my case, Docutils). > I realize there are other use cases that setup_requires solves, and > that using pkg_resources can be a performance issue. The issue isn't importing ‘pkg_resources’. The issue is generating the distribution, which ‘pkg_resources’ can't help with. > Python packaging should be able to provide them this information, they > should not need to provide it themselves. Once the distribution is installed: I agree. While generating the distribution – the point where ‘setup_requires’ is meant to help – no, I disagree. We're trying to get information such that it can be fed to Distutils, since Distutils can't know until it's told. -- \ “Nothing exists except atoms and empty space; everything else | `\ is opinion.” —Democritus | _o__) | Ben Finney _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org https://mail.python.org/mailman/listinfo/distutils-sig