Commit 42c0f1ef by Eric Coissac

Merge branch 'orgasm-python3' into 'master'

Orgasm python3

The Python3 version becomes the new master version

See merge request !1
parents aa3f94c4 e98adb8d
......@@ -4,8 +4,8 @@ recursive-include python *.pyx *.pxd *.c *.h *.cfiles
recursive-include src *.c *.h
recursive-include fiboheap *.c *.h
recursive-include doc/sphinx/source *.txt *.rst *.py
recursive-include doc/sphinx/sphinxext *.py
include doc/sphinx/make.bat
include doc/sphinx/Makefile
include README.txt
include requirements.txt
def build_ext(*args,**kargs):
'''
Wrapper over the build_ext class to postpone the import of cython
'''
from build_ext import build_ext as _build_ext
return _build_ext(*args,**kargs)
......@@ -27,11 +27,16 @@ class build(ori_build):
def has_pidname(self):
return is_mac_system()
def has_doc(self):
return True
sub_commands = [('littlebigman', has_littlebigman),
('pidname',has_pidname),
('build_ctools', has_ctools),
('build_files', has_files),
('build_cexe', has_executables)] \
+ ori_build.sub_commands
+ ori_build.sub_commands + \
[('build_sphinx',has_doc)]
......@@ -4,9 +4,7 @@ Created on 20 oct. 2012
@author: coissac
'''
import os
from obidistutils.command.build_ctools import build_ctools
from distutils.sysconfig import customize_compiler
from distutils.errors import DistutilsSetupError
from distutils import log
......@@ -55,21 +53,21 @@ class build_cexe(build_ctools):
name of the built file (see --> build_files)
"""
sources = list(sources)
for i in xrange(len(sources)):
print exe_name,sources[i],
for i in range(len(sources)):
message = "%s :-> %s" % (exe_name,sources[i])
if sources[i][0]=='@':
try:
filename = self.built_files[sources[i][1:]]
except KeyError:
raise DistutilsSetupError, \
('The %s filename declared in the source '
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)
'built by the installation process' % (sources[i],
exe_name))
sources[i]=filename
print "changed to ",filename
log.info("%s changed to %s",message,filename)
else:
print " ok"
log.info("%s ok",message)
return sources
......@@ -4,12 +4,8 @@ Created on 20 oct. 2012
@author: coissac
'''
import os
from obidistutils.command.build_exe import build_exe
from distutils.sysconfig import customize_compiler
from distutils.errors import DistutilsSetupError
from distutils import log
class build_ctools(build_exe):
......@@ -42,18 +38,21 @@ class build_ctools(build_exe):
self.executables = self.distribution.ctools
self.check_executable_list(self.executables)
if self.littlebigman =='-DLITTLE_END':
if self.define is None:
self.define=[('LITTLE_END',None)]
else:
self.define.append('LITTLE_END',None)
log.info('Look for CPU architecture... %s',self.define)
self.ctools = set()
def run(self):
build_exe.run(self)
for e,p in self.executables:
for e,p in self.executables: # @UnusedVariable
self.ctools.add(e)
......
......@@ -12,8 +12,6 @@ from distutils.errors import DistutilsSetupError
from distutils import log
from distutils.ccompiler import show_compilers
import subprocess
class build_exe(Command):
description = "build an executable -- Abstract command "
......@@ -124,30 +122,28 @@ class build_exe(Command):
just returns otherwise.
"""
if not isinstance(executables, list):
raise DistutilsSetupError, \
"'executables' option must be a list of tuples"
raise DistutilsSetupError("'executables' option must be a list of tuples")
for exe in executables:
if not isinstance(exe, tuple) and len(exe) != 2:
raise DistutilsSetupError, \
"each element of 'executables' must a 2-tuple"
raise DistutilsSetupError("each element of 'executables' must a 2-tuple")
name, build_info = exe
if not isinstance(name, str):
raise DistutilsSetupError, \
"first element of each tuple in 'executables' " + \
"must be a string (the executables name)"
raise DistutilsSetupError(
"first element of each tuple in 'executables' "
"must be a string (the executables name)")
if '/' in name or (os.sep != '/' and os.sep in name):
raise DistutilsSetupError, \
("bad executable name '%s': " +
"may not contain directory separators") % \
exe[0]
raise DistutilsSetupError(
"bad executable name '%s': "
"may not contain directory separators" % exe[0])
if not isinstance(build_info, dict):
raise DistutilsSetupError, \
"second element of each tuple in 'executables' " + \
"must be a dictionary (build info)"
raise DistutilsSetupError(
"second element of each tuple in 'executables' "
"must be a dictionary (build info)")
def get_executable_names(self):
# Assume the executables list is valid -- 'check_executable_list()' is
......@@ -156,7 +152,7 @@ class build_exe(Command):
return None
exe_names = []
for (exe_name, build_info) in self.executables:
for (exe_name, build_info) in self.executables: # @UnusedVariable
exe_names.append(exe_name)
return exe_names
......@@ -164,13 +160,13 @@ class build_exe(Command):
def get_source_files(self):
self.check_executable_list(self.executables)
filenames = []
for (exe_name, build_info) in self.executables:
for (exe_name, build_info) in self.executables: # @UnusedVariable
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
raise DistutilsSetupError, \
("in 'executables' option (library '%s'), "
raise DistutilsSetupError(
"in 'executables' option (library '%s'), "
"'sources' must be present and must be "
"a list of source filenames") % exe_name
"a list of source filenames" % exe_name)
filenames.extend(sources)
return filenames
......@@ -182,10 +178,11 @@ class build_exe(Command):
for (exe_name, build_info) in executables:
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
raise DistutilsSetupError, \
("in 'executables' option (library '%s'), " +
"'sources' must be present and must be " +
"a list of source filenames") % exe_name
raise DistutilsSetupError(
"in 'executables' option (library '%s'), "
"'sources' must be present and must be "
"a list of source filenames" % exe_name)
sources = self.substitute_sources(exe_name,sources)
log.info("building '%s' program", exe_name)
......
......@@ -4,26 +4,29 @@ Created on 13 fevr. 2014
@author: coissac
'''
try:
from Cython.Distutils import build_ext as ori_build_ext # @UnresolvedImport
except ImportError:
from distutils.command.build_ext import build_ext as ori_build_ext
from distutils.errors import DistutilsSetupError
from distutils import log
import os
from Cython.Distutils import build_ext as ori_build_ext # @UnresolvedImport
from Cython.Compiler import Options as cython_options # @UnresolvedImport
from distutils.errors import DistutilsSetupError
class build_ext(ori_build_ext):
def modifyDocScripts(self):
print >>open("doc/sphinx/build_dir.txt","w"),self.build_lib
build_dir_file=open("doc/sphinx/build_dir.txt","w")
print(self.build_lib,file=build_dir_file)
build_dir_file.close()
def initialize_options(self):
ori_build_ext.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)
ori_build_ext.finalize_options(self) # @UndefinedVariable
self.set_undefined_options('littlebigman',
('littlebigman', 'littlebigman'))
......@@ -45,8 +48,8 @@ class build_ext(ori_build_ext):
name of the built file (see --> build_files)
"""
sources = list(sources)
for i in xrange(len(sources)):
print exe_name,sources[i],
for i in range(len(sources)):
message = "%s :-> %s" % (exe_name,sources[i])
if sources[i][0]=='@':
try:
filename = self.built_files[sources[i][1:]]
......@@ -55,15 +58,15 @@ class build_ext(ori_build_ext):
if os.path.isfile (tmpfilename):
filename = tmpfilename
else:
raise DistutilsSetupError, \
('The %s filename declared in the source '
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)
'built by the installation process' % (sources[i],
exe_name))
sources[i]=filename
print "changed to ",filename
log.info("%s changed to %s",message,filename)
else:
print " ok"
log.info("%s ok",message)
return sources
......@@ -76,16 +79,17 @@ class build_ext(ori_build_ext):
self.check_extensions_list(self.extensions)
for ext in self.extensions:
print "#####>",ext.sources
log.info("%s :-> %s",ext.name,ext.sources)
ext.sources = self.cython_sources(ext.sources, ext)
self.build_extension(ext)
def run(self):
self.modifyDocScripts()
ori_build_ext.run(self)
cython_options.annotate = True
ori_build_ext.run(self) # @UndefinedVariable
......@@ -7,13 +7,8 @@ Created on 20 oct. 2012
import os.path
from distutils.core import Command
from distutils.util import convert_path
from distutils import log, sysconfig
from distutils.dep_util import newer
from distutils import log
class build_files(Command):
def initialize_options(self):
......
'''
Created on 20 oct. 2012
@author: coissac
'''
from obidistutils.command.build_scripts import build_scripts
class build_filters(build_scripts):
pass
......@@ -6,14 +6,14 @@ Created on 20 oct. 2012
import os.path
from distutils.command.build_scripts import build_scripts as ori_build_scripts,\
first_line_re
from distutils.command.build_scripts import build_scripts as ori_build_scripts
from distutils.util import convert_path
from distutils import log, sysconfig
from distutils.dep_util import newer
from stat import ST_MODE
import re
first_line_re = re.compile('^#!.*python[0-9.]*([ \t].*)?$')
class build_scripts(ori_build_scripts):
......@@ -93,8 +93,10 @@ class build_scripts(ori_build_scripts):
if self.dry_run:
log.info("changing mode of %s", F)
else:
oldmode = os.stat(F)[ST_MODE] & 07777
newmode = (oldmode | 0555) & 07777
oldmode = os.stat(F)[ST_MODE]
oldmode = oldmode & 0o7777
newmode = (oldmode | 0o555) & 0o7777
if newmode != oldmode:
log.info("changing mode of %s from %o to %o",
F, oldmode, newmode)
......
'''
Created on 10 mars 2015
@author: coissac
'''
from sphinx.setup_command import BuildDoc as ori_build_sphinx # @UnresolvedImport
class build_sphinx(ori_build_sphinx):
'''
Build Sphinx documentation in html, epub and man formats
'''
description = __doc__
def run(self):
self.builder='html'
self.finalize_options()
ori_build_sphinx.run(self)
self.builder='epub'
self.finalize_options()
ori_build_sphinx.run(self)
self.builder='man'
self.finalize_options()
ori_build_sphinx.run(self)
\ No newline at end of file
......@@ -3,12 +3,12 @@ Created on 6 oct. 2014
@author: coissac
'''
from distutils.command.install import install as install_ori
#from setuptools.command.install import install as install_ori
class install(install_ori):
def __init__(self,dist):
install_ori.__init__(self, dist)
self.sub_commands.insert(0, ('build',lambda self: True))
# self.sub_commands.insert(0, ('build',lambda self: True))
self.sub_commands.append(('install_sphinx',lambda self: self.distribution.serenity))
......@@ -3,8 +3,8 @@ Created on 20 oct. 2012
@author: coissac
'''
from distutils.command.install_scripts import install_scripts as ori_install_scripts
import os.path
from distutils import log
......@@ -12,42 +12,32 @@ class install_scripts(ori_install_scripts):
def initialize_options(self):
ori_install_scripts.initialize_options(self)
self.deprecated_scripts = None
def revove_dot_py(self):
for filename in self.get_outputs():
pyfile = "%s.py" % filename
if os.path.exists(pyfile):
command = os.path.split(pyfile)[-1]
log.info('Removing deprecated .py form of the unix command : %s (file %s)' % (command,pyfile))
if not self.dry_run:
os.unlink(pyfile)
try:
if not self.dry_run:
os.unlink(os.path.join(self.build_dir,command))
except:
log.info('Unix command %s is not present in build dir' % command)
self.public_dir = None
def install_public_link(self):
self.mkpath(self.public_dir)
for file in self.get_outputs():
if self.dry_run:
log.info("changing mode of %s", file)
else:
log.info("exporting file %s -> %s", file,os.path.join(self.public_dir,
os.path.split(file)[1]
))
dest = os.path.join(self.public_dir,
os.path.split(file)[1]
)
if os.path.exists(dest):
os.unlink(dest)
os.symlink(file,dest)
def remove_deprecated_script(self):
if self.deprecated_scripts is not None:
for f in self.deprecated_scripts:
try:
ff = os.path.join(self.install_dir,f)
if not self.dry_run:
os.unlink(ff)
log.info('Removing deprecated unix command : %s (file : %s)' % (f,ff))
ff = os.path.join(self.build_dir,f)
if not self.dry_run:
os