Example #1
0
remote.setup(config.remote)

# Get remote python session
remote_python = remote.start_python_session(assume_pts=False)

# Get all python packages installed on the remote host
remote_packages = remote_python.installed_packages

# Get local python package version
local_packages = introspection.installed_python_packages()

# Loop over all python packages necessary for PTS
for dependency in introspection.get_all_dependencies():

    # Skip standard modules
    if introspection.is_std_lib(dependency): continue

    # Check present and version locally
    if dependency in local_packages:
        locally_present = True
        local_version = local_packages[dependency]
    else:
        # Check again for present by importing
        locally_present = introspection.is_present_package(dependency)
        local_version = None

    # Check present and version remotely
    if dependency in remote_packages:
        remotely_present = True
        remote_version = remote_packages[dependency]
    else:
Example #2
0
        introspection.add_dependencies(dependencies, configuration_module_path,
                                       encountered)
        introspection.add_dependencies(dependencies, class_module_path,
                                       encountered)

# Get the names and versions of all installed python packages
packages = introspection.installed_python_packages()

# Loop over the packages and report their presence
for dependency in sorted(dependencies, key=str.lower):

    # Get the list of PTS scripts for this dependency
    script_list = dependencies[dependency]

    # Skip packages from the standard library, unless the appropriate flag is enabled
    if introspection.is_std_lib(dependency) and not arguments.standard:
        continue

    # Check presency and version
    if dependency in packages:
        present = True
        if arguments.version: version = packages[dependency]
    else:
        present = introspection.is_present_package(dependency)
        version = None

    # Check whether the current package is present
    if present:

        # Show package name, whether it's present and version number (if requested)
        if version is not None:
Example #3
0
remote.setup(config.remote)

# Get remote python session
remote_python = remote.start_python_session(assume_pts=False)

# Get all python packages installed on the remote host
remote_packages = remote_python.installed_packages

# Get local python package version
local_packages = introspection.installed_python_packages()

# Loop over all python packages necessary for PTS
for dependency in introspection.get_all_dependencies():

    # Skip standard modules
    if introspection.is_std_lib(dependency): continue

    # Check present and version locally
    if dependency in local_packages:
        locally_present = True
        local_version = local_packages[dependency]
    else:
        # Check again for present by importing
        locally_present = introspection.is_present_package(dependency)
        local_version = None

    # Check present and version remotely
    if dependency in remote_packages:
        remotely_present = True
        remote_version = remote_packages[dependency]
    else:
Example #4
0
    def check_dependencies(self):
        """
        This function ...
        :return:
        """

        # Get the names and versions of all installed python packages
        packages = introspection.installed_python_packages()

        # Get the names of the packages available through Canopy
        if self.config.canopy:

            url = "https://www.enthought.com/products/canopy/package-index/"

            # Try importing lxml
            try:
                from lxml import html
            except Exception:
                raise RuntimeError(
                    "You need the 'lxml' package to be able to specify the '--canopy' option"
                )

            # Try importing requests
            try:
                import requests
            except Exception:
                raise RuntimeError(
                    "You need the 'requests' pacakge to be able to specify the '--canopy' option"
                )

            page_as_string = requests.get(url).content
            tree = html.fromstring(page_as_string)

            tables = [e for e in tree.iter() if e.tag == 'table']
            table = tables[-1]

            table_rows = [e for e in table.iter() if e.tag == 'tr']
            column_headings = [
                e.text_content() for e in table_rows[0].iter() if e.tag == 'th'
            ]

            canopy_packages = []

            for row in table_rows[1:]:
                name = row[0].text_content().strip()
                canopy_packages.append(name.lower())

        else:
            canopy_packages = None

        # Loop over the packages and check their presence
        for dependency in sorted(self.dependencies, key=str.lower):

            # Get the list of PTS scripts for this dependency
            script_list = self.dependencies[dependency]

            # print(script_list)

            # Skip packages from the standard library, unless the appropriate flag is enabled
            if introspection.is_std_lib(
                    dependency) and not self.config.standard:
                continue

            # Check presency and version
            if dependency in packages:
                present = True
                version = packages[dependency] if self.config.version else None
            else:
                present = introspection.is_present_package(dependency)
                version = None

            if present: self.present_dependencies.append(dependency)
            else: self.not_present_dependencies.append(dependency)

            # Check whether the package is available through Canopy
            in_canopy = dependency.lower(
            ) in canopy_packages if canopy_packages is not None else None

            # Check whether the package is available through pip
            if self.config.pip:

                from pts.core.tools.pypi import search
                results = list(search(dependency))
                in_pip = False
                for result in results:
                    if result["name"] == dependency:
                        in_pip = True
                        break
            else:
                in_pip = None

            # Check whether the package is available through conda
            if self.config.conda:

                from ..tools import conda
                results = conda.search(dependency)

                if len(results) > 0: in_conda = True
                else: in_conda = False

            else: in_conda = False

            # Get description
            if self.config.description:

                from pts.core.tools.pypi import search
                results = list(search(dependency))
                description = None
                for result in results:
                    if result["name"] == dependency:
                        description = result["summary"]
                        if description.lower().startswith(dependency.lower() +
                                                          ": "):                            description = \
description.split(": ")[1]
                        break
            else:
                description = None

            self.data[dependency] = [
                script_list, present, version, in_canopy, in_pip, in_conda,
                description
            ]
Example #5
0
        encountered = set()
        introspection.add_dependencies(dependencies, logging_path, encountered)
        introspection.add_dependencies(dependencies, configuration_module_path, encountered)
        introspection.add_dependencies(dependencies, class_module_path, encountered)

# Get the names and versions of all installed python packages
packages = introspection.installed_python_packages()

# Loop over the packages and report their presence
for dependency in sorted(dependencies, key=str.lower):

    # Get the list of PTS scripts for this dependency
    script_list = dependencies[dependency]

    # Skip packages from the standard library, unless the appropriate flag is enabled
    if introspection.is_std_lib(dependency) and not arguments.standard: continue

    # Check presency and version
    if dependency in packages:
        present = True
        if arguments.version: version = packages[dependency]
    else:
        present = introspection.is_present_package(dependency)
        version = None

    # Check whether the current package is present
    if present:

        # Show package name, whether it's present and version number (if requested)
        if version is not None: log.success(dependency + ": present (version " + version + ")")
        else: log.success(dependency + ": present")
Example #6
0
    def check_dependencies(self):

        """
        This function ...
        :return:
        """

        # Get the names and versions of all installed python packages
        packages = introspection.installed_python_packages()

        # Get the names of the packages available through Canopy
        if self.config.canopy:

            url = "https://www.enthought.com/products/canopy/package-index/"

            # Try importing lxml
            try: from lxml import html
            except Exception:
                raise RuntimeError("You need the 'lxml' package to be able to specify the '--canopy' option")

            # Try importing requests
            try: import requests
            except Exception:
                raise RuntimeError("You need the 'requests' pacakge to be able to specify the '--canopy' option")

            page_as_string = requests.get(url).content
            tree = html.fromstring(page_as_string)

            tables = [e for e in tree.iter() if e.tag == 'table']
            table = tables[-1]

            table_rows = [e for e in table.iter() if e.tag == 'tr']
            column_headings = [e.text_content() for e in table_rows[0].iter() if e.tag == 'th']

            canopy_packages = []

            for row in table_rows[1:]:
                name = row[0].text_content().strip()
                canopy_packages.append(name.lower())

        else: canopy_packages = None

        # Loop over the packages and check their presence
        for dependency in sorted(self.dependencies, key=str.lower):

            # Get the list of PTS scripts for this dependency
            script_list = self.dependencies[dependency]

            # print(script_list)

            # Skip packages from the standard library, unless the appropriate flag is enabled
            if introspection.is_std_lib(dependency) and not self.config.standard: continue

            # Check presency and version
            if dependency in packages:
                present = True
                version = packages[dependency] if self.config.version else None
            else:
                present = introspection.is_present_package(dependency)
                version = None

            if present: self.present_dependencies.append(dependency)
            else: self.not_present_dependencies.append(dependency)

            # Check whether the package is available through Canopy
            in_canopy = dependency.lower() in canopy_packages if canopy_packages is not None else None

            # Check whether the package is available through pip
            if self.config.pip:

                from pts.core.tools.pypi import search
                results = list(search(dependency))
                in_pip = False
                for result in results:
                    if result["name"] == dependency:
                        in_pip = True
                        break
            else: in_pip = None

            # Check whether the package is available through conda
            if self.config.conda:

                from ..tools import conda
                results = conda.search(dependency)

                if len(results) > 0: in_conda = True
                else: in_conda = False

            else: in_conda = False

            # Get description
            if self.config.description:

                from pts.core.tools.pypi import search
                results = list(search(dependency))
                description = None
                for result in results:
                    if result["name"] == dependency:
                        description = result["summary"]
                        if description.lower().startswith(dependency.lower() + ": "): description = \
                        description.split(": ")[1]
                        break
            else: description = None

            self.data[dependency] = [script_list, present, version, in_canopy, in_pip, in_conda, description]