Commit 52de6f27 by Eric Coissac

Update distutils for openmp and new version of pip

parent 29c56572
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -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:
......
......@@ -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
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -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)
......@@ -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):
......
......@@ -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,
......
File mode changed from 100755 to 100644
......@@ -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
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -5,7 +5,7 @@
* Author: coissac
*/
#include<stdio.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
......
File mode changed from 100755 to 100644
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment