Commit f4576e37 authored by Jason R. Coombs's avatar Jason R. Coombs

Add VersionlessRequirement adapter to suppress the version number in a Distribution. Ref #439.

parent 998cecea
......@@ -167,3 +167,26 @@ class develop(easy_install):
script_text = f.read()
f.close()
self.install_script(dist, script_name, script_text, script_path)
class VersionlessRequirement(object):
"""
Adapt a pkg_resources.Distribution to simply return the project
name as the 'requirement' so that scripts will work across
multiple versions.
>>> dist = Distribution(project_name='foo', version='1.0')
>>> str(dist.as_requirement())
'foo==1.0'
>>> adapted_dist = VersionlessRequirement(dist)
>>> str(adapted_dist.as_requirement())
'foo'
"""
def __init__(self, dist):
self.__dist = dist
def __getattr__(self, name):
return getattr(self.__dist, name)
def as_requirement(self):
return self.project_name
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment