On Apr 05, 2011, at 01:22 PM, Glenn Linderman wrote:
On 4/5/2011 11:52 AM, Barry Warsaw wrote:
DEFAULT_VERSION_RE = re.compile(r'(?P<version>\d+\.\d(?:\.\d+)?)') __version__ = pkgutil.get_distribution('elle').metadata['version']
The RE as given won't match alpha, beta, rc, dev, and post suffixes that are discussed in POP 386.
It really wasn't intended to. I'm torn about even including this code sample in the PEP. I'm highly tempted to rip this out and hand-wave over the implementation of get_version(). It's not a critical part of the PEP and might just be distracting.
Are there issues for finding and loading multiple versions of the same module?
Out of scope for this PEP I think.
Should it be possible to determine a version before loading a module? If yes, the version module would have to be able to find a parse version strings in any of the many places this PEP suggests they could be... so that would be somewhat complex, but the complexity shouldn't be used to change the answer... but if the answer is yes, it might encourage fewer variant cases to be supported for acceptable version definition locations for this PEP.
I think the answer can be "yes", but only through distutils2/packaging APIs. If there's no metadata for a module available, then I don't have a problem saying the version information can't be determined without importing it.