diff options
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 70 |
1 files changed, 33 insertions, 37 deletions
@@ -13,17 +13,15 @@ from distutils.util import convert_path command_ns = {} init_path = convert_path('setuptools/command/__init__.py') -init_file = open(init_path) -exec(init_file.read(), command_ns) -init_file.close() +with open(init_path) as init_file: + exec(init_file.read(), command_ns) SETUP_COMMANDS = command_ns['__all__'] main_ns = {} ver_path = convert_path('setuptools/version.py') -ver_file = open(ver_path) -exec(ver_file.read(), main_ns) -ver_file.close() +with open(ver_path) as ver_file: + exec(ver_file.read(), main_ns) import setuptools from setuptools.command.build_py import build_py as _build_py @@ -31,20 +29,28 @@ from setuptools.command.test import test as _test scripts = [] -console_scripts = ["easy_install = setuptools.command.easy_install:main"] +def _gen_console_scripts(): + yield "easy_install = setuptools.command.easy_install:main" + + # Gentoo distributions manage the python-version-specific scripts + # themselves, so those platforms define an environment variable to + # suppress the creation of the version-specific scripts. + var_names = ( + 'SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT', + 'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT', + ) + if any(os.environ.get(var) not in (None, "", "0") for var in var_names): + return + yield ("easy_install-{shortver} = setuptools.command.easy_install:main" + .format(shortver=sys.version[:3])) + +console_scripts = list(_gen_console_scripts()) -# Gentoo distributions manage the python-version-specific scripts themselves, -# so they define an environment variable to suppress the creation of the -# version-specific scripts. -if os.environ.get("SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT") in (None, "", "0") and \ - os.environ.get("DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT") in (None, "", "0"): - console_scripts.append("easy_install-%s = setuptools.command.easy_install:main" % sys.version[:3]) # specific command that is used to generate windows .exe files class build_py(_build_py): def build_package_data(self): """Copy data files into build directory""" - lastdir = None for package, src_dir, build_dir, filenames in self.data_files: for filename in filenames: target = os.path.join(build_dir, filename) @@ -62,23 +68,17 @@ class test(_test): _test.run(self) return # even though _test.run will raise SystemExit - f = open(entry_points) - - # running the test - try: + # save the content + with open(entry_points) as f: ep_content = f.read() - finally: - f.close() + # run the test try: _test.run(self) finally: - # restoring the file - f = open(entry_points, 'w') - try: + # restore the file + with open(entry_points, 'w') as f: f.write(ep_content) - finally: - f.close() readme_file = open('README.txt') @@ -88,12 +88,16 @@ if os.path.exists('CHANGES (links).txt'): else: # but if the release script has not run, fall back to the source file changes_file = open('CHANGES.txt') -long_description = readme_file.read() + '\n' + changes_file.read() -readme_file.close() -changes_file.close() +with readme_file: + with changes_file: + long_description = readme_file.read() + '\n' + changes_file.read() package_data = {'setuptools': ['site-patch.py']} -if sys.platform == 'win32' or os.environ.get("SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES") not in (None, "", "0"): +force_windows_specific_files = ( + os.environ.get("SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES") + not in (None, "", "0") +) +if sys.platform == 'win32' or force_windows_specific_files: package_data.setdefault('setuptools', []).extend(['*.exe']) package_data.setdefault('setuptools.command', []).extend(['*.xml']) @@ -169,8 +173,6 @@ setup_params = dict( License :: OSI Approved :: Python Software Foundation License License :: OSI Approved :: Zope Public License Operating System :: OS Independent - Programming Language :: Python :: 2.4 - Programming Language :: Python :: 2.5 Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 @@ -184,17 +186,11 @@ setup_params = dict( """).strip().splitlines(), extras_require = { "ssl:sys_platform=='win32'": "wincertstore==0.1", - "ssl:sys_platform=='win32' and python_version=='2.4'": "ctypes==1.0.2", - "ssl:python_version in '2.4, 2.5'":"ssl==1.16", "certs": "certifi==0.0.8", }, dependency_links = [ 'https://pypi.python.org/packages/source/c/certifi/certifi-0.0.8.tar.gz#md5=dc5f5e7f0b5fc08d27654b17daa6ecec', - 'https://pypi.python.org/packages/source/s/ssl/ssl-1.16.tar.gz#md5=fb12d335d56f3c8c7c1fefc1c06c4bfb', 'https://pypi.python.org/packages/source/w/wincertstore/wincertstore-0.1.zip#md5=2f9accbebe8f7b4c06ac7aa83879b81c', - 'https://bitbucket.org/pypa/setuptools/downloads/ctypes-1.0.2.win32-py2.4.exe#md5=9092a0ad5a3d79fa2d980f1ddc5e9dbc', - 'https://bitbucket.org/pypa/setuptools/downloads/ssl-1.16-py2.4-win32.egg#md5=3cfa2c526dc66e318e8520b6f1aadce5', - 'https://bitbucket.org/pypa/setuptools/downloads/ssl-1.16-py2.5-win32.egg#md5=85ad1cda806d639743121c0bbcb5f39b', ], scripts = [], # tests_require = "setuptools[ssl]", |