X Tutup
Skip to content

Commit f070c8f

Browse files
author
stonebig
committed
cleanup wppm launcher
1 parent 96831de commit f070c8f

File tree

4 files changed

+71
-88
lines changed

4 files changed

+71
-88
lines changed

scripts/wppm

Lines changed: 0 additions & 48 deletions
This file was deleted.

scripts/wppm.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ def get_subpackages(name):
6565
'.html', '.js', '.ini')), },
6666
# requires=["PyQt4 (>=4.5)"],
6767
scripts=[osp.join('scripts', fname) for fname in
68-
('register_python', 'register_python.bat',
69-
'wppm', 'wppm.bat')],
68+
('register_python', 'register_python.bat')],
7069
# use setuptools functionalities
7170
entry_points={
7271
'console_scripts': [
7372
'wpcp = winpython.controlpanel:main',
73+
'wppm = winpython.wppm:main',
7474
]
7575
},
7676
classifiers=['License :: OSI Approved :: MIT License',

winpython/wppm.py

Lines changed: 69 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
from winpython.config import DATA_PATH
2525
from winpython.py3compat import configparser as cp
2626

27+
# from former wppm separate script launcher
28+
from argparse import ArgumentParser
29+
from winpython import py3compat
30+
31+
2732
# Workaround for installing PyVISA on Windows from source:
2833
os.environ['HOME'] = os.environ['USERPROFILE']
2934

@@ -645,41 +650,69 @@ def install_nsis_package(self, package):
645650
self.copy_files(package, targetdir, '$_OUTDIR', outdir)
646651
self._print_done()
647652

648-
649-
if __name__ == '__main__':
650-
sbdir = osp.join(osp.dirname(__file__),
653+
def main(test=False):
654+
if test:
655+
sbdir = osp.join(osp.dirname(__file__),
651656
os.pardir, os.pardir, os.pardir, 'sandbox')
652-
tmpdir = osp.join(sbdir, 'tobedeleted')
653-
654-
# for fname in os.listdir(sbdir):
655-
# try:
656-
# ins = Installation(fname)
657-
# print fname, '--->', ins.name, ins.version, ins.architecture
658-
# except NotImplementedError:
659-
# pass
660-
661-
# fname = osp.join(tmpdir, 'scipy-0.10.1.win-amd64-py2.7.exe')
662-
fname = osp.join(sbdir, 'Cython-0.16.win-amd64-py2.7.exe')
663-
fname = osp.join(sbdir, 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe')
664-
fname = osp.join(sbdir, 'scikits.timeseries-0.91.3.win32-py2.7.exe')
665-
print(Package(fname))
666-
sys.exit()
667-
# fname = osp.join(sbdir, 'pylzma-0.4.4dev.win-amd64-py2.7.exe')
668-
# fname = osp.join(sbdir, 'cx_Freeze-4.3.win-amd64-py2.6.exe')
669-
# fname = osp.join(sbdir, 'PyQtdoc-4.7.2.win-amd64.exe')
670-
# fname = osp.join(sbdir, 'winpython-0.1dev.win-amd64.exe')
671-
target = osp.join(sbdir, 'winpython-2.7.3.amd64', 'python-2.7.3.amd64')
672-
673-
target = osp.join(utils.BASE_DIR, 'build',
657+
tmpdir = osp.join(sbdir, 'tobedeleted')
658+
659+
# fname = osp.join(tmpdir, 'scipy-0.10.1.win-amd64-py2.7.exe')
660+
fname = osp.join(sbdir, 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe')
661+
print(Package(fname))
662+
sys.exit()
663+
target = osp.join(utils.BASE_DIR, 'build',
674664
'winpython-2.7.3', 'python-2.7.3')
675-
# fname = osp.join(utils.BASE_DIR, 'packages.src', 'docutils-0.9.1.tar.gz')
676-
fname = osp.join(utils.BASE_DIR, 'packages.win32',
677-
'PyQt-Py2.7-x32-gpl-4.8.6-1.exe')
678-
fname = osp.join(utils.BASE_DIR, 'packages.win32',
679-
'scikits-image-0.6.1.win32-py2.7.exe')
680-
681-
dist = Distribution(target, verbose=True)
682-
pack = Package(fname)
683-
print(pack.description)
684-
# dist.install(pack)
685-
# dist.uninstall(pack)
665+
fname = osp.join(utils.BASE_DIR, 'packages.src', 'docutils-0.9.1.tar.gz')
666+
667+
dist = Distribution(target, verbose=True)
668+
pack = Package(fname)
669+
print(pack.description)
670+
# dist.install(pack)
671+
# dist.uninstall(pack)
672+
else:
673+
674+
parser = ArgumentParser(description="WinPython Package Manager: install, "\
675+
"uninstall or upgrade Python packages on a Windows "\
676+
"Python distribution like WinPython.")
677+
parser.add_argument('fname', metavar='package',
678+
type=str if py3compat.PY3 else unicode,
679+
help='path to a Python package')
680+
parser.add_argument('-t', '--target', dest='target', default=sys.prefix,
681+
help='path to target Python distribution '\
682+
'(default: "%s")' % sys.prefix)
683+
parser.add_argument('-i', '--install', dest='install',
684+
action='store_const', const=True, default=False,
685+
help='install package (this is the default action)')
686+
parser.add_argument('-u', '--uninstall', dest='uninstall',
687+
action='store_const', const=True, default=False,
688+
help='uninstall package')
689+
args = parser.parse_args()
690+
691+
if args.install and args.uninstall:
692+
raise RuntimeError("Incompatible arguments: --install and --uninstall")
693+
694+
if not args.install and not args.uninstall:
695+
args.install = True
696+
697+
if not osp.isfile(args.fname):
698+
raise IOError("File not found: %s" % args.fname)
699+
700+
if utils.is_python_distribution(args.target):
701+
dist = Distribution(args.target)
702+
try:
703+
package = Package(args.fname)
704+
if package.is_compatible_with(dist):
705+
if args.install:
706+
dist.install(package)
707+
else:
708+
dist.uninstall(package)
709+
else:
710+
raise RuntimeError("Package is not compatible with Python "\
711+
"%s %dbit" % (dist.version, dist.architecture))
712+
except NotImplementedError:
713+
raise RuntimeError("Package is not (yet) supported by WPPM")
714+
else:
715+
raise WindowsError("Invalid Python distribution %s" % args.target)
716+
717+
if __name__ == '__main__':
718+
main()

0 commit comments

Comments
 (0)
X Tutup