Exemplo n.º 1
0
 def distribution_changed(self, path):
     """Distribution path has just changed"""
     for package in self.table.model.packages:
         self.table.remove_package(package)
     dist = wppm.Distribution(to_text_string(path))
     self.table.refresh_distribution(dist)
     self.untable.refresh_distribution(dist)
     self.distribution = dist
     self.selector.label.setText('Python %s %dbit:' %
                                 (dist.version, dist.architecture))
def info():
    import sys, platform, re
    from os import path

    print("Welcome to Scpy2")
    print("Python:", platform.python_version())
    print("executable:", path.abspath(sys.executable))

    try:
        patterns = r"numpy.*|scipy.*|sympy.*|pandas.*|opencv.*|ets.*|cython.*|matplotlib.*"
        from winpython import wppm
        dist = wppm.Distribution(sys.prefix)
        for package in dist.get_installed_packages():
            if re.match(patterns, package.name, flags=re.IGNORECASE):
                print("{:20s}: {}".format(package.name, package.version))
    except ImportError:
        pass
Exemplo n.º 3
0
    def make(self, remove_existing=True):
        """Make WinPython distribution in target directory from the installers
        located in wheeldir

        remove_existing=True: (default) install all from scratch
        remove_existing=False: only for test purpose (launchers/scripts)"""
        if self.simulation:
            print("WARNING: this is just a simulation!", file=sys.stderr)

        self.python_fname = self.get_package_fname(
                            r'python-([0-9\.rc]*)(\.amd64)?\.msi')
        self.python_name = osp.basename(self.python_fname)[:-4]
        distname = 'win%s' % self.python_name
        vlst = re.match(r'winpython-([0-9\.]*)', distname
                        ).groups()[0].split('.')
        self.python_version = '.'.join(vlst[:2])
        self.python_fullversion = '.'.join(vlst[:3])

        # Create the WinPython base directory
        self._print("Creating WinPython %s base directory"
                    % self.python_version)
        self.winpydir = osp.join(self.target, distname)
        if osp.isdir(self.winpydir) and remove_existing \
           and not self.simulation:
            shutil.rmtree(self.winpydir, onerror=utils.onerror)
        if not osp.isdir(self.winpydir):
            os.mkdir(self.winpydir)
        if remove_existing and not self.simulation:
            # Create settings directory
            # (only necessary if user is starting an application with a batch
            #  scripts before using an executable launcher, because the latter
            #  is creating the directory automatically)
            os.mkdir(osp.join(self.winpydir, 'settings'))
        self._print_done()

        if remove_existing and not self.simulation:
            self._extract_python()
        self.distribution = wppm.Distribution(self.python_dir,
                                              verbose=self.verbose,
                                              indent=True)

        self._check_packages()

        if remove_existing:
            if not self.simulation:
                self._add_msvc_files()
            if not self.simulation:
                self._create_batch_scripts_initial()
                self._run_complement_batch_scripts("run_required_first.bat")
            self._install_required_packages()
            self._install_all_other_packages()
            if not self.simulation:
                self._copy_dev_tools()
                self._copy_dev_docs()
        if not self.simulation:
            self._create_launchers()
            self._create_batch_scripts()
            self._run_complement_batch_scripts()

        if remove_existing and not self.simulation:
            self._print("Cleaning up distribution")
            self.distribution.clean_up()
            self._print_done()

        # Writing package index
        self._print("Writing package index")
        fname = osp.join(self.winpydir, os.pardir,
                         'WinPython%s-%s.txt' % (self.flavor, self.winpyver))
        open(fname, 'w').write(self.package_index_wiki)
        # Copy to winpython/changelogs
        shutil.copyfile(fname, osp.join(CHANGELOGS_DIR, osp.basename(fname)))
        self._print_done()

        # Writing changelog
        self._print("Writing changelog")
        diff.write_changelog(self.winpyver, rootdir=self.rootdir,
                             flavor=self.flavor)
        self._print_done()
Exemplo n.º 4
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)
Exemplo n.º 5
0
    def make(self, remove_existing=True, requirements=None, my_winpydir=None):  #, find_links=None):
        """Make WinPython distribution in target directory from the installers
        located in wheeldir

        remove_existing=True: (default) install all from scratch
        remove_existing=False: only for test purpose (launchers/scripts)
        requirements=file(s) of requirements (separated by space if several)"""
        if self.simulation:
            print("WARNING: this is just a simulation!", file=sys.stderr)

        self.python_fname = self.get_package_fname(
                            r'python-([0-9\.rc]*)((\.|\-)amd64)?\.(msi|zip)')
        self.python_name = osp.basename(self.python_fname)[:-4]
        distname = 'win%s' % self.python_name
        vlst = re.match(r'winpython-([0-9\.]*)', distname
                        ).groups()[0].split('.')
        self.python_version = '.'.join(vlst[:2])
        self.python_fullversion = '.'.join(vlst[:3])
        print(self.python_fname,self.python_name , distname, self.python_version, self.python_fullversion)
        # Create the WinPython base directory
        self._print("Creating WinPython %s base directory"
                    % self.python_version)
        if my_winpydir is None:        
            self.winpydir = osp.join(self.target, distname)  
        else: 
            self.winpydir = osp.join(self.target, my_winpydir)
        if osp.isdir(self.winpydir) and remove_existing \
           and not self.simulation:
            shutil.rmtree(self.winpydir, onerror=utils.onerror)
        if not osp.isdir(self.winpydir):
            os.mkdir(self.winpydir)
        if remove_existing and not self.simulation:
            # Create settings directory
            # (only necessary if user is starting an application with a batch
            #  scripts before using an executable launcher, because the latter
            #  is creating the directory automatically)
            os.mkdir(osp.join(self.winpydir, 'settings'))
        self._print_done()

        if remove_existing and not self.simulation:
            self._extract_python()
        self.distribution = wppm.Distribution(self.python_dir,
                                              verbose=self.verbose,
                                              indent=True)

        self._check_packages()

        if remove_existing:
            if not self.simulation:
                self._add_msvc_files()
            if not self.simulation:
                self._create_batch_scripts_initial()
                self._create_batch_scripts()  # which set mingwpy as compiler
                self._run_complement_batch_scripts("run_required_first.bat")
                # launchers at the beginning
                self._create_launchers()


            # pre-patch current pip (until default python has pip 8.0.3)
            self.distribution.patch_standard_packages('pip')
            # force update of pip (FIRST) and setuptools here
            for req in ('pip', 'setuptools'):   
                actions = ["install","--upgrade", "--force-reinstall", req]
                if self.install_options is not None:
                    actions += self.install_options
                print("piping %s" % ' '.join(actions))
                self._print("piping %s" % ' '.join(actions))
                self.distribution.do_pip_action(actions)
                self.distribution.patch_standard_packages(req)
                
            # install packages in source_dirs (not using requirements.txt)
            self._install_all_other_packages()
            if not self.simulation:
                self._copy_dev_tools()
                self._copy_dev_docs()
        if not self.simulation:

            if requirements:
                if not list(requirements)==requirements:
                    requirements = requirements.split()
                for req in requirements:
                    actions = ["install","-r", req]
                    if self.install_options is not None:
                        actions += self.install_options
                    print("piping %s" % ' '.join(actions))
                    self._print("piping %s" % ' '.join(actions))
                    self.distribution.do_pip_action(actions)
                    #actions=["install","-r", req, "--no-index",
                    #         "--trusted-host=None"]+ links,
                    #         install_options=None)

            self._run_complement_batch_scripts()  # run_complement.bat
            self.distribution.patch_standard_packages()

        if remove_existing and not self.simulation:
            self._print("Cleaning up distribution")
            self.distribution.clean_up()
            self._print_done()

        # Writing package index
        self._print("Writing package index")
        # winpyver2 = need the version without build part
        self.winpyver2 = '%s.%s' % (self.python_fullversion, self.build_number)
        fname = osp.join(self.winpydir, os.pardir,
                         'WinPython%s-%s.md' % (self.flavor, self.winpyver2))
        open(fname, 'w').write(self.package_index_wiki)
        # Copy to winpython/changelogs
        shutil.copyfile(fname, osp.join(CHANGELOGS_DIR, osp.basename(fname)))
        self._print_done()

        # Writing changelog
        self._print("Writing changelog")
        diff.write_changelog(self.winpyver2, basedir=self.basedir,
                             flavor=self.flavor, release_level=self.release_level)
        self._print_done()