Exemple #1
0
 def select_directory(self):
     """Select directory"""
     basedir = to_text_string(self.line_edit.text())
     if not osp.isdir(basedir):
         basedir = getcwd()
     while True:
         directory = getexistingdirectory(self, self.TITLE, basedir)
         if not directory:
             break
         if not utils.is_python_distribution(directory):
             QMessageBox.warning(self, self.TITLE,
                 "The following directory is not a Python distribution.",
                 QMessageBox.Ok)
             basedir = directory
             continue
         directory = osp.abspath(osp.normpath(directory))
         self.set_distribution(directory)
         self.emit(SIGNAL('selected_distribution(QString)'), directory)
         break
Exemple #2
0
def main(test=False):
    if test:
        sbdir = osp.join(osp.dirname(__file__), os.pardir, os.pardir,
                         os.pardir, 'sandbox')
        tmpdir = osp.join(sbdir, 'tobedeleted')

        # fname = osp.join(tmpdir, 'scipy-0.10.1.win-amd64-py2.7.exe')
        fname = osp.join(sbdir, 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe')
        print(Package(fname))
        sys.exit()
        target = osp.join(utils.BASE_DIR, 'build', 'winpython-2.7.3',
                          'python-2.7.3')
        fname = osp.join(utils.BASE_DIR, 'packages.src',
                         'docutils-0.9.1.tar.gz')

        dist = Distribution(target, verbose=True)
        pack = Package(fname)
        print(pack.description)
        # dist.install(pack)
        # dist.uninstall(pack)
    else:

        parser = ArgumentParser(description="WinPython Package Manager: install, "\
                        "uninstall or upgrade Python packages on a Windows "\
                        "Python distribution like WinPython.")
        parser.add_argument('fname',
                            metavar='package',
                            type=str if py3compat.PY3 else unicode,
                            help='path to a Python package')
        parser.add_argument('-t', '--target', dest='target', default=sys.prefix,
                    help='path to target Python distribution '\
                         '(default: "%s")' % sys.prefix)
        parser.add_argument(
            '-i',
            '--install',
            dest='install',
            action='store_const',
            const=True,
            default=False,
            help='install package (this is the default action)')
        parser.add_argument('-u',
                            '--uninstall',
                            dest='uninstall',
                            action='store_const',
                            const=True,
                            default=False,
                            help='uninstall package')
        args = parser.parse_args()

        if args.install and args.uninstall:
            raise RuntimeError(
                "Incompatible arguments: --install and --uninstall")

        if not args.install and not args.uninstall:
            args.install = True

        if not osp.isfile(args.fname) and args.install:
            raise IOError("File not found: %s" % args.fname)

        if utils.is_python_distribution(args.target):
            dist = Distribution(args.target)
            try:
                if args.uninstall:
                    package = dist.find_package(args.fname)
                    dist.uninstall(package)
                else:
                    package = Package(args.fname)
                    if args.install and package.is_compatible_with(dist):
                        dist.install(package)
                    else:
                        raise RuntimeError("Package is not compatible with Python "\
                               "%s %dbit" % (dist.version, dist.architecture))
            except NotImplementedError:
                raise RuntimeError("Package is not (yet) supported by WPPM")
        else:
            raise WindowsError("Invalid Python distribution %s" % args.target)
Exemple #3
0
def main(test=False):
    if test:
        sbdir = osp.join(osp.dirname(__file__),
                     os.pardir, os.pardir, os.pardir, 'sandbox')
        tmpdir = osp.join(sbdir, 'tobedeleted')

        # fname = osp.join(tmpdir, 'scipy-0.10.1.win-amd64-py2.7.exe')
        fname = osp.join(sbdir, 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe')
        print(Package(fname))
        sys.exit()
        target = osp.join(utils.BASE_DIR, 'build',
                      'winpython-2.7.3', 'python-2.7.3')
        fname = osp.join(utils.BASE_DIR, 'packages.src', 'docutils-0.9.1.tar.gz')

        dist = Distribution(target, verbose=True)
        pack = Package(fname)
        print(pack.description)
        # dist.install(pack)
        # dist.uninstall(pack)
    else:

        parser = ArgumentParser(description="WinPython Package Manager: install, "\
                        "uninstall or upgrade Python packages on a Windows "\
                        "Python distribution like WinPython.")
        parser.add_argument('fname', metavar='package',
                    type=str if py3compat.PY3 else unicode,
                    help='path to a Python package')
        parser.add_argument('-t', '--target', dest='target', default=sys.prefix,
                    help='path to target Python distribution '\
                         '(default: "%s")' % sys.prefix)
        parser.add_argument('-i', '--install', dest='install',
                    action='store_const', const=True, default=False,
                    help='install package (this is the default action)')
        parser.add_argument('-u', '--uninstall', dest='uninstall',
                    action='store_const', const=True, default=False,
                    help='uninstall package')
        args = parser.parse_args()

        if args.install and args.uninstall:
            raise RuntimeError("Incompatible arguments: --install and --uninstall")

        if not args.install and not args.uninstall:
            args.install = True

        if not osp.isfile(args.fname):
            raise IOError("File not found: %s" % args.fname)

        if utils.is_python_distribution(args.target):
            dist = Distribution(args.target)
            try:
                package = Package(args.fname)
                if package.is_compatible_with(dist):
                    if args.install:
                        dist.install(package)
                    else:
                        dist.uninstall(package)
                else:
                    raise RuntimeError("Package is not compatible with Python "\
                               "%s %dbit" % (dist.version, dist.architecture))
            except NotImplementedError:
                raise RuntimeError("Package is not (yet) supported by WPPM")
        else:
            raise WindowsError("Invalid Python distribution %s" % args.target)
Exemple #4
0
def main(test=False):
    if test:
        sbdir = osp.join(
            osp.dirname(__file__),
            os.pardir,
            os.pardir,
            os.pardir,
            'sandbox',
        )
        tmpdir = osp.join(sbdir, 'tobedeleted')

        # fname = osp.join(tmpdir, 'scipy-0.10.1.win-amd64-py2.7.exe')
        fname = osp.join(
            sbdir, 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe'
        )
        print(Package(fname))
        sys.exit()
        target = osp.join(
            utils.BASE_DIR,
            'build',
            'winpython-2.7.3',
            'python-2.7.3',
        )
        fname = osp.join(
            utils.BASE_DIR,
            'packages.src',
            'docutils-0.9.1.tar.gz',
        )

        dist = Distribution(target, verbose=True)
        pack = Package(fname)
        print(pack.description)
        # dist.install(pack)
        # dist.uninstall(pack)
    else:

        parser = ArgumentParser(
            description="WinPython Package Manager: view, install, "
            "uninstall or upgrade Python packages on a Windows "
            "Python distribution like WinPython."
        )
        parser.add_argument(
            'fname',
            metavar='package',
            type=str if py3compat.PY3 else unicode,
            help='path to a Python package, or package name',
        )
        parser.add_argument(
            '-t',
            '--target',
            dest='target',
            default=sys.prefix,
            help='path to target Python distribution '
            '(default: "%s")' % sys.prefix,
        )
        parser.add_argument(
            '-i',
            '--install',
            dest='install',
            action='store_const',
            const=True,
            default=False,
            help='install package (this is the default action)',
        )
        parser.add_argument(
            '-u',
            '--uninstall',
            dest='uninstall',
            action='store_const',
            const=True,
            default=False,
            help='uninstall package',
        )
        parser.add_argument(
            '-r',
            '--reverse-tree',
            dest='pipup',
            action='store_const',
            const=True,
            default=False,
            help='show reverse dependancies of the package',
        )
        parser.add_argument(
            '-p',
            '--package-tree',
            dest='pipdown',
            action='store_const',
            const=True,
            default=False,
            help='show  dependancies of the package',
        )    
        parser.add_argument(
            '-l',
            '--levels_of_depth',
            dest='levels_of_depth', 
            type=int, default=2,
            help='show  l levels_of_depth',
        )
        
        args = parser.parse_args()

        if args.install and args.uninstall:
            raise RuntimeError(
                "Incompatible arguments: --install and --uninstall"
            )
        if args.pipdown:
           pip = piptree.pipdata()
           pack, extra, *other =(args.fname +"[").replace(']','[').split("[")
           pip.down(pack, extra, args.levels_of_depth)
           sys.exit()
        elif args.pipup:
           pip = piptree.pipdata()
           pack, extra, *other =(args.fname +"[").replace(']','[').split("[")
           pip.up(pack, extra, args.levels_of_depth)
           sys.exit()
        elif not args.install and not args.uninstall:
            args.install = True
        if not osp.isfile(args.fname) and args.install:
            raise IOError("File not found: %s" % args.fname)
        if utils.is_python_distribution(args.target):
            dist = Distribution(args.target)
            try:
                if args.uninstall:
                    package = dist.find_package(args.fname)
                    dist.uninstall(package)
                else:
                    package = Package(args.fname)
                    if (
                        args.install
                        and package.is_compatible_with(dist)
                    ):
                        dist.install(package)
                    else:
                        raise RuntimeError(
                            "Package is not compatible with Python "
                            "%s %dbit"
                            % (
                                dist.version,
                                dist.architecture,
                            )
                        )
            except NotImplementedError:
                raise RuntimeError(
                    "Package is not (yet) supported by WPPM"
                )
        else:
            raise WindowsError(
                "Invalid Python distribution %s"
                % args.target
            )
import sys
from winpython import associate, utils
from argparse import ArgumentParser

parser = ArgumentParser(description="Register Python file extensions, icons "\
                        "and Windows explorer context menu to a target "\
                        "Python distribution.")
try:
    str_type = unicode
except NameError:
    str_type = str
parser.add_argument('--target',
                    metavar='path',
                    type=str,
                    default=sys.prefix,
                    help='path to the target Python distribution')
parser.add_argument('--all', dest='all', action='store_const',
                    const=True, default=False,
                    help='register to all users, requiring administrative '\
                         'privileges (default: register to current user only)')
args = parser.parse_args()

print(args.target)
if utils.is_python_distribution(args.target):
    associate.register(args.target, current=not args.all)
else:
    raise WindowsError("Invalid Python distribution %s" % args.target)
from winpython import associate, utils
from argparse import ArgumentParser

parser = ArgumentParser(
    description="Register Python file extensions, icons "
    "and Windows explorer context menu to a target "
    "Python distribution."
)
try:
    str_type = unicode
except NameError:
    str_type = str
parser.add_argument(
    "--target", metavar="path", type=str, default=sys.prefix, help="path to the target Python distribution"
)
parser.add_argument(
    "--all",
    dest="all",
    action="store_const",
    const=True,
    default=False,
    help="register to all users, requiring administrative " "privileges (default: register to current user only)",
)
args = parser.parse_args()

print(args.target)
if utils.is_python_distribution(args.target):
    associate.register(args.target, current=not args.all)
else:
    raise WindowsError("Invalid Python distribution %s" % args.target)