Python distutils.command.install.install() Examples
The following are 30
code examples of distutils.command.install.install().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
distutils.command.install
, or try the search function
.
Example #1
Source File: test_install.py From oss-ftp with MIT License | 6 votes |
def test_finalize_options(self): dist = Distribution({'name': 'xx'}) cmd = install(dist) # must supply either prefix/exec-prefix/home or # install-base/install-platbase -- not both cmd.prefix = 'prefix' cmd.install_base = 'base' self.assertRaises(DistutilsOptionError, cmd.finalize_options) # must supply either home or prefix/exec-prefix -- not both cmd.install_base = None cmd.home = 'home' self.assertRaises(DistutilsOptionError, cmd.finalize_options) # can't combine user with prefix/exec_prefix/home or # install_(plat)base cmd.prefix = None cmd.user = 'user' self.assertRaises(DistutilsOptionError, cmd.finalize_options)
Example #2
Source File: test_install.py From oss-ftp with MIT License | 6 votes |
def test_record(self): install_dir = self.mkdtemp() project_dir, dist = self.create_dist(py_modules=['hello'], scripts=['sayhi']) os.chdir(project_dir) self.write_file('hello.py', "def main(): print 'o hai'") self.write_file('sayhi', 'from hello import main; main()') cmd = install(dist) dist.command_obj['install'] = cmd cmd.root = install_dir cmd.record = os.path.join(project_dir, 'filelist') cmd.ensure_finalized() cmd.run() f = open(cmd.record) try: content = f.read() finally: f.close() found = [os.path.basename(line) for line in content.splitlines()] expected = ['hello.py', 'hello.pyc', 'sayhi', 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] self.assertEqual(found, expected)
Example #3
Source File: paths.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def get_install_paths(name): """ Return the (distutils) install paths for the named dist. A dict with ('purelib', 'platlib', 'headers', 'scripts', 'data') keys. """ paths = {} i = get_install_command(name) for key in install.SCHEME_KEYS: paths[key] = getattr(i, 'install_' + key) # pip uses a similar path as an alternative to the system's (read-only) # include directory: if hasattr(sys, 'real_prefix'): # virtualenv paths['headers'] = os.path.join(sys.prefix, 'include', 'site', 'python' + sys.version[:3], name) return paths
Example #4
Source File: paths.py From jbox with MIT License | 6 votes |
def get_install_paths(name): """ Return the (distutils) install paths for the named dist. A dict with ('purelib', 'platlib', 'headers', 'scripts', 'data') keys. """ paths = {} i = get_install_command(name) for key in install.SCHEME_KEYS: paths[key] = getattr(i, 'install_' + key) # pip uses a similar path as an alternative to the system's (read-only) # include directory: if hasattr(sys, 'real_prefix'): # virtualenv paths['headers'] = os.path.join(sys.prefix, 'include', 'site', 'python' + sys.version[:3], name) return paths
Example #5
Source File: install.py From pledgeservice with Apache License 2.0 | 6 votes |
def do_egg_install(self): easy_install = self.distribution.get_command_class('easy_install') cmd = easy_install( self.distribution, args="x", root=self.root, record=self.record, ) cmd.ensure_finalized() # finalize before bdist_egg munges install cmd cmd.always_copy_from = '.' # make sure local-dir eggs get installed # pick up setup-dir .egg files only: no .egg-info cmd.package_index.scan(glob.glob('*.egg')) self.run_command('bdist_egg') args = [self.distribution.get_command_obj('bdist_egg').egg_output] if setuptools.bootstrap_install_from: # Bootstrap self-installation of setuptools args.insert(0, setuptools.bootstrap_install_from) cmd.args = args cmd.run() setuptools.bootstrap_install_from = None # XXX Python 3.1 doesn't see _nc if this is inside the class
Example #6
Source File: paths.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
def get_install_paths(name): """ Return the (distutils) install paths for the named dist. A dict with ('purelib', 'platlib', 'headers', 'scripts', 'data') keys. """ paths = {} i = get_install_command(name) for key in install.SCHEME_KEYS: paths[key] = getattr(i, 'install_' + key) # pip uses a similar path as an alternative to the system's (read-only) # include directory: if hasattr(sys, 'real_prefix'): # virtualenv paths['headers'] = os.path.join(sys.prefix, 'include', 'site', 'python' + sys.version[:3], name) return paths
Example #7
Source File: test_install.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_finalize_options(self): dist = Distribution({'name': 'xx'}) cmd = install(dist) # must supply either prefix/exec-prefix/home or # install-base/install-platbase -- not both cmd.prefix = 'prefix' cmd.install_base = 'base' self.assertRaises(DistutilsOptionError, cmd.finalize_options) # must supply either home or prefix/exec-prefix -- not both cmd.install_base = None cmd.home = 'home' self.assertRaises(DistutilsOptionError, cmd.finalize_options) # can't combine user with prefix/exec_prefix/home or # install_(plat)base cmd.prefix = None cmd.user = 'user' self.assertRaises(DistutilsOptionError, cmd.finalize_options)
Example #8
Source File: test_install.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_record(self): install_dir = self.mkdtemp() project_dir, dist = self.create_dist(py_modules=['hello'], scripts=['sayhi']) os.chdir(project_dir) self.write_file('hello.py', "def main(): print 'o hai'") self.write_file('sayhi', 'from hello import main; main()') cmd = install(dist) dist.command_obj['install'] = cmd cmd.root = install_dir cmd.record = os.path.join(project_dir, 'filelist') cmd.ensure_finalized() cmd.run() f = open(cmd.record) try: content = f.read() finally: f.close() found = [os.path.basename(line) for line in content.splitlines()] expected = ['hello.py', 'hello.pyc', 'sayhi', 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] self.assertEqual(found, expected)
Example #9
Source File: install.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def initialize_options(self): orig.install.initialize_options(self) self.old_and_unmanageable = None self.single_version_externally_managed = None
Example #10
Source File: locations.py From oss-ftp with MIT License | 5 votes |
def distutils_scheme(dist_name, user=False, home=None, root=None): """ Return a distutils install scheme """ from distutils.dist import Distribution scheme = {} d = Distribution({'name': dist_name}) d.parse_config_files() i = d.get_command_obj('install', create=True) # NOTE: setting user or home has the side-effect of creating the home dir or # user base for installations during finalize_options() # ideally, we'd prefer a scheme class that has no side-effects. i.user = user or i.user i.home = home or i.home i.root = root or i.root i.finalize_options() for key in SCHEME_KEYS: scheme[key] = getattr(i, 'install_'+key) if running_under_virtualenv(): scheme['headers'] = os.path.join(sys.prefix, 'include', 'site', 'python' + sys.version[:3], dist_name) if root is not None: scheme["headers"] = os.path.join( root, os.path.abspath(scheme["headers"])[1:], ) return scheme
Example #11
Source File: install.py From oss-ftp with MIT License | 5 votes |
def initialize_options(self): orig.install.initialize_options(self) self.old_and_unmanageable = None self.single_version_externally_managed = None
Example #12
Source File: install.py From oss-ftp with MIT License | 5 votes |
def finalize_options(self): orig.install.finalize_options(self) if self.root: self.single_version_externally_managed = True elif self.single_version_externally_managed: if not self.root and not self.record: raise DistutilsArgError( "You must specify --record or --root when building system" " packages" )
Example #13
Source File: install.py From Computable with MIT License | 5 votes |
def setuptools_run(self): """ The setuptools version of the .run() method. We must pull in the entire code so we can override the level used in the _getframe() call since we wrap this call by one more level. """ # Explicit request for old-style install? Just do it if self.old_and_unmanageable or self.single_version_externally_managed: return old_install_mod._install.run(self) # Attempt to detect whether we were called from setup() or by another # command. If we were called by setup(), our caller will be the # 'run_command' method in 'distutils.dist', and *its* caller will be # the 'run_commands' method. If we were called any other way, our # immediate caller *might* be 'run_command', but it won't have been # called by 'run_commands'. This is slightly kludgy, but seems to # work. # caller = sys._getframe(3) caller_module = caller.f_globals.get('__name__', '') caller_name = caller.f_code.co_name if caller_module != 'distutils.dist' or caller_name!='run_commands': # We weren't called from the command line or setup(), so we # should run in backward-compatibility mode to support bdist_* # commands. old_install_mod._install.run(self) else: self.do_egg_install()
Example #14
Source File: install.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def finalize_options(self): orig.install.finalize_options(self) if self.root: self.single_version_externally_managed = True elif self.single_version_externally_managed: if not self.root and not self.record: raise DistutilsArgError( "You must specify --record or --root when building system" " packages" )
Example #15
Source File: install.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def handle_extra_path(self): if self.root or self.single_version_externally_managed: # explicit backward-compatibility mode, allow extra_path to work return orig.install.handle_extra_path(self) # Ignore extra_path when installing an egg (or being run by another # command without --root or --single-version-externally-managed self.path_file = None self.extra_dirs = ''
Example #16
Source File: install.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def run(self): # Explicit request for old-style install? Just do it if self.old_and_unmanageable or self.single_version_externally_managed: return orig.install.run(self) if not self._called_from_setup(inspect.currentframe()): # Run in backward-compatibility mode to support bdist_* commands. orig.install.run(self) else: self.do_egg_install()
Example #17
Source File: install.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def do_egg_install(self): easy_install = self.distribution.get_command_class('easy_install') cmd = easy_install( self.distribution, args="x", root=self.root, record=self.record, ) cmd.ensure_finalized() # finalize before bdist_egg munges install cmd cmd.always_copy_from = '.' # make sure local-dir eggs get installed # pick up setup-dir .egg files only: no .egg-info cmd.package_index.scan(glob.glob('*.egg')) self.run_command('bdist_egg') args = [self.distribution.get_command_obj('bdist_egg').egg_output] if setuptools.bootstrap_install_from: # Bootstrap self-installation of setuptools args.insert(0, setuptools.bootstrap_install_from) cmd.args = args cmd.run() setuptools.bootstrap_install_from = None # XXX Python 3.1 doesn't see _nc if this is inside the class
Example #18
Source File: install.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def handle_extra_path(self): if self.root or self.single_version_externally_managed: # explicit backward-compatibility mode, allow extra_path to work return orig.install.handle_extra_path(self) # Ignore extra_path when installing an egg (or being run by another # command without --root or --single-version-externally-managed self.path_file = None self.extra_dirs = ''
Example #19
Source File: install.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def do_egg_install(self): easy_install = self.distribution.get_command_class('easy_install') cmd = easy_install( self.distribution, args="x", root=self.root, record=self.record, ) cmd.ensure_finalized() # finalize before bdist_egg munges install cmd cmd.always_copy_from = '.' # make sure local-dir eggs get installed # pick up setup-dir .egg files only: no .egg-info cmd.package_index.scan(glob.glob('*.egg')) self.run_command('bdist_egg') args = [self.distribution.get_command_obj('bdist_egg').egg_output] if setuptools.bootstrap_install_from: # Bootstrap self-installation of setuptools args.insert(0, setuptools.bootstrap_install_from) cmd.args = args cmd.run() setuptools.bootstrap_install_from = None # XXX Python 3.1 doesn't see _nc if this is inside the class
Example #20
Source File: test_install.py From Computable with MIT License | 5 votes |
def test_home_installation_scheme(self): # This ensure two things: # - that --home generates the desired set of directory names # - test --home is supported on all platforms builddir = self.mkdtemp() destination = os.path.join(builddir, "installation") dist = Distribution({"name": "foopkg"}) # script_name need not exist, it just need to be initialized dist.script_name = os.path.join(builddir, "setup.py") dist.command_obj["build"] = support.DummyCommand( build_base=builddir, build_lib=os.path.join(builddir, "lib"), ) cmd = install(dist) cmd.home = destination cmd.ensure_finalized() self.assertEqual(cmd.install_base, destination) self.assertEqual(cmd.install_platbase, destination) def check_path(got, expected): got = os.path.normpath(got) expected = os.path.normpath(expected) self.assertEqual(got, expected) libdir = os.path.join(destination, "lib", "python") check_path(cmd.install_lib, libdir) check_path(cmd.install_platlib, libdir) check_path(cmd.install_purelib, libdir) check_path(cmd.install_headers, os.path.join(destination, "include", "python", "foopkg")) check_path(cmd.install_scripts, os.path.join(destination, "bin")) check_path(cmd.install_data, destination)
Example #21
Source File: install.py From lambda-chef-node-cleanup with Apache License 2.0 | 5 votes |
def do_egg_install(self): easy_install = self.distribution.get_command_class('easy_install') cmd = easy_install( self.distribution, args="x", root=self.root, record=self.record, ) cmd.ensure_finalized() # finalize before bdist_egg munges install cmd cmd.always_copy_from = '.' # make sure local-dir eggs get installed # pick up setup-dir .egg files only: no .egg-info cmd.package_index.scan(glob.glob('*.egg')) self.run_command('bdist_egg') args = [self.distribution.get_command_obj('bdist_egg').egg_output] if setuptools.bootstrap_install_from: # Bootstrap self-installation of setuptools args.insert(0, setuptools.bootstrap_install_from) cmd.args = args cmd.run() setuptools.bootstrap_install_from = None # XXX Python 3.1 doesn't see _nc if this is inside the class
Example #22
Source File: install.py From vnpy_crypto with MIT License | 5 votes |
def setuptools_run(self): """ The setuptools version of the .run() method. We must pull in the entire code so we can override the level used in the _getframe() call since we wrap this call by one more level. """ from distutils.command.install import install as distutils_install # Explicit request for old-style install? Just do it if self.old_and_unmanageable or self.single_version_externally_managed: return distutils_install.run(self) # Attempt to detect whether we were called from setup() or by another # command. If we were called by setup(), our caller will be the # 'run_command' method in 'distutils.dist', and *its* caller will be # the 'run_commands' method. If we were called any other way, our # immediate caller *might* be 'run_command', but it won't have been # called by 'run_commands'. This is slightly kludgy, but seems to # work. # caller = sys._getframe(3) caller_module = caller.f_globals.get('__name__', '') caller_name = caller.f_code.co_name if caller_module != 'distutils.dist' or caller_name!='run_commands': # We weren't called from the command line or setup(), so we # should run in backward-compatibility mode to support bdist_* # commands. distutils_install.run(self) else: self.do_egg_install()
Example #23
Source File: install.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def do_egg_install(self): easy_install = self.distribution.get_command_class('easy_install') cmd = easy_install( self.distribution, args="x", root=self.root, record=self.record, ) cmd.ensure_finalized() # finalize before bdist_egg munges install cmd cmd.always_copy_from = '.' # make sure local-dir eggs get installed # pick up setup-dir .egg files only: no .egg-info cmd.package_index.scan(glob.glob('*.egg')) self.run_command('bdist_egg') args = [self.distribution.get_command_obj('bdist_egg').egg_output] if setuptools.bootstrap_install_from: # Bootstrap self-installation of setuptools args.insert(0, setuptools.bootstrap_install_from) cmd.args = args cmd.run() setuptools.bootstrap_install_from = None # XXX Python 3.1 doesn't see _nc if this is inside the class
Example #24
Source File: install.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def run(self): # Explicit request for old-style install? Just do it if self.old_and_unmanageable or self.single_version_externally_managed: return orig.install.run(self) if not self._called_from_setup(inspect.currentframe()): # Run in backward-compatibility mode to support bdist_* commands. orig.install.run(self) else: self.do_egg_install()
Example #25
Source File: install.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def handle_extra_path(self): if self.root or self.single_version_externally_managed: # explicit backward-compatibility mode, allow extra_path to work return orig.install.handle_extra_path(self) # Ignore extra_path when installing an egg (or being run by another # command without --root or --single-version-externally-managed self.path_file = None self.extra_dirs = ''
Example #26
Source File: install.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def finalize_options(self): orig.install.finalize_options(self) if self.root: self.single_version_externally_managed = True elif self.single_version_externally_managed: if not self.root and not self.record: raise DistutilsArgError( "You must specify --record or --root when building system" " packages" )
Example #27
Source File: install.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
def initialize_options(self): orig.install.initialize_options(self) self.old_and_unmanageable = None self.single_version_externally_managed = None
Example #28
Source File: paths.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def get_install_command(name): # late binding due to potential monkeypatching d = dist.Distribution({'name':name}) i = install.install(d) i.finalize_options() return i
Example #29
Source File: install.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def setuptools_run(self): """ The setuptools version of the .run() method. We must pull in the entire code so we can override the level used in the _getframe() call since we wrap this call by one more level. """ from distutils.command.install import install as distutils_install # Explicit request for old-style install? Just do it if self.old_and_unmanageable or self.single_version_externally_managed: return distutils_install.run(self) # Attempt to detect whether we were called from setup() or by another # command. If we were called by setup(), our caller will be the # 'run_command' method in 'distutils.dist', and *its* caller will be # the 'run_commands' method. If we were called any other way, our # immediate caller *might* be 'run_command', but it won't have been # called by 'run_commands'. This is slightly kludgy, but seems to # work. # caller = sys._getframe(3) caller_module = caller.f_globals.get('__name__', '') caller_name = caller.f_code.co_name if caller_module != 'distutils.dist' or caller_name!='run_commands': # We weren't called from the command line or setup(), so we # should run in backward-compatibility mode to support bdist_* # commands. distutils_install.run(self) else: self.do_egg_install()
Example #30
Source File: install.py From lambda-chef-node-cleanup with Apache License 2.0 | 5 votes |
def handle_extra_path(self): if self.root or self.single_version_externally_managed: # explicit backward-compatibility mode, allow extra_path to work return orig.install.handle_extra_path(self) # Ignore extra_path when installing an egg (or being run by another # command without --root or --single-version-externally-managed self.path_file = None self.extra_dirs = ''