Skip to content
Snippets Groups Projects
Commit d422fd79 authored by Alessandro Mirone's avatar Alessandro Mirone
Browse files

ristrutturazione

parent 5f1c2353
No related branches found
No related tags found
No related merge requests found
python setup.py install --install-lib ./dummy
python setup.py install --install-lib ./dummy --install-scripts ./dummyscripts/
......@@ -5,6 +5,10 @@
// 1 oppure zero ( 0 --> non foglia )
// 8 puntatori a nodi oppure 3 elementi
#define ROOT 1
#define FOGLIA 0
class OctTree {
public:
OctTree( double P0, double P1, double P2, double D ); /// python
......
......@@ -12,10 +12,6 @@
#define ROOT 1
#define FOGLIA 0
#include"octree.h"
......
......@@ -15,7 +15,7 @@
%typemap(in) (int n, double * ArrayFLOAT) (PyArrayObject* tmp) {
tmp = (PyArrayObject *)PyArray_ContiguousFromObject($input, PyArray_DOUBLE, 1, 1);
if(tmp == NULL) return NULL;
$1 = Alen = tmp->dimensions[0];
$1 = tmp->dimensions[0];
$2 = (double *)tmp->data;
}
%typemap(freearg) (int n,double * ArrayFLOAT) {Py_DECREF(tmp$argnum);}
......@@ -36,7 +36,7 @@
}
%typemap(argout) ( int &n , int *&ArrIntRet ) {
%typemap(argout,fragment="t_output_helper") ( int &n , int *&ArrIntRet ) {
int nd=1;
int dims[1];
PyObject *arr_a;
......@@ -44,7 +44,7 @@
dims[0]= n$argnum;
nd=1;
dims[0]= n $argnum;
dims[0]= n$argnum;
arr_a = PyArray_FromDims(nd,dims,PyArray_INT) ;
memcpy( ( (PyArrayObject *) arr_a )->data , *$2 , dims[0]*sizeof(int) );
......@@ -58,7 +58,7 @@
%typemap(in, numinputs=0) ( int &n , double *&ArrFloatRet) ( int n , double * ArrFloatRet ) {
$1=&n;
$2=&ArrFloataRet;
$2=&ArrFloatRet;
}
......@@ -70,7 +70,7 @@
dims[0]= n$argnum;
nd=1;
dims[0]= n $argnum;
dims[0]= n$argnum;
arr_a = PyArray_FromDims(nd,dims,PyArray_DOUBLE) ;
memcpy( ( (PyArrayObject *) arr_a )->data , *$2 , dims[0]*sizeof(double) );
......@@ -101,6 +101,6 @@ public:
int &n , int *&ArrIntRet ); // python
// void getdatapointer(int &N, double *&data); // python
void getdatapointer(int &n , int *&ArrFloatRet ); // python
void getdatapointer(int &n , double *&ArrFloatRet ); // python
};
......@@ -17,169 +17,101 @@ global AB2TDS_SCRIPTS_DIR
# Append cvs tag if working from cvs tree
if os.path.isdir('.bzr') and os.path.isfile(os.sep.join(['.bzr', 'branch', 'last-revision'])):
revision = open( os.sep.join(['.bzr', 'branch', 'last-revision']) ).read()
if os.path.isdir('.git') and os.path.isfile(os.sep.join(['.git', 'logs', 'HEAD'])):
logs = open( os.sep.join(['.git', 'logs', 'HEAD']) ).read()
import re
revision = 0
revre = re.compile('committed-rev="(\d+)"')
for match in revre.finditer(open(os.sep.join(['.svn', 'entries'])).read()):
revision = max(revision, int(match.group(1)))
__version__ += 'dev_r%i' % revision
packages = ['ab2tds', 'ab2tds.octree']
for line in file(os.path.join('PyMca', 'PyMca.py')).readlines():
if line[:11] == '__version__':
exec(line)
# Append cvs tag if working from cvs tree
if os.path.isdir('.svn') and os.path.isfile(os.sep.join(['.svn', 'entries'])):
import re
revision = 0
revre = re.compile('committed-rev="(\d+)"')
for match in revre.finditer(open(os.sep.join(['.svn', 'entries'])).read()):
revision = max(revision, int(match.group(1)))
__version__ += 'dev_r%i' % revision
break
# Specify all the required PyMca data
data_files = [('PyMca', ['PyMca/Scofield1973.dict',
'PyMca/changelog.txt',
'PyMca/McaTheory.cfg',
'PyMca/PyMcaSplashImage.png',
'PyMca/KShellRates.dat','PyMca/KShellRatesScofieldHS.dat','PyMca/KShellConstants.dat',
'PyMca/LShellRates.dat','PyMca/LShellConstants.dat',
'PyMca/LShellRatesCampbell.dat','PyMca/LShellRatesScofieldHS.dat',
'PyMca/MShellRates.dat','PyMca/MShellConstants.dat']),
('PyMca/attdata', glob.glob('PyMca/attdata/*')),
('PyMca/HTML', glob.glob('PyMca/HTML/*.*')),
('PyMca/HTML/IMAGES', glob.glob('PyMca/HTML/IMAGES/*')),
('PyMca/HTML/PyMCA_files', glob.glob('PyMca/HTML/PyMCA_files/*'))]
# The following is not supported by python-2.3:
#package_data = {'PyMca': ['attdata/*', 'HTML/*.*', 'HTML/IMAGES/*', 'HTML/PyMCA_files/*']}
packages = ['PyMca']
sources = glob.glob('*.c')
sources = glob.glob('*.cc')
if sys.platform == "win32":
define_macros = [('WIN32',None)]
script_files = []
else:
define_macros = []
script_files = glob.glob('PyMca/scripts/*')
script_files = glob.glob('ab2tds/scripts/*')
files_to_check = glob.glob('ab2tds/octree/*.i')
for file in files_to_check:
stat_i = os.stat( file ).st_mtime
ok=0
wrapfile = file[:-2]+"_wrap.cxx"
if os.path.isfile( wrapfile):
stat_cxx = os.stat( wrapfile ).st_mtime
print stat_cxx
print stat_i
if stat_cxx > stat_i:
ok=1
if not ok :
print " GENERATING SWIG WRAPPER FOR ", file
if sys.platform == "win32":
raise Exception, "completa col comando per win32 "
else:
os.system("swig -c++ -python "+ file )
def build_FastEdf(ext_modules):
module = Extension(name = 'PyMca.FastEdf',
sources = glob.glob('PyMca/edf/*.c'),
define_macros = define_macros,
include_dirs = [numpy.get_include()])
ext_modules.append(module)
def build_specfile(ext_modules):
module = Extension(name = 'PyMca.specfile',
sources = glob.glob('PyMca/specfile/src/*.c'),
define_macros = define_macros,
include_dirs = ['PyMca/specfile/include',
numpy.get_include()])
ext_modules.append(module)
def build_specfit(ext_modules):
module = Extension(name = 'PyMca.SpecfitFuns',
sources = glob.glob('PyMca/specfit/*.c'),
define_macros = define_macros,
include_dirs = ['PyMca/specfit',
numpy.get_include()])
ext_modules.append(module)
def build_sps(ext_modules):
if platform.system() == 'Linux' :
extra_compile_args = ['-pthread']
#extra_compile_args = []
elif platform.system() == 'SunOS' :
#extra_compile_args = ['-pthreads']
extra_compile_args = []
else:
extra_compile_args = []
module = Extension(name = 'PyMca.spslut',
sources = ['PyMca/sps/Src/sps_lut.c',
'PyMca/sps/Src/spslut_py.c'],
define_macros = define_macros,
extra_compile_args = extra_compile_args,
include_dirs = ['PyMca/sps/Include',
numpy.get_include()])
def build_octree(ext_modules):
module = Extension(name = 'ab2tds.octree._octree',
sources = glob.glob('ab2tds/octree/*.cc')+
glob.glob('ab2tds/octree/*.cxx'),
define_macros = define_macros,
include_dirs = ['ab2tds/octree/include',
numpy.get_include()])
ext_modules.append(module)
if sys.platform != "win32":
module = (Extension(name = 'PyMca.sps',
sources = ['PyMca/sps/Src/sps.c',
'PyMca/sps/Src/sps_py.c'],
define_macros = define_macros,
extra_compile_args = extra_compile_args,
include_dirs = ['PyMca/sps/Include',
numpy.get_include()]))
ext_modules.append(module)
ext_modules = []
build_FastEdf(ext_modules)
build_specfile(ext_modules)
build_specfit(ext_modules)
build_sps(ext_modules)
build_octree(ext_modules)
# data_files fix from http://wiki.python.org/moin/DistutilsInstallDataScattered
from distutils.command.install_data import install_data
class smart_install_data(install_data):
def run(self):
global PYMCA_INSTALL_DIR
#need to change self.install_dir to the library dir
install_cmd = self.get_finalized_command('install')
self.install_dir = getattr(install_cmd, 'install_lib')
PYMCA_INSTALL_DIR = self.install_dir
print "PyMCA to be installed in %s" % self.install_dir
return install_data.run(self)
from distutils.command.install_scripts import install_scripts
class smart_install_scripts(install_scripts):
def run (self):
global PYMCA_SCRIPTS_DIR
global AB2TDS_SCRIPTS_DIR
#I prefer not to translate the python used during the build
#process for the case of having an installation on a disk shared
#by different machines and starting python from a shell script
#that positions the environment
from distutils import log
from stat import ST_MODE
install_cmd = self.get_finalized_command('install')
#This is to ignore the --install-scripts keyword
#I do not know if to leave it optional ...
if False:
self.install_dir = os.path.join(getattr(install_cmd, 'install_lib'), 'PyMca')
self.install_dir = os.path.join(getattr(install_cmd, 'install_lib'), 'ab2tds')
self.install_dir = os.path.join(self.install_dir, 'bin')
else:
self.install_dir = getattr(install_cmd, 'install_scripts')
PYMCA_SCRIPTS_DIR = self.install_dir
AB2TDS_SCRIPTS_DIR = self.install_dir
if sys.platform != "win32":
print "PyMCA scripts to be installed in %s" % self.install_dir
print "AB2TDS scripts to be installed in %s" % self.install_dir
self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
self.outfiles = []
for filein in glob.glob('PyMca/scripts/*'):
for filein in glob.glob('ab2tds/scripts/*'):
filedest = os.path.join(self.install_dir, os.path.basename(filein))
if os.path.exists(filedest):
os.remove(filedest)
moddir = os.path.join(getattr(install_cmd,'install_lib'), "PyMca")
moddir = os.path.join(getattr(install_cmd,'install_lib'), "ab2tds")
f = open(filein, 'r')
modfile = f.readline().replace("\n","")
f.close()
text = "#!/bin/bash\n"
text += "export PYTHONPATH=%s:${PYTHONPATH}\n" % moddir
text += "export LD_LIBRARY_PATH=%s:${LD_LIBRARY_PATH}\n" % moddir
text += "exec python %s $*\n" % os.path.join(moddir, modfile)
f=open(filedest, 'w')
f.write(text)
......@@ -201,155 +133,28 @@ description = ""
long_description = """
"""
distrib = setup(name="PyMca",
distrib = setup(name="ab2tds",
license = "GPL - Please read LICENSE.GPL for details",
version= __version__,
# version= logs,
description = description,
author = "V. Armando Sole",
author_email="sole@esrf.fr",
url = "http://sourceforge.net/projects/pymca",
author = "Alessandro Mirone",
author_email="mirone@esrf.fr",
url = "http://forge.epn-campus.fr/projects/ab2tds",
long_description = long_description,
packages = packages,
platforms='any',
ext_modules = ext_modules,
data_files = data_files,
## data_files = data_files,
## package_data = package_data,
## package_dir = {'': 'lib'},
cmdclass = {'install_data':smart_install_data,
'install_scripts':smart_install_scripts},
cmdclass = {
# 'install_data':smart_install_data,
'install_scripts':smart_install_scripts},
scripts=script_files,
)
#post installation checks
try:
import sip
SIP = True
except ImportError:
SIP = False
print "sip must be installed for full pymca functionality."
badtext = "No valid PyQt with PyQwt4 or PyQwt5 installation found.\n"
badtext += "No valid PyQt4 with PyQwt5 installation found.\n"
badtext += "You will only be able to develop applications using a very \n"
badtext += "small subset of PyMCA."
try:
print "PyMCA is installed in %s " % PYMCA_INSTALL_DIR
except NameError:
#I really do not see how this may happen but ...
pass
if SIP:
try:
import PyQt4.QtCore
QT4 = True
except ImportError:
QT4 = False
except:
QT4 = True
try:
from PyQt4 import Qwt5
QWT5 = True
except ImportError:
QWT5 = False
QT3 = False
QWT4 = False
if not QT4:
try:
import qt
QT3 = True
except ImportError:
QT3 = False
except:
pass
try:
import Qwt5 as qwt
QWT5 = True
except ImportError:
QWT5 = False
except:
pass
if not QWT5:
try:
import Qwt4 as qwt
QWT4 = True
except ImportError:
QWT4 = False
if not QWT4:
try:
import qwt
QWT4 = True
except ImportError:
QWT4 = False
if QT4 and QT3:
#print "PyMCA does not work in a mixed Qt4 and qt installation (yet)"
if QWT5:
print "You have PyQt4 and PyQwt5 installed."
print "PyMCA is fully functional under PyQt4 with PyQwt5."
print "You can easily embed PyMCA fitting in your Qt4 graphical "
print "applications using McaAdvancedFit.py"
else:
print badtext
elif QT3 and QWT5:
print "PyMCA PyQt installations tested with PyQwt4"
print "You have PyQwt5 installed. It should also work."
print "PyMCA installation successfully completed."
elif QT3 and not QWT4:
print "PyMCA PyQt installations need PyQwt5 or PyQwt4"
print badtext
elif QT4 and QWT5:
print "You have PyQt4 and PyQwt5 installed."
print "PyMCA is fully functional under PyQt4 with PyQwt5."
print "You can easily embed PyMCA fitting in your Qt4 graphical "
print "applications using McaAdvancedFit.py"
try:
if sys.platform != 'win32':
print "Please make sure %s is in your path" % PYMCA_SCRIPTS_DIR
print "and try the scripts:"
for script in script_files:
s = os.path.basename(script)
if s.upper() == "PYMCA":continue
if s.upper() == "MCA2EDF":continue
print script
except NameError:
pass
elif QT3 and QWT4:
print "PyMCA installation successfully completed."
try:
if sys.platform != 'win32':
print "Please make sure %s is in your path" % PYMCA_SCRIPTS_DIR
print "and try the scripts:"
for script in script_files:
print os.path.basename(script)
except NameError:
pass
else:
print badtext
else:
print "No valid PyQt with qwt or PyQt4 with PyQwt5 installation found."
print "You will only be able to develop applications using a very "
print "small subset of PyMCA."
......@@ -357,74 +162,6 @@ else:
#!/usr/bin/env python
# To use:
# python setup.py install
#
import os, sys, string, re
from glob import glob
import distutils
#try:
import distutils
from distutils.command.install import install
from distutils.core import setup, Extension
# except:
# raise SystemExit, "Distutils problem, see Numeric README."
headers = glob (os.path.join ("Include","*.h") )
header = headers + glob (os.path.join ("Include/Numeric","*.h") )
# The version is set in Lib/numeric_version.py
import numpy
if("USEGPU" in sys.argv):
libs = ['gputomo','gcc','m']
libsdirs = ['./GPU',"/var/NVIDIA_CUDA_SDK/lib/"]
SOURCES_forward=['PyHST_c_b.c']
LIBRARIES_FORWARD=["projection"]
else:
libs = ['gcc','m']
libsdirs = ['./' ]
LIBRARIES_FORWARD=[]
SOURCES_forward=['PyHST_c_b.c',"c_hst_project_1over.c"]
setup (name = "extension",
description = " Extension to Python",
ext_modules = [Extension('PyHST_c',
['PyHST_c.c',"Vhst_fourier.c","Vhst_calculate_limits.c"],
libraries=libs ,
include_dirs = [numpy.get_include(),'./'],
library_dirs = libsdirs,
),
Extension('PyHST_c_b',
SOURCES_forward,
include_dirs = [numpy.get_include(),'./'],
libraries=LIBRARIES_FORWARD+[ 'gcc','m'],
library_dirs = libsdirs,
),
# libraries=['efence', 'gcc','m'])
Extension('_cudadistributionmodule',
['./cudadistribution/cudadistribution_wrap.cxx' ],
libraries=["cudadistribution","stdc++",
"gcc",]+
["m"],
include_dirs = [numpy.get_include(),'./'],
library_dirs = ['./','./cudadistribution']
)
]
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment