Commit dd5fbb02 by Eric Coissac

--no commit message

parent 3a824692
......@@ -6,98 +6,108 @@ Created on 13 fevr. 2014
from distutils import log
import sys
from obidistutils.serenity import is_serenity
try:
from Cython.Distutils import build_ext as ori_build_ext # @UnresolvedImport
except ImportError:
from obidistutils.serenity.cython import get_a_cython_module
import imp
import os.path
from distutils.errors import DistutilsSetupError
log.info("No cython installed, try to install a temporary cython")
cython = get_a_cython_module()
sys.path.insert(0,os.path.dirname(os.path.dirname(cython.__file__)))
f, filename, description=imp.find_module('Distutils',[os.path.dirname(cython.__file__)])
submodule = imp.load_module('Cython.Distutils', f, filename, description)
ori_build_ext = submodule.build_ext
from distutils.errors import DistutilsSetupError
import os
class build_ext(ori_build_ext):
def modifyDocScripts(self):
print >>open("doc/sphinx/build_dir.txt","w"),self.build_lib
def initialize_options(self):
ori_build_ext.initialize_options(self)
self.littlebigman = None
self.built_files = None
class build_ext(ori_build_ext):
def modifyDocScripts(self):
print >>open("doc/sphinx/build_dir.txt","w"),self.build_lib
def initialize_options(self):
ori_build_ext.initialize_options(self) # @UndefinedVariable
self.littlebigman = None
self.built_files = None
def finalize_options(self):
ori_build_ext.finalize_options(self)
self.set_undefined_options('littlebigman',
('littlebigman', 'littlebigman'))
self.set_undefined_options('build_files',
('files', 'built_files'))
self.cython_c_in_temp = 1
if self.littlebigman =='-DLITTLE_END':
if self.define is None:
self.define=[('LITTLE_END',None)]
else:
self.define.append('LITTLE_END',None)
def substitute_sources(self,exe_name,sources):
"""
Substitutes source file name starting by an @ by the actual
name of the built file (see --> build_files)
"""
sources = list(sources)
for i in xrange(len(sources)):
print exe_name,sources[i],
if sources[i][0]=='@':
try:
filename = self.built_files[sources[i][1:]]
except KeyError:
tmpfilename = os.path.join(self.build_temp,sources[i][1:])
if os.path.isfile (tmpfilename):
filename = tmpfilename
else:
raise DistutilsSetupError, \
('The %s filename declared in the source '
'files of the program %s have not been '
'built by the installation process') % (sources[i],
exe_name)
sources[i]=filename
print "changed to ",filename
else:
print " ok"
return sources
def build_extensions(self):
# First, sanity-check the 'extensions' list
for ext in self.extensions:
ext.sources = self.substitute_sources(ext.name,ext.sources)
def finalize_options(self):
ori_build_ext.finalize_options(self) # @UndefinedVariable
self.set_undefined_options('littlebigman',
('littlebigman', 'littlebigman'))
self.set_undefined_options('build_files',
('files', 'built_files'))
self.cython_c_in_temp = 1
if self.littlebigman =='-DLITTLE_END':
if self.define is None:
self.define=[('LITTLE_END',None)]
else:
self.define.append('LITTLE_END',None)
def substitute_sources(self,exe_name,sources):
"""
Substitutes source file name starting by an @ by the actual
name of the built file (see --> build_files)
"""
sources = list(sources)
for i in xrange(len(sources)):
print exe_name,sources[i],
if sources[i][0]=='@':
try:
filename = self.built_files[sources[i][1:]]
except KeyError:
tmpfilename = os.path.join(self.build_temp,sources[i][1:])
if os.path.isfile (tmpfilename):
filename = tmpfilename
else:
raise DistutilsSetupError, \
('The %s filename declared in the source '
'files of the program %s have not been '
'built by the installation process') % (sources[i],
exe_name)
sources[i]=filename
print "changed to ",filename
else:
print " ok"
return sources
def build_extensions(self):
# First, sanity-check the 'extensions' list
for ext in self.extensions:
ext.sources = self.substitute_sources(ext.name,ext.sources)
self.check_extensions_list(self.extensions)
for ext in self.extensions:
print "#####>",ext.sources
ext.sources = self.cython_sources(ext.sources, ext)
self.build_extension(ext)
def run(self):
self.modifyDocScripts()
ori_build_ext.run(self) # @UndefinedVariable
self.check_extensions_list(self.extensions)
for ext in self.extensions:
print "#####>",ext.sources
ext.sources = self.cython_sources(ext.sources, ext)
self.build_extension(ext)
def run(self):
self.modifyDocScripts()
ori_build_ext.run(self)
except ImportError:
if is_serenity():
from distutils.command.build_ext import build_ext as ori_build_ext # @UnusedImport
else:
log.error('Cython must be installed before installing obitools')
sys.exit(1)
# from obidistutils.serenity.cython import get_a_cython_module
# import imp
# import os.path
#
# log.info("No cython installed, try to install a temporary cython")
# cython = get_a_cython_module()
# sys.path.insert(0,os.path.dirname(os.path.dirname(cython.__file__)))
# f, filename, description=imp.find_module('Distutils',[os.path.dirname(cython.__file__)])
# submodule = imp.load_module('Cython.Distutils', f, filename, description)
# ori_build_ext = submodule.build_ext
#
......
......@@ -13,6 +13,7 @@ from obidistutils.command.sdist import sdist
try:
from setuptools import setup as ori_setup
from setuptools.command.egg_info import egg_info
has_setuptools = True
except ImportError:
from distutils.core import setup as ori_setup
......@@ -130,6 +131,10 @@ COMMANDS = {'build':build,
'install':install,
'sdist':sdist}
if has_setuptools:
COMMANDS['egg_info']=egg_info
CTOOLS =[]
CEXES =[]
FILES =[]
......
......@@ -42,7 +42,7 @@ from obidistutils.serenity.util import save_argv
from obidistutils.serenity.snake import snake
from obidistutils.serenity.globals import PIP_MINVERSION
from obidistutils.serenity.globals import PIP_MINVERSION, local_serenity
def serenity_snake(envname,package,version,minversion=PIP_MINVERSION):
......@@ -71,6 +71,9 @@ def serenity_assert(version,minversion=PIP_MINVERSION):
check_requirements()
def is_serenity():
from obidistutils.serenity.globals import local_serenity
return local_serenity and local_serenity[0]
def serenity_mode(package,version):
......@@ -100,11 +103,10 @@ def serenity_mode(package,version):
sys.argv = [sys.argv[0]] + unknown
if args.serenity:
local_serenity.append(True)
serenity_snake(args.virtual,package,version)
else:
pass
# serenity_assert(package,version)
local_serenity.append(False)
log.set_threshold(old)
......
......@@ -12,3 +12,4 @@ tmpdir=[]
local_pip=[]
local_virtualenv=[]
local_cython=[]
local_serenity=[]
......@@ -18,7 +18,8 @@ from obidistutils.serenity.globals import PIP_MINVERSION, \
from obidistutils.serenity.checkpip import get_a_pip_module
from obidistutils.serenity.checkpackage import get_package_requirement
from obidistutils.serenity.checkpackage import get_package_requirement,\
install_requirements
from obidistutils.serenity.checkpackage import parse_package_requirement
from obidistutils.serenity.checkpackage import is_installed
from obidistutils.serenity.checkpackage import pip_install_package
......@@ -113,6 +114,8 @@ def serenity_virtualenv(envname,package,version,minversion=PIP_MINVERSION,pip=No
else:
ok = False
install_requirements()
#
# Creates a new virtualenv
......
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