Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
props.append(("ARPURLINFOABOUT", metadata.url))
if props:
add_data(self.db, 'Property', props)
self.add_find_python()
self.add_files()
self.add_scripts()
self.add_ui()
self.db.Commit()
if hasattr(self.distribution, 'dist_files'):
tup = 'bdist_msi', self.target_version or 'any', fullname
self.distribution.dist_files.append(tup)
if not self.keep_temp:
log.info("removing temporary build directory %s", self.bdist_dir)
if not self.dry_run:
rmtree(self.bdist_dir)
error = _move_file(file_, tmpfile)
if error is not None:
success = False
break
finally:
if not os.path.isfile(file_):
os.rename(tmpfile, file_)
if file_ not in rmfiles:
rmfiles.append(file_)
if dirname not in rmdirs:
rmdirs.append(dirname)
finally:
shutil.rmtree(tmp)
if not success:
logger.info('%r cannot be removed.', project_name)
logger.info('Error: %s', error)
return False
logger.info('Removing %r: ', project_name)
for file_ in rmfiles:
logger.info(' %s', file_)
# Taken from the pip project
if auto_confirm:
response = 'y'
else:
response = ask('Proceed (y/n)? ', ('y', 'n'))
if response == 'y':
file_count = 0
if hooks is None:
return
for hook in hooks.values():
if isinstance(hook, str):
try:
hook_obj = resolve_name(hook)
except ImportError as e:
raise PackagingModuleError(e)
else:
hook_obj = hook
if not callable(hook_obj):
raise PackagingOptionError('hook %r is not callable' % hook)
logger.info('running %s %s for command %s',
hook_kind, hook, cmd_obj.get_command_name())
hook_obj(cmd_obj)
else:
encoding, lines = detect_encoding(f.readline)
f.seek(0)
first_line = f.readline()
if not first_line:
logger.warning('%s: %s is an empty file (skipping)',
self.get_command_name(), script)
continue
match = first_line_re.match(first_line)
if match:
adjust = True
post_interp = match.group(1) or b''
if adjust:
logger.info("copying and adjusting %s -> %s", script,
self.build_dir)
if not self.dry_run:
if not sysconfig.is_python_build():
executable = self.executable
else:
executable = os.path.join(
sysconfig.get_config_var("BINDIR"),
"python%s%s" % (sysconfig.get_config_var("VERSION"),
sysconfig.get_config_var("EXE")))
executable = os.fsencode(executable)
shebang = b"#!" + executable + post_interp + b"\n"
# Python parser starts to read a script using UTF-8 until
# it gets a #coding:xxx cookie. The shebang has to be the
# first line of a file, the #coding:xxx cookie cannot be
# written before. So the shebang has to be decodable from
# UTF-8.
def main(args=None):
old_level = logger.level
old_handlers = list(logger.handlers)
try:
dispatcher = Dispatcher(args)
if dispatcher.action is None:
return
return dispatcher()
except KeyboardInterrupt:
logger.info('interrupted')
return 1
except (IOError, os.error, PackagingError, CCompilerError) as exc:
logger.exception(exc)
return 1
finally:
logger.setLevel(old_level)
logger.handlers[:] = old_handlers
def _run_install_from_dir(source_dir):
old_dir = os.getcwd()
os.chdir(source_dir)
install_method = get_install_method(source_dir)
func = install_methods[install_method]
try:
func = install_methods[install_method]
try:
func(source_dir)
return True
except ValueError as err:
# failed to install
logger.info(str(err))
return False
finally:
os.chdir(old_dir)
def dump_file(filename, head=None):
"""Dumps a file content into log.info.
If head is not None, will be dumped before the file content.
"""
if head is None:
logger.info(filename)
else:
logger.info(head)
with open(filename) as file:
logger.info(file.read())
def build_libraries(self, libraries):
for lib_name, build_info in libraries:
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
raise PackagingSetupError(("in 'libraries' option (library '%s'), " +
"'sources' must be present and must be " +
"a list of source filenames") % lib_name)
sources = list(sources)
logger.info("building '%s' library", lib_name)
# First, compile the source code to object files in the library
# directory. (This should probably change to putting object
# files in a temporary build directory.)
macros = build_info.get('macros')
include_dirs = build_info.get('include_dirs')
objects = self.compiler.compile(sources,
output_dir=self.build_temp,
macros=macros,
include_dirs=include_dirs,
debug=self.debug)
# Now "link" the object files together into a static library.
# (On Unix at least, this isn't really linking -- it just
# builds an archive. Whatever.)
self.compiler.create_static_lib(objects, lib_name,