annotate quickinstall.py @ 2614:9d04f5a42445

Removed pep-8 error from MoinMoin/items/ticket.py
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Fri, 30 May 2014 11:54:44 +0530
parents 2c54228b0cbe
children 5f372df47c94
rev   line source
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
1 #!/usr/bin/python
2211
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
2 # Copyright: 2013 MoinMoin:BastianBlank
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
3 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
4 """
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
5 create a virtual environment and install moin2 (in development mode) and
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
6 its requirements.
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
7
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
8 needs: virtualenv, pip
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
9 """
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
10
2307
773f0e488722 dirty hack to support pip 1.5 incompatibilities, set PIP15=True in quickinstall.py if you need it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2306
diff changeset
11
2304
aaeb6bba4b0f fix #379 quickinstall.py fails with obscure error message
RogerHaase
parents: 2299
diff changeset
12 import MoinMoin # validate python version
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
13 import argparse
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
14 import logging
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
15 import os
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
16 import subprocess
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
17 import sys
2306
90a17c8544ad fix #379 part 2, replace traceback with error message
RogerHaase
parents: 2304
diff changeset
18 try:
90a17c8544ad fix #379 part 2, replace traceback with error message
RogerHaase
parents: 2304
diff changeset
19 import virtualenv
90a17c8544ad fix #379 part 2, replace traceback with error message
RogerHaase
parents: 2304
diff changeset
20 except ImportError:
90a17c8544ad fix #379 part 2, replace traceback with error message
RogerHaase
parents: 2304
diff changeset
21 sys.exit("""
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
22 Error: import virtualenv failed, either virtualenv is not installed (see installation docs)
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
23 or the virtual environment must be deactivated before rerunning quickinstall.py
2306
90a17c8544ad fix #379 part 2, replace traceback with error message
RogerHaase
parents: 2304
diff changeset
24 """)
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
25
2565
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
26 from make import Commands, WINDOWS_OS, M, ACTIVATE
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
27
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
28
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
29 WIN_INFO = 'm.bat, activate.bat, and deactivate.bat are created by quickinstall.py'
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
30 NIX_INFO = 'the m bash script and the activate symlink are created by quickinstall.py'
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
31
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
32
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
33 def create_m():
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
34 """Create an 'm.bat or 'm' bash script that will run make.py using this Python"""
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
35 if WINDOWS_OS:
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
36 with open('m.bat', 'w') as f:
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
37 f.write(':: {}\n\n@{} make.py %*\n'.format(WIN_INFO, sys.executable))
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
38 else:
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
39 with open('m', 'w') as f:
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
40 f.write('# {}\n\n{} make.py $*\n'.format(NIX_INFO, sys.executable))
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
41 os.fchmod(f.fileno(), 0775)
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
42
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
43
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
44 class QuickInstall(object):
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
45 def __init__(self, source, venv=None, download_cache=None):
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
46 self.dir_source = source
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
47 if venv is None:
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
48 base, source_name = os.path.split(source)
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
49 executable = os.path.basename(sys.executable).split('.exe')[0]
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
50 venv = os.path.join(base, '{}-venv-{}'.format(source_name, executable))
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
51 if download_cache is None:
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
52 # make cache sibling of ~/pip/pip.log or ~/.pip/pip.log
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
53 if WINDOWS_OS:
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
54 download_cache = '~/pip/pip-download-cache'
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
55 else:
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
56 # XXX: move cache to XDG cache dir
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
57 download_cache = '~/.pip/pip-download-cache'
2299
01dced4292d8 quickinstall: Use virtualenv path resoltion
Bastian Blank <bblank@thinkmo.de>
parents: 2211
diff changeset
58
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
59 venv = os.path.abspath(venv)
2299
01dced4292d8 quickinstall: Use virtualenv path resoltion
Bastian Blank <bblank@thinkmo.de>
parents: 2211
diff changeset
60 venv_home, venv_lib, venv_inc, venv_bin = virtualenv.path_locations(venv)
01dced4292d8 quickinstall: Use virtualenv path resoltion
Bastian Blank <bblank@thinkmo.de>
parents: 2211
diff changeset
61 self.dir_venv = venv_home
01dced4292d8 quickinstall: Use virtualenv path resoltion
Bastian Blank <bblank@thinkmo.de>
parents: 2211
diff changeset
62 self.dir_venv_bin = venv_bin
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
63 self.download_cache = os.path.normpath(os.path.expanduser(download_cache))
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
64
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
65 def __call__(self):
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
66 self.do_venv()
2565
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
67 self.do_helpers()
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
68 self.do_install()
2210
c5562f2a893c quickinstall: Again create catalogs for translations
Bastian Blank <bblank@thinkmo.de>
parents: 2206
diff changeset
69 self.do_catalog()
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
70
2211
69db40714019 quickinstall: docstring and docs update
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2210
diff changeset
71 sys.stdout.write("""
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
72 Pip cache location is at {0}
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
73
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
74 Successfully created or updated venv at {1}
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
75 """.format(self.download_cache, self.dir_venv))
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
76
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
77 def do_venv(self):
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
78 virtualenv.create_environment(self.dir_venv)
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
79
2565
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
80 def pip15_plus(self):
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
81 """Return true if pip version is >= 1.5"""
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
82 command = ACTIVATE + 'pip --version'
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
83 pip_txt = subprocess.check_output(command, shell=True)
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
84 # expecting pip_txt similar to "pip 1.4.1 from /bitbucket/moin-2.0..."
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
85 pip_txt = pip_txt.split()
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
86 if pip_txt[0] == 'pip':
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
87 pip_version = [int(x) for x in pip_txt[1].split('.')]
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
88 return pip_version >= [1, 5]
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
89 else:
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
90 sys.exit("Error: 'pip --version' produced unexpected results.")
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
91
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
92 def do_install(self):
2307
773f0e488722 dirty hack to support pip 1.5 incompatibilities, set PIP15=True in quickinstall.py if you need it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2306
diff changeset
93 args = [
2299
01dced4292d8 quickinstall: Use virtualenv path resoltion
Bastian Blank <bblank@thinkmo.de>
parents: 2211
diff changeset
94 os.path.join(self.dir_venv_bin, 'pip'),
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
95 'install',
2586
2c54228b0cbe change quickinstall.py and make.py to use --upgrade option
RogerHaase <haaserd@gmail.com>
parents: 2565
diff changeset
96 '--upgrade',
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
97 '--download-cache',
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
98 self.download_cache,
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
99 '--editable',
2307
773f0e488722 dirty hack to support pip 1.5 incompatibilities, set PIP15=True in quickinstall.py if you need it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2306
diff changeset
100 self.dir_source,
773f0e488722 dirty hack to support pip 1.5 incompatibilities, set PIP15=True in quickinstall.py if you need it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2306
diff changeset
101 ]
2565
2d205939e80e fix 395 - with pip 1.5+ quickinstall.py fails with CalledProcessError trying to download Flask-Themes
RogerHaase <haaserd@gmail.com>
parents: 2555
diff changeset
102 if self.pip15_plus():
2307
773f0e488722 dirty hack to support pip 1.5 incompatibilities, set PIP15=True in quickinstall.py if you need it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2306
diff changeset
103 args += [
2546
b6136f5042c8 Fixed PEP8 errors in quickinstall.py
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2315
diff changeset
104 '--process-dependency-links',
b6136f5042c8 Fixed PEP8 errors in quickinstall.py
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2315
diff changeset
105 '--allow-external', 'flatland',
b6136f5042c8 Fixed PEP8 errors in quickinstall.py
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2315
diff changeset
106 '--allow-unverified', 'flatland',
b6136f5042c8 Fixed PEP8 errors in quickinstall.py
Ajitesh Gupta <ajgupta93@gmail.com>
parents: 2315
diff changeset
107 ]
2307
773f0e488722 dirty hack to support pip 1.5 incompatibilities, set PIP15=True in quickinstall.py if you need it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2306
diff changeset
108 subprocess.check_call(args)
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
109
2210
c5562f2a893c quickinstall: Again create catalogs for translations
Bastian Blank <bblank@thinkmo.de>
parents: 2206
diff changeset
110 def do_catalog(self):
c5562f2a893c quickinstall: Again create catalogs for translations
Bastian Blank <bblank@thinkmo.de>
parents: 2206
diff changeset
111 subprocess.check_call((
2299
01dced4292d8 quickinstall: Use virtualenv path resoltion
Bastian Blank <bblank@thinkmo.de>
parents: 2211
diff changeset
112 os.path.join(self.dir_venv_bin, 'python'),
2210
c5562f2a893c quickinstall: Again create catalogs for translations
Bastian Blank <bblank@thinkmo.de>
parents: 2206
diff changeset
113 os.path.join(self.dir_source, 'setup.py'),
c5562f2a893c quickinstall: Again create catalogs for translations
Bastian Blank <bblank@thinkmo.de>
parents: 2206
diff changeset
114 'compile_catalog', '--statistics',
2304
aaeb6bba4b0f fix #379 quickinstall.py fails with obscure error message
RogerHaase
parents: 2299
diff changeset
115 # needed in case user runs quickinstall.py with a cwd other than the repo root
aaeb6bba4b0f fix #379 quickinstall.py fails with obscure error message
RogerHaase
parents: 2299
diff changeset
116 '--directory', os.path.join(os.path.dirname(__file__), 'MoinMoin', 'translations'),
2210
c5562f2a893c quickinstall: Again create catalogs for translations
Bastian Blank <bblank@thinkmo.de>
parents: 2206
diff changeset
117 ))
c5562f2a893c quickinstall: Again create catalogs for translations
Bastian Blank <bblank@thinkmo.de>
parents: 2206
diff changeset
118
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
119 def create_wrapper(self, filename, target):
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
120 """Create files in the repo root that wrap files in <path-to-virtual-env>\Scripts."""
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
121 target = os.path.join(self.dir_venv_bin, target)
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
122 with open(filename, 'w') as f:
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
123 f.write(':: {}\n\n@call {} %*\n'.format(WIN_INFO, target))
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
124
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
125 def do_helpers(self):
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
126 """Create small helper scripts or symlinks in repo root, avoid keying the long path to virtual env."""
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
127 create_m() # recreate m.bat or ./m to insure it is consistent with activate
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
128 if WINDOWS_OS:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
129 # windows commands are: activate | deactivate
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
130 self.create_wrapper('activate.bat', 'activate.bat')
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
131 self.create_wrapper('deactivate.bat', 'deactivate.bat')
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
132 if os.path.exists('moin.bat'): # cleanup obsolete file - TODO remove after 2014-04
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
133 os.remove('moin.bat')
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
134 else:
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
135 # linux commands are: source activate | deactivate
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
136 if os.path.exists('activate'):
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
137 os.unlink('activate')
2555
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
138 os.symlink(os.path.join(self.dir_venv_bin, 'activate'), 'activate') # no need to define deactivate on unix
98ab35b03176 fixes #398; simplify code in make.py; eliminate creation of moin.bat, moin symlink
RogerHaase <haaserd@gmail.com>
parents: 2546
diff changeset
139 if os.path.exists('moin'): # cleanup obsolete file - TODO remove after 2014-04
2310
4bcb0c04a6a4 changed default locations of virtualenv and pip download cache; added small helper scripts in repo root to reduce keying
RogerHaase
parents: 2306
diff changeset
140 os.unlink('moin')
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
141
2311
c4abbe125226 rewrite Makefile as python script for windows and unix
RogerHaase
parents: 2310
diff changeset
142
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
143 if __name__ == '__main__':
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
144 if os.path.isfile('m') or os.path.isfile('m.bat'):
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
145 # create the virtual env
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
146 logging.basicConfig(level=logging.INFO)
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
147
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
148 parser = argparse.ArgumentParser()
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
149 parser.add_argument('venv', metavar='VENV', nargs='?', help='location of v(irtual)env')
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
150 parser.add_argument('--download_cache', dest='download_cache', help='location of pip download cache')
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
151 args = parser.parse_args()
2206
85840f06e1ac quickinstall: Rewrite
Bastian Blank <bblank@thinkmo.de>
parents:
diff changeset
152
2312
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
153 QuickInstall(os.path.dirname(os.path.realpath(sys.argv[0])), venv=args.venv, download_cache=args.download_cache)()
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
154 else:
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
155 # run this same script (quickinstall.py) again to create the virtual env
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
156 create_m() # create file so above IF will be true next time around
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
157 # Use the make.py subprocess so user will see a few success/failure messages instead of ~500 info messages.
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
158 commands = Commands()
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
159 choice = getattr(commands, 'cmd_quickinstall')
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
160 choice(*sys.argv[1:]) # <override-path-to-venv> --download_cache <override-path-to-cache>
9f516825b465 change default venv name; rename m.py to make.py; delete makemoinmenu.py; rerun "python quickinstall.py" after applying this cs
RogerHaase
parents: 2311
diff changeset
161 print '\n> > > Type "%s" for menu < < <' % M