Update distutils for openmp and new version of pip

This commit is contained in:
2019-02-19 17:30:53 +01:00
parent 29c56572cf
commit 52de6f2717
31 changed files with 114 additions and 44 deletions

0
distutils.ext/obidistutils/__init__.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/__init__.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/build.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/build_cexe.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/build_ctools.py Executable file → Normal file
View File

21
distutils.ext/obidistutils/command/build_exe.py Executable file → Normal file
View File

@ -6,12 +6,28 @@ Created on 20 oct. 2012
import os
from distutils import sysconfig
from distutils.core import Command
from distutils.sysconfig import customize_compiler
from distutils.sysconfig import customize_compiler as customize_compiler_ori
from distutils.errors import DistutilsSetupError
from distutils import log
from distutils.ccompiler import show_compilers
def customize_compiler(compiler):
customize_compiler_ori(compiler)
compilername = compiler.compiler[0]
if ("gcc" in compilername or "g++" in compilername):
cc_cmd = ' '.join(compiler.compiler + ['-fopenmp'])
ccshared= ' '.join(x for x in sysconfig.get_config_vars("ccshared") if x is not None)
compiler.set_executables(
compiler=cc_cmd,
compiler_so=cc_cmd + ' ' + ccshared
)
class build_exe(Command):
description = "build an executable -- Abstract command "
@ -80,6 +96,7 @@ class build_exe(Command):
else:
self.extra_compile_args.append('-m%s' % self.sse)
# XXX same as for build_ext -- what about 'self.define' and
# 'self.undef' ?
@ -96,7 +113,7 @@ class build_exe(Command):
dry_run=self.dry_run,
force=self.force)
customize_compiler(self.compiler)
if self.include_dirs is not None:
self.compiler.set_include_dirs(self.include_dirs)
if self.define is not None:

28
distutils.ext/obidistutils/command/build_ext.py Executable file → Normal file
View File

@ -7,9 +7,21 @@ Created on 13 fevr. 2014
from distutils import log
import os
from distutils import sysconfig
from distutils.errors import DistutilsSetupError
def _customize_compiler(compiler):
compilername = compiler.compiler[0]
if ("gcc" in compilername or "g++" in compilername):
cc_cmd = ' '.join(compiler.compiler + ['-fopenmp'])
ccshared= ' '.join(x for x in sysconfig.get_config_vars("ccshared") if x is not None)
compiler.set_executables(
compiler=cc_cmd,
compiler_so=cc_cmd + ' ' + ccshared
)
try:
from Cython.Distutils import build_ext as ori_build_ext # @UnresolvedImport
from Cython.Compiler import Options as cython_options # @UnresolvedImport
@ -28,7 +40,8 @@ try:
def finalize_options(self):
ori_build_ext.finalize_options(self) # @UndefinedVariable
super(build_ext, self).finalize_options()
self.set_undefined_options('littlebigman',
('littlebigman', 'littlebigman'))
@ -85,6 +98,14 @@ try:
ext.sources = self.cython_sources(ext.sources, ext)
self.build_extension(ext)
def build_extensions(self):
if hasattr(self, 'compiler'):
_customize_compiler(self.compiler)
if hasattr(self, 'shlib_compiler'):
_customize_compiler(self.shlib_compiler)
ori_build_ext.build_extensions(self)
def run(self):
self.modifyDocScripts()
@ -104,8 +125,7 @@ try:
sub_commands = [('build_files',has_files),
('build_cexe', has_executables)
] + \
ori_build_ext.sub_commands
] + ori_build_ext.sub_commands
except ImportError:
from distutils.command import build_ext # @UnusedImport

0
distutils.ext/obidistutils/command/build_files.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/build_scripts.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/build_sphinx.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/install.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/install_scripts.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/install_sphinx.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/littlebigman.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/pidname.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/command/sdist.py Executable file → Normal file
View File

16
distutils.ext/obidistutils/core.py Executable file → Normal file
View File

@ -9,12 +9,12 @@ import os.path
import glob
import sys
# try:
# from setuptools.extension import Extension
# except ImportError:
# from distutils.extension import Extension
try:
from setuptools.extension import Extension
except ImportError:
from distutils.extension import Extension
from distutils.extension import Extension
# from distutils.extension import Extension
from obidistutils.serenity.checkpackage import install_requirements,\
check_requirements, \
@ -40,7 +40,6 @@ def findPackage(root,base=None):
def findCython(root,base=None,pyrexs=None):
setupdir = os.path.dirname(sys.argv[0])
csourcedir = os.path.join(setupdir,"src")
pyrexs=[]
if base is None:
@ -54,7 +53,6 @@ def findCython(root,base=None,pyrexs=None):
[pyrex]
)
)
pyrexs[-1].include_dirs.append(csourcedir)
try:
cfiles = os.path.splitext(pyrex)[0]+".cfiles"
cfilesdir = os.path.dirname(cfiles)
@ -72,7 +70,7 @@ def findCython(root,base=None,pyrexs=None):
'-Wno-unused-function',
'-Wmissing-braces',
'-Wchar-subscripts'])
except IOError:
pass
@ -225,4 +223,4 @@ def setup(**attrs):
from distutils.core import setup as ori_setup
ori_setup(**attrs)
return ori_setup(**attrs)

10
distutils.ext/obidistutils/dist.py Executable file → Normal file
View File

