How to use the packaging.logger function in packaging

To help you get started, we’ve selected a few packaging examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github larryhastings / gilectomy / Lib / packaging / compiler / ccompiler.py View on Github external
def mkpath(self, name, mode=0o777):
        name = os.path.normpath(name)
        if os.path.isdir(name) or name == '':
            return
        if self.dry_run:
            head = ''
            for part in name.split(os.sep):
                logger.info("created directory %s%s", head, part)
                head += part + os.sep
            return
        os.makedirs(name, mode)
github larryhastings / gilectomy / Lib / packaging / command / install_dist.py View on Github external
"install-base/install-platbase -- not both")

        if self.home and (self.prefix or self.exec_prefix):
            raise PackagingOptionError(
                "must supply either home or prefix/exec-prefix -- not both")

        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")

        # Next, stuff that's wrong (or dubious) only on certain platforms.
        if os.name != "posix":
            if self.exec_prefix:
                logger.warning(
                    '%s: exec-prefix option ignored on this platform',
                    self.get_command_name())
                self.exec_prefix = None

        # Now the interesting logic -- so interesting that we farm it out
        # to other methods.  The goal of these methods is to set the final
        # values for the install_{lib,scripts,data,...}  options, using as
        # input a heady brew of prefix, exec_prefix, home, install_base,
        # install_platbase, user-supplied versions of
        # install_{purelib,platlib,lib,scripts,data,...}, and the
        # INSTALL_SCHEME dictionary above.  Phew!

        self.dump_dirs("pre-finalize_{unix,other}")

        if os.name == 'posix':
            self.finalize_unix()
github larryhastings / gilectomy / Lib / packaging / compiler / msvccompiler.py View on Github external
RegError = winreg.error

except ImportError:
    try:
        import win32api
        import win32con
        _can_read_reg = True
        hkey_mod = win32con

        RegOpenKeyEx = win32api.RegOpenKeyEx
        RegEnumKey = win32api.RegEnumKey
        RegEnumValue = win32api.RegEnumValue
        RegError = win32api.error

    except ImportError:
        logger.warning(
            "can't read registry to find the necessary compiler setting;\n"
            "make sure that Python modules _winreg, win32api or win32con "
            "are installed.")

if _can_read_reg:
    HKEYS = (hkey_mod.HKEY_USERS,
             hkey_mod.HKEY_CURRENT_USER,
             hkey_mod.HKEY_LOCAL_MACHINE,
             hkey_mod.HKEY_CLASSES_ROOT)


def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
github larryhastings / gilectomy / Lib / packaging / command / upload.py View on Github external
# send the data
        try:
            result = urlopen(request)
            status = result.code
            reason = result.msg
        except socket.error as e:
            logger.error(e)
            return
        except HTTPError as e:
            status = e.code
            reason = e.msg

        if status == 200:
            logger.info('Server response (%s): %s', status, reason)
        else:
            logger.error('Upload failed (%s): %s', status, reason)

        if self.show_response and logger.isEnabledFor(logging.INFO):
            sep = '-' * 75
            logger.info('%s\n%s\n%s', sep, result.read().decode(), sep)
github larryhastings / gilectomy / Lib / packaging / install.py View on Github external
metadata = release.fetch_metadata()

    # we need to build setuptools deps if any
    if 'requires_dist' not in metadata:
        metadata['requires_dist'] = _get_setuptools_deps(release)

    # build the dependency graph with local and required dependencies
    dists = list(installed)
    dists.append(release)
    depgraph = generate_graph(dists)

    # Get what the missing deps are
    dists = depgraph.missing[release]
    if dists:
        logger.info("Missing dependencies found, retrieving metadata")
        # we have missing deps
        for dist in dists:
            _update_infos(infos, get_infos(dist, index, installed))

    # Fill in the infos
    existing = [d for d in installed if d.name == release.name]
    if existing:
        infos['remove'].append(existing[0])
        infos['conflict'].extend(depgraph.reverse_list[existing[0]])
    infos['install'].append(release)
    return infos
github larryhastings / gilectomy / Lib / packaging / command / build_py.py View on Github external
if package_dir != "":
            if not os.path.exists(package_dir):
                raise PackagingFileError(
                      "package directory '%s' does not exist" % package_dir)
            if not os.path.isdir(package_dir):
                raise PackagingFileError(
                       "supposed package directory '%s' exists, "
                       "but is not a directory" % package_dir)

        # Require __init__.py for all but the "root package"
        if package:
            init_py = os.path.join(package_dir, "__init__.py")
            if os.path.isfile(init_py):
                return init_py
            else:
                logger.warning("package init file %r not found "
                               "(or not a regular file)", init_py)

        # Either not in a package at all (__init__.py not expected), or
        # __init__.py doesn't exist -- so don't return the filename.
        return None
github naftaliharris / tauthon / Lib / packaging / pypi / simple.py View on Github external
"""
        with self._open_url(url) as f:
            base_url = f.url
            if url not in self._processed_urls:
                self._processed_urls.append(url)
                link_matcher = self._get_link_matcher(url)
                for link, is_download in link_matcher(f.read().decode(), base_url):
                    if link not in self._processed_urls:
                        if self._is_distribution(link) or is_download:
                            self._processed_urls.append(link)
                            # it's a distribution, so create a dist object
                            try:
                                infos = get_infos_from_url(link, project_name,
                                            is_external=self.index_url not in url)
                            except CantParseArchiveName as e:
                                logger.warning(
                                    "version has not been parsed: %s", e)
                            else:
                                self._register_release(release_info=infos)
                        else:
                            if self._is_browsable(link) and follow_links:
                                self._process_url(link, project_name,
                                    follow_links=False)
github larryhastings / gilectomy / Lib / packaging / command / check.py View on Github external
def warn(self, msg, *args):
        """Wrapper around logging that also remembers messages."""
        # XXX we could use a special handler for this, but would need to test
        # if it works even if the logger has a too high level
        self._warnings.append((msg, args))
        return logger.warning('%s: %s' % (self.get_command_name(), msg), *args)
github larryhastings / gilectomy / Lib / packaging / run.py View on Github external
# XXX there's a bug somewhere: the help text says that -v is default
        # (and verbose is set to 1 above), but when the user explicitly gives
        # -v on the command line, self.verbose is incremented to 2!  Here we
        # compensate for that (I tested manually).  On a related note, I think
        # it's a good thing to use -q/nothing/-v/-vv on the command line
        # instead of logging constants; it will be easy to add support for
        # logging configuration in setup.cfg for advanced users. --merwok
        elif self.verbose in (1, 2):
            level = logging.INFO
        else:  # -vv and more for debug
            level = logging.DEBUG

        # setting up the stream handler
        handler = logging.StreamHandler(sys.stderr)
        handler.setLevel(level)
        logger.addHandler(handler)
        logger.setLevel(level)
github larryhastings / gilectomy / Lib / packaging / compiler / msvccompiler.py View on Github external
"""Set environment variable 'name' to an MSVC path type value.

        This is equivalent to a SET command prior to execution of spawned
        commands.
        """

        if name == "lib":
            p = self.get_msvc_paths("library")
        else:
            p = self.get_msvc_paths(name)
        if p:
            os.environ[name] = ';'.join(p)


if get_build_version() >= 8.0:
    logger.debug("importing new compiler from distutils.msvc9compiler")
    OldMSVCCompiler = MSVCCompiler
    from packaging.compiler.msvc9compiler import MSVCCompiler
    # get_build_architecture not really relevant now we support cross-compile
    from packaging.compiler.msvc9compiler import MacroExpander