Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
28
Issues
28
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools
Commits
bc0378b3
Commit
bc0378b3
authored
Nov 13, 2014
by
Eric Coissac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work on the installation script
parent
be4be4c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
17 deletions
+41
-17
distutils.ext/obidistutils/serenity/checkpackage.py
distutils.ext/obidistutils/serenity/checkpackage.py
+4
-1
distutils.ext/obidistutils/serenity/checkpip.py
distutils.ext/obidistutils/serenity/checkpip.py
+37
-16
No files found.
distutils.ext/obidistutils/serenity/checkpackage.py
View file @
bc0378b3
...
...
@@ -80,7 +80,7 @@ def install_requirements(skip_virtualenv=True,pip=None):
if
pip
is
None
:
pip
=
get_a_pip_module
()
try
:
requirements
=
open
(
'requirements.txt'
).
readlines
()
requirements
=
[
x
.
strip
()
for
x
in
requirements
]
...
...
@@ -161,6 +161,9 @@ def pip_install_package(package,directory=None,pip=None):
log
.
info
(
'installing %s in directory %s'
%
(
package
,
str
(
directory
)))
if
'http_proxy'
in
os
.
environ
and
'https_proxy'
not
in
os
.
environ
:
os
.
environ
[
'https_proxy'
]
=
os
.
environ
[
'http_proxy'
]
if
pip
is
None
:
pip
=
get_a_pip_module
()
...
...
distutils.ext/obidistutils/serenity/checkpip.py
View file @
bc0378b3
...
...
@@ -27,10 +27,21 @@ import pkgutil
def
is_pip_installed
(
minversion
=
PIP_MINVERSION
):
try
:
import
pip
# @UnresolvedImport
ok
=
LooseVersion
(
pip
.
__version__
)
>=
LooseVersion
(
minversion
)
except
:
log
.
info
(
"Try to load pip module..."
)
pipmodule
=
importlib
.
import_module
(
'pip'
)
if
hasattr
(
pipmodule
,
'__version__'
):
ok
=
LooseVersion
(
pipmodule
.
__version__
)
>=
LooseVersion
(
minversion
)
log
.
info
(
"Pip installed version %s"
%
pipmodule
.
__version__
)
else
:
ok
=
False
log
.
info
(
"A too old version of pip is installed on your system"
)
for
m
in
[
x
for
x
in
sys
.
modules
if
x
.
startswith
(
'pip.'
or
x
==
'pip'
)]:
del
sys
.
modules
[
m
]
except
Exception
,
e
:
ok
=
False
log
.
info
(
"No pip installed on your system"
)
return
ok
...
...
@@ -43,8 +54,11 @@ def get_a_pip_module(minversion=PIP_MINVERSION):
if
not
local_pip
:
if
not
is_pip_installed
(
minversion
):
try
:
if
'http_proxy'
in
os
.
environ
and
'https_proxy'
not
in
os
.
environ
:
os
.
environ
[
'https_proxy'
]
=
os
.
environ
[
'http_proxy'
]
pipinstallscript
=
urllib2
.
urlopen
(
'https://bootstrap.pypa.io/get-pip.py'
)
except
:
except
Exception
,
e
:
print
(
str
(
e
))
raise
DistutilsError
,
"Pip (>=%s) is not install on your system and I cannot install it"
%
PIP_MINVERSION
script
=
pipinstallscript
.
read
()
...
...
@@ -58,30 +72,37 @@ def get_a_pip_module(minversion=PIP_MINVERSION):
ZIPFILE
=
getpip
.
ZIPFILE
pip_zip
=
os
.
path
.
join
(
tmpdir
,
"pip.zip"
)
print
pip_zip
with
open
(
pip_zip
,
"wb"
)
as
fp
:
log
.
info
(
"Installing temporary pip..."
)
fp
.
write
(
base64
.
decodestring
(
ZIPFILE
))
log
.
info
(
" done."
)
# Add the zipfile to sys.path so that we can import it
sys
.
path
=
[
pip_zip
]
+
sys
.
path
sys
.
path
.
insert
(
0
,
pip_zip
)
zi
=
zipimport
.
zipimporter
(
pip_zip
)
pip
=
zi
.
load_module
(
"pip"
)
pipmodule
=
importlib
.
import_module
(
'pip'
)
# Prepare the CERT certificat for https download
else
:
import
pip
local_pip
.
append
(
pip
)
print
pip
.
__file__
# Prepare the CERT certificat for https download
cert_path
=
os
.
path
.
join
(
tmpdir
,
"cacert.pem"
)
cert_path
=
os
.
path
.
join
(
tmpdir
,
"cacert.pem"
)
with
open
(
cert_path
,
"wb"
)
as
cert
:
cert
.
write
(
pkgutil
.
get_data
(
"pip._vendor.requests"
,
"cacert.pem"
))
os
.
environ
.
setdefault
(
"PIP_CERT"
,
cert_path
)
certificate
=
pkgutil
.
get_data
(
"pip._vendor.requests"
,
"cacert.pem"
)
with
open
(
cert_path
,
"wb"
)
as
cert
:
cert
.
write
(
certificate
)
assert
LooseVersion
(
pipmodule
.
__version__
)
>=
minversion
,
\
os
.
environ
.
setdefault
(
"PIP_CERT"
,
cert_path
)
assert
hasattr
(
pip
,
'__version__'
)
and
LooseVersion
(
pip
.
__version__
)
>=
minversion
,
\
"Unable to find suitable version of pip get %s instead of %s"
%
(
pipmodule
.
__version__
,
minversion
)
local_pip
.
append
(
pipmodule
)
return
local_pip
[
0
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment