Branch merge

This commit is contained in:
Éric Araujo 2011-09-18 20:24:27 +02:00
commit cc95dd81f3
16 changed files with 48 additions and 97 deletions

View file

@ -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):

View file

@ -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

View file

@ -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):

View file

@ -2,15 +2,14 @@
# Forked from the former install_egg_info command by Josip Djolonga
import csv
import os
import re
import csv
import hashlib
from packaging.command.cmd import Command
from packaging import logger
from shutil import rmtree
from packaging import logger
from packaging.command.cmd import Command
class install_distinfo(Command):

View file

@ -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?