diff options
Diffstat (limited to 'wheel/metadata.py')
-rw-r--r-- | wheel/metadata.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/wheel/metadata.py b/wheel/metadata.py index b3cc65c..fd2bb7e 100644 --- a/wheel/metadata.py +++ b/wheel/metadata.py @@ -15,7 +15,8 @@ import os.path import textwrap import pkg_resources import email.parser -import wheel + +from . import __version__ as wheel_version METADATA_VERSION = "2.0" @@ -106,12 +107,13 @@ def pkginfo_to_dict(path, distribution=None): """ metadata = OrderedDefaultDict(lambda: OrderedDefaultDict(lambda: OrderedDefaultDict(OrderedDict))) - metadata["generator"] = "bdist_wheel (" + wheel.__version__ + ")" + metadata["generator"] = "bdist_wheel (" + wheel_version + ")" try: unicode pkg_info = read_pkg_info(path) except NameError: - pkg_info = email.parser.Parser().parsestr(open(path, 'rb').read().decode('utf-8')) + with open(path, 'rb') as pkg_info_file: + pkg_info = email.parser.Parser().parsestr(pkg_info_file.read().decode('utf-8')) description = None if pkg_info['Summary']: @@ -244,7 +246,8 @@ def pkginfo_to_metadata(egg_info_path, pkginfo_path): pkg_info.replace_header('Metadata-Version', '2.0') requires_path = os.path.join(egg_info_path, 'requires.txt') if os.path.exists(requires_path): - requires = open(requires_path).read() + with open(requires_path) as requires_file: + requires = requires_file.read() for extra, reqs in sorted(pkg_resources.split_sections(requires), key=lambda x: x[0] or ''): condition = '' |