summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/command
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-09-17 01:31:51 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-09-17 01:31:51 (GMT)
commit7724a6c10c56a1b14b4933de368e672eae840f47 (patch)
tree1b3bd60ab9b79bd018cbc942a8e12140b2e18576 /Lib/packaging/command
parent37ccd6f794539e0678b7a7ad938e571cc73e106c (diff)
downloadcpython-7724a6c10c56a1b14b4933de368e672eae840f47.zip
cpython-7724a6c10c56a1b14b4933de368e672eae840f47.tar.gz
cpython-7724a6c10c56a1b14b4933de368e672eae840f47.tar.bz2
Packaging cleanup: remove conditionals for < 2.6 support.
PEP 370 features and sys.dont_write_bytecode are always available in 3.3; the distutils2 backport still has the conditionals. I also renamed an internal misnamed method and fixed a few things (“packaging2” name, stray print, unused import, fd leak).
Diffstat (limited to 'Lib/packaging/command')
-rw-r--r--Lib/packaging/command/build_ext.py17
-rw-r--r--Lib/packaging/command/build_py.py2
-rw-r--r--Lib/packaging/command/install_dist.py59
-rw-r--r--Lib/packaging/command/install_distinfo.py7
-rw-r--r--Lib/packaging/command/install_lib.py2
5 files changed, 32 insertions, 55 deletions
diff --git a/Lib/packaging/command/build_ext.py b/Lib/packaging/command/build_ext.py
index 2bffae3..4051a2d 100644
--- a/Lib/packaging/command/build_ext.py
+++ b/Lib/packaging/command/build_ext.py
@@ -3,6 +3,7 @@
import os
import re
import sys
+import site
import logging
import sysconfig
@@ -15,9 +16,6 @@ from packaging.util import newer_group
from packaging.compiler.extension import Extension
from packaging import logger
-import site
-HAS_USER_SITE = True
-
if os.name == 'nt':
from packaging.compiler.msvccompiler import get_build_version
MSVC_VERSION = int(get_build_version())
@@ -62,6 +60,8 @@ class build_ext(Command):
('inplace', 'i',
"ignore build-lib and put compiled extensions into the source " +
"directory alongside your pure Python modules"),
+ ('user', None,
+ "add user include, library and rpath"),
('include-dirs=', 'I',
"list of directories to search for header files" + sep_by),
('define=', 'D',
@@ -88,12 +88,8 @@ class build_ext(Command):
"path to the SWIG executable"),
]
- boolean_options = ['inplace', 'debug', 'force']
+ boolean_options = ['inplace', 'debug', 'force', 'user']
- if HAS_USER_SITE:
- user_options.append(('user', None,
- "add user include, library and rpath"))
- boolean_options.append('user')
help_options = [
('help-compiler', None,
@@ -120,8 +116,7 @@ class build_ext(Command):
self.compiler = None
self.swig = None
self.swig_opts = None
- if HAS_USER_SITE:
- self.user = None
+ self.user = None
def finalize_options(self):
self.set_undefined_options('build',
@@ -270,7 +265,7 @@ class build_ext(Command):
self.swig_opts = self.swig_opts.split(' ')
# Finally add the user include and library directories if requested
- if HAS_USER_SITE and self.user:
+ if self.user:
user_include = os.path.join(site.USER_BASE, "include")
user_lib = os.path.join(site.USER_BASE, "lib")
if os.path.isdir(user_include):
diff --git a/Lib/packaging/command/build_py.py b/Lib/packaging/command/build_py.py
index 7baa6e4..0eafffa 100644
--- a/Lib/packaging/command/build_py.py
+++ b/Lib/packaging/command/build_py.py
@@ -388,7 +388,7 @@ class build_py(Command, Mixin2to3):
self.build_module(module, module_file, package)
def byte_compile(self, files):
- if hasattr(sys, 'dont_write_bytecode') and sys.dont_write_bytecode:
+ if sys.dont_write_bytecode:
logger.warning('%s: byte-compiling is disabled, skipping.',
self.get_command_name())
return
diff --git a/Lib/packaging/command/install_dist.py b/Lib/packaging/command/install_dist.py
index dfe6df2..4fbca7e 100644
--- a/Lib/packaging/command/install_dist.py
+++ b/Lib/packaging/command/install_dist.py
@@ -14,9 +14,6 @@ from packaging.util import convert_path, change_root, get_platform
from packaging.errors import PackagingOptionError
-HAS_USER_SITE = True
-
-
class install_dist(Command):
description = "install everything from build directory"
@@ -27,6 +24,9 @@ class install_dist(Command):
"installation prefix"),
('exec-prefix=', None,
"(Unix only) prefix for platform-specific files"),
+ ('user', None,
+ "install in user site-packages directory [%s]" %
+ get_path('purelib', '%s_user' % os.name)),
('home=', None,
"(Unix only) home directory to install under"),
@@ -97,15 +97,7 @@ class install_dist(Command):
]
boolean_options = ['compile', 'force', 'skip-build', 'no-distinfo',
- 'requested', 'no-record']
-
- if HAS_USER_SITE:
- user_options.append(
- ('user', None,
- "install in user site-packages directory [%s]" %
- get_path('purelib', '%s_user' % os.name)))
-
- boolean_options.append('user')
+ 'requested', 'no-record', 'user']
negative_opt = {'no-compile': 'compile', 'no-requested': 'requested'}
@@ -115,8 +107,7 @@ class install_dist(Command):
self.prefix = None
self.exec_prefix = None
self.home = None
- if HAS_USER_SITE:
- self.user = False
+ self.user = False
# These select only the installation base; it's up to the user to
# specify the installation scheme (currently, that means supplying
@@ -135,9 +126,8 @@ class install_dist(Command):
self.install_lib = None # set to either purelib or platlib
self.install_scripts = None
self.install_data = None
- if HAS_USER_SITE:
- self.install_userbase = get_config_var('userbase')
- self.install_usersite = get_path('purelib', '%s_user' % os.name)
+ self.install_userbase = get_config_var('userbase')
+ self.install_usersite = get_path('purelib', '%s_user' % os.name)
self.compile = None
self.optimize = None
@@ -219,9 +209,8 @@ class install_dist(Command):
raise PackagingOptionError(
"must supply either home or prefix/exec-prefix -- not both")
- if HAS_USER_SITE and self.user and (
- self.prefix or self.exec_prefix or self.home or
- self.install_base or self.install_platbase):
+ if self.user and (self.prefix or self.exec_prefix or self.home or
+ self.install_base or self.install_platbase):
raise PackagingOptionError(
"can't combine user with prefix/exec_prefix/home or "
"install_base/install_platbase")
@@ -274,11 +263,9 @@ class install_dist(Command):
'exec_prefix': exec_prefix,
'srcdir': srcdir,
'projectbase': projectbase,
- }
-
- if HAS_USER_SITE:
- self.config_vars['userbase'] = self.install_userbase
- self.config_vars['usersite'] = self.install_usersite
+ 'userbase': self.install_userbase,
+ 'usersite': self.install_usersite,
+ }
self.expand_basedirs()
@@ -295,9 +282,9 @@ class install_dist(Command):
self.dump_dirs("post-expand_dirs()")
- # Create directories in the home dir:
- if HAS_USER_SITE and self.user:
- self.create_home_path()
+ # Create directories under USERBASE
+ if self.user:
+ self.create_user_dirs()
# Pick the actual directory to install all modules to: either
# install_purelib or install_platlib, depending on whether this
@@ -311,10 +298,8 @@ class install_dist(Command):
# Convert directories from Unix /-separated syntax to the local
# convention.
- self.convert_paths('lib', 'purelib', 'platlib',
- 'scripts', 'data', 'headers')
- if HAS_USER_SITE:
- self.convert_paths('userbase', 'usersite')
+ self.convert_paths('lib', 'purelib', 'platlib', 'scripts',
+ 'data', 'headers', 'userbase', 'usersite')
# Well, we're not actually fully completely finalized yet: we still
# have to deal with 'extra_path', which is the hack for allowing
@@ -355,7 +340,7 @@ class install_dist(Command):
"installation scheme is incomplete")
return
- if HAS_USER_SITE and self.user:
+ if self.user:
if self.install_userbase is None:
raise PackagingPlatformError(
"user base directory is not specified")
@@ -383,7 +368,7 @@ class install_dist(Command):
def finalize_other(self):
"""Finalize options for non-posix platforms"""
- if HAS_USER_SITE and self.user:
+ if self.user:
if self.install_userbase is None:
raise PackagingPlatformError(
"user base directory is not specified")
@@ -494,10 +479,8 @@ class install_dist(Command):
attr = "install_" + name
setattr(self, attr, change_root(self.root, getattr(self, attr)))
- def create_home_path(self):
- """Create directories under ~."""
- if HAS_USER_SITE and not self.user:
- return
+ def create_user_dirs(self):
+ """Create directories under USERBASE as needed."""
home = convert_path(os.path.expanduser("~"))
for name, path in self.config_vars.items():
if path.startswith(home) and not os.path.isdir(path):
diff --git a/Lib/packaging/command/install_distinfo.py b/Lib/packaging/command/install_distinfo.py
index c1f85ed..e85aaf7 100644
--- a/Lib/packaging/command/install_distinfo.py
+++ b/Lib/packaging/command/install_distinfo.py
@@ -2,14 +2,13 @@
# Forked from the former install_egg_info command by Josip Djolonga
-import csv
import os
-import re
+import csv
import hashlib
+from shutil import rmtree
-from packaging.command.cmd import Command
from packaging import logger
-from shutil import rmtree
+from packaging.command.cmd import Command
class install_distinfo(Command):
diff --git a/Lib/packaging/command/install_lib.py b/Lib/packaging/command/install_lib.py
index 978f0ef..5e81b41 100644
--- a/Lib/packaging/command/install_lib.py
+++ b/Lib/packaging/command/install_lib.py
@@ -114,7 +114,7 @@ class install_lib(Command):
return outfiles
def byte_compile(self, files):
- if getattr(sys, 'dont_write_bytecode'):
+ if sys.dont_write_bytecode:
# XXX do we want this? because a Python runs without bytecode
# doesn't mean that the *dists should not contain bytecode
#--or does it?