From 0e5c42377f2c337622d641d10303c6c0fd99f4f6 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 3 Dec 2015 09:30:06 -0700 Subject: [PATCH] Fix unclosed file handles in setup.py. --- TODO.rst | 4 ---- setup.py | 22 +++++++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 TODO.rst diff --git a/TODO.rst b/TODO.rst deleted file mode 100644 index 4218c78..0000000 --- a/TODO.rst +++ /dev/null @@ -1,4 +0,0 @@ -TODO -==== - -* Switch to proper test skips once Django 1.3 is minimum supported. diff --git a/setup.py b/setup.py index feb5ffc..8b92d32 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,29 @@ -from os.path import join +import os from setuptools import setup, find_packages -long_description = (open('README.rst').read() + - open('CHANGES.rst').read() + - open('TODO.rst').read()) +def long_desc(root_path): + FILES = ['README.rst', 'CHANGES.rst'] + for filename in FILES: + filepath = os.path.realpath(os.path.join(root_path, filename)) + if os.path.isfile(filepath): + with open(filepath, mode='r') as f: + yield f.read() -def get_version(): - with open(join('model_utils', '__init__.py')) as f: +HERE = os.path.abspath(os.path.dirname(__file__)) +long_description = "\n\n".join(long_desc(HERE)) + + +def get_version(root_path): + with open(os.path.join(root_path, 'model_utils', '__init__.py')) as f: for line in f: if line.startswith('__version__ ='): return line.split('=')[1].strip().strip('"\'') setup( name='django-model-utils', - version=get_version(), + version=get_version(HERE), description='Django model mixins and utilities', long_description=long_description, author='Carl Meyer',