@@ -61,16 +61,13 @@ def __init__(self, nop=False):
61
61
self .dist = self .platform .dist
62
62
self .ver = self .platform .os_ver
63
63
64
- if self .has_command ("python3" ):
65
- self .python = "python3"
66
- elif self .has_command ("python" ):
67
- self .python = "python"
68
- elif self .has_command ("python2" ):
69
- self .python = "python2"
64
+ self .python = sys .executable
70
65
71
66
if self .os == 'macosx' :
72
67
# this is required because osx pip installed are done with --user
73
- os .environ ["PATH" ] = os .environ ["PATH" ] + ':' + '$HOME/Library/Python/2.7/bin'
68
+ os .environ ["PATH" ] = os .environ ["PATH" ] + ':' + os .environ ["HOME" ] + '/Library/Python/2.7/bin'
69
+ # this prevents brew updating before each install
70
+ os .environ ["HOMEBREW_NO_AUTO_UPDATE" ] = "1"
74
71
75
72
if self .platform .is_debian_compat ():
76
73
# prevents apt-get from interactively prompting
@@ -118,11 +115,11 @@ def brew_install(self, packs, group=False, _try=False):
118
115
119
116
def install (self , packs , group = False , _try = False ):
120
117
if self .os == 'linux' :
121
- if self .dist == 'fedora' :
118
+ if self .dist == 'fedora' : # also include centos 8
122
119
self .dnf_install (packs , group = group , _try = _try )
123
- elif self .dist == 'ubuntu' or self . dist == 'debian' :
120
+ elif self .platform . is_debian_compat () :
124
121
self .apt_install (packs , group = group , _try = _try )
125
- elif self .dist == 'centos' or self . dist == 'redhat' :
122
+ elif self .platform . is_redhat_compat () :
126
123
self .yum_install (packs , group = group , _try = _try )
127
124
elif self .dist == 'suse' :
128
125
self .zypper_install (packs , group = group , _try = _try )
@@ -135,48 +132,48 @@ def install(self, packs, group=False, _try=False):
135
132
else :
136
133
Assert (False ), "Cannot determine installer"
137
134
138
- def group_install (self , packs ):
139
- self .install (packs , group = True )
135
+ def group_install (self , packs , _try = False ):
136
+ self .install (packs , group = True , _try = _try )
140
137
141
138
#------------------------------------------------------------------------------------------
142
139
143
- def yum_add_repo (self , repourl , repo = "" ):
140
+ def yum_add_repo (self , repourl , repo = "" , _try = False ):
144
141
if not self .has_command ("yum-config-manager" ):
145
142
self .install ("yum-utils" )
146
- self .run ("yum-config-manager -y --add-repo {}" .format (repourl ))
143
+ self .run ("yum-config-manager -y --add-repo {}" .format (repourl ), _try = _try )
147
144
148
- def apt_add_repo (self , repourl , repo = "" ):
145
+ def apt_add_repo (self , repourl , repo = "" , _try = False ):
149
146
if not self .has_command ("yum-config-manager" ):
150
147
self .install ("software-properties-common" )
151
- self .run ("add-apt-repository -y {}" .format (repourl ))
152
- self .run ("apt-get -qq update" )
148
+ self .run ("add-apt-repository -y {}" .format (repourl ), _try = _try )
149
+ self .run ("apt-get -qq update" , _try = _try )
153
150
154
- def dnf_add_repo (self , repourl , repo = "" ):
151
+ def dnf_add_repo (self , repourl , repo = "" , _try = False ):
155
152
if self .run ("dnf config-manager 2>/dev/null" , _try = True ):
156
- self .install ("dnf-plugins-core" )
157
- self .run ("dnf config-manager -y --add-repo {}" .format (repourl ))
153
+ self .install ("dnf-plugins-core" , _try = _try )
154
+ self .run ("dnf config-manager -y --add-repo {}" .format (repourl ), _try = _try )
158
155
159
- def zypper_add_repo (self , repourl , repo = "" ):
156
+ def zypper_add_repo (self , repourl , repo = "" , _try = False ):
160
157
pass
161
158
162
- def pacman_add_repo (self , repourl , repo = "" ):
159
+ def pacman_add_repo (self , repourl , repo = "" , _try = False ):
163
160
pass
164
161
165
- def brew_add_repo (self , repourl , repo = "" ):
162
+ def brew_add_repo (self , repourl , repo = "" , _try = False ):
166
163
pass
167
164
168
- def add_repo (self , repourl , repo = "" ):
165
+ def add_repo (self , repourl , repo = "" , _try = False ):
169
166
if self .os == 'linux' :
170
167
if self .dist == 'fedora' :
171
- self .dnf_add_repo (repourl , repo = repo )
168
+ self .dnf_add_repo (repourl , repo = repo , _try = _try )
172
169
elif self .dist == 'ubuntu' or self .dist == 'debian' :
173
- self .apt_add_repo (repourl , repo = repo )
170
+ self .apt_add_repo (repourl , repo = repo , _try = _try )
174
171
elif self .dist == 'centos' or self .dist == 'redhat' :
175
- self .yum_add_repo (repourl , repo = repo )
172
+ self .yum_add_repo (repourl , repo = repo , _try = _try )
176
173
elif self .dist == 'suse' :
177
- self .zypper_add_repo (repourl , repo = repo )
174
+ self .zypper_add_repo (repourl , repo = repo , _try = _try )
178
175
elif self .dist == 'arch' :
179
- self .pacman_add_repo (repourl , repo = repo )
176
+ self .pacman_add_repo (repourl , repo = repo , _try = _try )
180
177
else :
181
178
Assert (False ), "Cannot determine installer"
182
179
elif self .os == 'macosx' :
@@ -190,26 +187,35 @@ def pip_install(self, cmd, _try=False):
190
187
pip_user = ''
191
188
if self .os == 'macosx' :
192
189
pip_user = '--user '
193
- self .run (" pip install --disable-pip-version-check " + pip_user + cmd , output_on_error = True , _try = _try )
190
+ self .run (self . python + " -m pip install --disable-pip-version-check " + pip_user + cmd , output_on_error = True , _try = _try )
194
191
195
192
def pip3_install (self , cmd , _try = False ):
196
193
pip_user = ''
197
194
if self .os == 'macosx' :
198
195
pip_user = '--user '
199
- self .run ("pip3 install --disable-pip-version-check " + pip_user + cmd , output_on_error = True , _try = _try )
196
+ self .run (self . python + " -m pip install --disable-pip-version-check " + pip_user + cmd , output_on_error = True , _try = _try )
200
197
201
- def setup_pip (self ):
198
+ def setup_pip (self , _try = False ):
202
199
get_pip = "set -e; wget -q https://bootstrap.pypa.io/get-pip.py -O /tmp/get-pip.py"
203
- if not self .has_command ("pip3" ):
204
- self .install ("python3-distutils" , _try = True )
200
+ if self .run (self .python + " -m pip --version" , _try = True , output_on_error = False ) != 0 :
201
+ if sys .version_info .major == 3 :
202
+ self .install ("python3-distutils" )
205
203
self .install_downloaders ()
206
- self .run (get_pip + "; " + self .python + " /tmp/get-pip.py" , output_on_error = True )
204
+ pip_user = ' --user' if self .os == 'macosx' else ''
205
+ self .run (get_pip + "; " + self .python + " /tmp/get-pip.py" + pip_user + " 'pip==19.3.1'" , output_on_error = True , _try = _try )
207
206
208
- def install_downloaders (self ):
207
+ def install_downloaders (self , _try = False ):
209
208
if self .os == 'linux' :
210
- self .install ("ca-certificates" )
211
- self .install ("curl wget" )
212
-
213
- def install_git_lfs_on_linux (self ):
214
- self .run ("curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash" )
215
- self .install ("git-lfs" )
209
+ self .install ("ca-certificates" , _try = _try )
210
+ self .install ("curl wget" , _try = _try )
211
+
212
+ def install_git_lfs_on_linux (self , _try = False ):
213
+ self .run ("set -e; wget -q https://github.com/git-lfs/git-lfs/releases/download/v2.9.2/git-lfs-linux-amd64-v2.9.2.tar.gz -O /tmp/git-lfs.tar.gz" )
214
+ self .run ("cd /tmp; tar xzf git-lfs.tar.gz; ./install.sh" )
215
+
216
+ # cmd = "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.{}.sh | bash"
217
+ # if self.platform.is_redhat_compat():
218
+ # self.run(cmd.format('rpm'), _try=_try)
219
+ # elif self.platform.is_debian_compat():
220
+ # self.run(cmd.format('deb'), _try=_try)
221
+ # self.install("git-lfs", _try=_try)
0 commit comments