Transfert the distutil.ext from the org.asm project
This commit is contained in:
@@ -11,8 +11,7 @@ import re
|
||||
from distutils.errors import DistutilsError
|
||||
import tempfile
|
||||
|
||||
import importlib
|
||||
import imp
|
||||
from importlib.util import spec_from_file_location # @UnresolvedImport
|
||||
import zipimport
|
||||
|
||||
import argparse
|
||||
@@ -106,3 +105,8 @@ def serenity_mode(package,version):
|
||||
return args.serenity
|
||||
|
||||
|
||||
def getVersion(source,main,version):
|
||||
path = os.path.join(source,main,'%s.py' % version)
|
||||
spec = spec_from_file_location('version',path)
|
||||
return spec.loader.load_module().version.strip()
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ def install_requirements(requirementfile='requirements.txt'):
|
||||
log.info(" Installing requirement : %s" % x)
|
||||
pip_install_package(x)
|
||||
install_something=True
|
||||
if x[0:3]=='pip':
|
||||
return True
|
||||
|
||||
return install_something
|
||||
|
||||
@@ -134,7 +136,9 @@ def get_package_requirement(package,requirementfile='requirements.txt'):
|
||||
|
||||
def pip_install_package(package,directory=None,upgrade=True):
|
||||
|
||||
log.info('installing %s in directory %s' % (package,str(directory)))
|
||||
if directory is not 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']
|
||||
@@ -144,8 +148,8 @@ def pip_install_package(package,directory=None,upgrade=True):
|
||||
if upgrade:
|
||||
args.append('--upgrade')
|
||||
|
||||
if 'http_proxy' in os.environ:
|
||||
args.append('--proxy=%s' % os.environ['http_proxy'])
|
||||
if 'https_proxy' in os.environ:
|
||||
args.append('--proxy=%s' % os.environ['https_proxy'])
|
||||
|
||||
if directory is not None:
|
||||
args.append('--target=%s' % directory)
|
||||
|
||||
@@ -37,7 +37,7 @@ def is_python_version(path=None,minversion='3.4',maxversion=None):
|
||||
stdout=subprocess.PIPE)
|
||||
pythonversion=str(p.communicate()[0],'utf8').strip()
|
||||
pythonversion = StrictVersion(pythonversion)
|
||||
|
||||
|
||||
return ( pythonversion >=StrictVersion(minversion)
|
||||
and ( maxversion is None
|
||||
or pythonversion < StrictVersion(maxversion))
|
||||
@@ -91,9 +91,9 @@ def is_a_virtualenv_python(path=None):
|
||||
|
||||
'''
|
||||
if path is None:
|
||||
rep = sys.base_exec_prefix == sys.exec_prefix
|
||||
rep = sys.base_exec_prefix != sys.exec_prefix
|
||||
else:
|
||||
command = """'%s' -c 'import sys; print(sys.base_exec_prefix == sys.exec_prefix)'""" % path
|
||||
command = """'%s' -c 'import sys; print(sys.base_exec_prefix != sys.exec_prefix)'""" % path
|
||||
p = subprocess.Popen(command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE)
|
||||
|
||||
@@ -9,10 +9,10 @@ import sys
|
||||
import venv
|
||||
|
||||
from distutils.errors import DistutilsError
|
||||
from obidistutils.serenity.globals import local_virtualenv # @UnusedImport
|
||||
from obidistutils.serenity.checkpython import which_virtualenv,\
|
||||
is_python_version, \
|
||||
is_a_virtualenv_python
|
||||
from .globals import local_virtualenv # @UnusedImport
|
||||
from .checkpython import which_virtualenv,\
|
||||
is_python_version, \
|
||||
is_a_virtualenv_python
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ def serenity_virtualenv(envname,package,version,minversion='3.4',maxversion=None
|
||||
maxversion=maxversion) and
|
||||
is_a_virtualenv_python(python))
|
||||
|
||||
|
||||
#
|
||||
# The virtualenv already exist but it is not ok
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user