Example #1
0
 def add_packages(self, fnames):
     """Add packages"""
     notsupported = []
     notcompatible = []
     dist = self.distribution
     for fname in fnames:
         bname = osp.basename(fname)
         try:
             package = wppm.Package(fname)
             if package.is_compatible_with(dist):
                 self.add_package(package)
             else:
                 notcompatible.append(bname)
         except NotImplementedError:
             notsupported.append(bname)
     self.emit(SIGNAL('package_added()'))
     if notsupported:
         QMessageBox.warning(
             self, "Warning", "The following packages are <b>not (yet) "
             "supported</b> by %s:\n\n%s" %
             (self.winname, "<br>".join(notsupported)), QMessageBox.Ok)
     if notcompatible:
         QMessageBox.warning(
             self, "Warning", "The following packages "
             "are <b>not compatible</b> with "
             "Python <u>%s %dbit</u>:\n\n%s" %
             (dist.version, dist.architecture, "<br>".join(notcompatible)),
             QMessageBox.Ok)
Example #2
0
 def _check_packages(self):
     """Check packages for duplicates or unsupported packages"""
     print("Checking packages")
     packages = []
     my_plist = []
     my_plist += os.listdir(self.wheeldir)
     for fname0 in my_plist:
         fname = self.get_package_fname(fname0)
         if fname == self.python_fname:
             continue
         try:
             pack = wppm.Package(fname)
         except NotImplementedError:
             print("WARNING: package %s is not supported"
                   % osp.basename(fname), file=sys.stderr)
             continue
         packages.append(pack)
     all_duplicates = []
     for pack in packages:
         if pack.name in all_duplicates:
             continue
         all_duplicates.append(pack.name)
         duplicates = [p for p in packages if p.name == pack.name]
         if len(duplicates) > 1:
             print("WARNING: duplicate packages %s (%s)" %
                   (pack.name, ", ".join([p.version for p in duplicates])),
                   file=sys.stderr)
Example #3
0
 def install_package(self, pattern):
     """Install package matching pattern"""
     fname = self.get_package_fname(pattern)
     if fname not in [p.fname for p in self.installed_packages]:
         pack = wppm.Package(fname)
         if self.simulation:
             self.distribution._print(pack, "Installing")
             self.distribution._print_done()
         else:
             self.distribution.install(pack)
         self.installed_packages.append(pack)
Example #4
0
def test_python_packages(pyver):
    """Check if all Python packages are supported by WinPython"""
    basedir = utils.get_basedir(pyver)
    for suffix in ('src', 'win32', 'win-amd64'):
        dirname = osp.join(basedir, 'packages.%s' % suffix)
        for name in os.listdir(dirname):
            if osp.isfile(osp.join(dirname, name)) \
               and not re.match(r'python-([0-9\.]*)(\.amd64)?\.msi', name):
                try:
                    print(wppm.Package(name))
                    print('')
                except:
                    print('failed: %s' % name, file=sys.stderr)
Example #5
0
except:
    raise Exception(("Unable to retrieve on the server the filename "
                     "of the installer."))

# Generate the local path of the downloaded file.
# TEMPDIR = tempfile.mkdtemp()
# localpath = os.path.join(TEMPDIR, "{0:s}".format(filename))
localpath = os.path.join(APPDIR, "downloads/{0:s}".format(filename))

# Download the file and save it.
url = os.path.join(BASEURL, filename)
print("Downloading {0:s}...".format(url), end=' ')
try:
    with open(localpath, 'wb') as f:
        f.write(urllib2.urlopen(url).read())
except:
    raise Exception("Unable to download the file to {0:s}.".format(localpath))
print("Done!")

# Install the package.
print("Installing the distribution...", end=' ')
try:
    dist = wppm.Distribution(sys.prefix)
    package = wppm.Package(localpath)
    dist.install(package)
except:
    raise Exception("Unable to install the package.")
print("Done!")

time.sleep(1)