@ -4,12 +4,12 @@ Created on 20 oct. 2012
@author: coissac
'''
# try:
# from setuptools.dist import Distribution as ori_Distribution
# except ImportError:
# from distutils.dist import Distribution as ori_Distribution
try:
from setuptools.dist import Distribution as ori_Distribution
except ImportError:
from distutils.dist import Distribution as ori_Distribution
from distutils.dist import Distribution as ori_Distribution
# from distutils.dist import Distribution as ori_Distribution
class Distribution(ori_Distribution):

8
distutils.ext/obidistutils/serenity/__init__.py Executable file → Normal file
View File

@ -81,9 +81,15 @@ def serenity_mode(package,version):
argparser.add_argument('--serenity',
dest='serenity',
action='store_true',
default=False,
default=True,
help='Switch the installer in serenity mode. Everythings are installed in a virtualenv')
argparser.add_argument('--no-serenity',
dest='serenity',
action='store_false',
default=True,
help='Switch the installer in the no serenity mode.')
argparser.add_argument('--virtualenv',
dest='virtual',
type=str,

0
distutils.ext/obidistutils/serenity/bootstrappip.py Executable file → Normal file
View File

54
distutils.ext/obidistutils/serenity/checkpackage.py Executable file → Normal file
View File

@ -5,32 +5,35 @@ Created on 2 oct. 2014
'''
import re
import os
try:
import pip # @UnresolvedImport
from pip.utils import get_installed_distributions # @UnresolvedImport
except ImportError:
from .bootstrappip import bootstrap
bootstrap()
from distutils.version import StrictVersion # @UnusedImport
from distutils.errors import DistutilsError
from distutils import log
import os.path
import sys
import subprocess
class RequirementError(Exception):
pass
def is_installed(requirement):
pipcommand = os.path.join(os.path.dirname(sys.executable),'pip')
pipjson = subprocess.run([pipcommand,"list","--format=json"],
capture_output=True).stdout
packages = eval(pipjson)
requirement_project,requirement_relation,requirement_version = parse_package_requirement(requirement)
package = [x for x in get_installed_distributions() if x.project_name==requirement_project]
package = [x for x in packages if x["name"]==requirement_project]
if len(package)==1:
if requirement_version is not None and requirement_relation is not None:
rep = (len(package)==1) and eval("StrictVersion('%s') %s StrictVersion('%s')" % (package[0].version,
if ( requirement_version is not None
and requirement_relation is not None):
rep = (len(package)==1) and eval("StrictVersion('%s') %s StrictVersion('%s')" % (package[0]["version"],
requirement_relation,
requirement_version)
)
@ -44,20 +47,23 @@ def is_installed(requirement):
log.info("Look for package %s (%s%s) : ok version %s installed" % (requirement_project,
requirement_relation,
requirement_version,
package[0].version))
package[0]["version"]))
else:
log.info("Look for package %s : ok version %s installed" % (requirement_project,
package[0].version))
package[0]["version"]))
else:
if len(package)!=1:
log.info("Look for package %s (%s%s) : not installed" % (requirement_project,
requirement_relation,
requirement_version))
if requirement_version is not None and requirement_relation is not None:
log.info("Look for package %s (%s%s) : not installed" % (requirement_project,
requirement_relation,
requirement_version))
else:
log.info("Look for package %s : not installed" % requirement_project)
else:
log.info("Look for package %s (%s%s) : failed only version %s installed" % (requirement_project,
requirement_relation,
requirement_version,
package[0].version))
package[0]["version"]))
return rep
@ -86,7 +92,7 @@ def install_requirements(requirementfile='requirements.txt'):
ok = is_installed(x)
if not ok:
log.info(" Installing requirement : %s" % x)
pip_install_package(x)
pip_install_package(x,requirement=requirementfile)
install_something=True
if x[0:3]=='pip':
return True
@ -139,8 +145,9 @@ def get_package_requirement(package,requirementfile='requirements.txt'):
return None
def pip_install_package(package,directory=None,upgrade=True):
def pip_install_package(package,directory=None,requirement=None):
pipcommand = os.path.join(os.path.dirname(sys.executable),'pip')
if directory is not None:
log.info(' installing %s in directory %s' % (package,str(directory)))
@ -150,8 +157,9 @@ def pip_install_package(package,directory=None,upgrade=True):
args = ['install']
if upgrade:
args.append('--upgrade')
if requirement:
args.append('--requirement')
args.append(requirement)
if 'https_proxy' in os.environ:
args.append('--proxy=%s' % os.environ['https_proxy'])
@ -161,5 +169,7 @@ def pip_install_package(package,directory=None,upgrade=True):
args.append(package)
return pip.main(args)
pip = subprocess.run([pipcommand] + args)
return pip

0
distutils.ext/obidistutils/serenity/checkpython.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/serenity/checksystem.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/serenity/globals.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/serenity/rerun.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/serenity/snake.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/serenity/util.py Executable file → Normal file
View File

0
distutils.ext/obidistutils/serenity/virtual.py Executable file → Normal file
View File

2
distutils.ext/src/littlebigman.c Executable file → Normal file
View File

@ -5,7 +5,7 @@
* Author: coissac
*/
#include<stdio.h>
#include <stdio.h>
int main(int argc, char *argv[])
{

0
distutils.ext/src/pidname.c Executable file → Normal file
View File

View File

@ -33,6 +33,25 @@ sys.path.append(SRC)
if __name__=="__main__":
import sys
print("----------------")
print(" ".join(sys.argv))
print("----------------")
#
# Horrible hack
#
if sys.argv[0]=="-c":
sys.argv[0]="setup.py"
#
# End of the horrible hack
#
try:
from obitools3 import version
VERSION = version.version