|
From: <mk...@us...> - 2003-03-18 10:04:34
|
Update of /cvsroot/csp/APPLICATIONS/SimData
In directory sc8-pr-cvs1:/tmp/cvs-serv11687
Modified Files:
CHANGES.current README
Added Files:
setup.py
Log Message:
see CHANGES.current
--- NEW FILE: setup.py ---
from distutils.core import setup
from distutils.core import Extension
import distutils.command.build_ext
from distutils.command.build_ext import build_ext
import os, os.path, string
# REMEMBER TO 'touch Version.cpp' OR REBUILD ALL
VERSION = "\"0.3.1\""
class build_swig_ext(build_ext):
swig_options = ''
def build_extension(self, ext):
self.ext = ext
build_ext.build_extension(self, ext)
def swig_sources (self, sources):
"""Walk the list of source files in 'sources', looking for SWIG
interface (.i) files. Run SWIG on all that are found, and
return a modified 'sources' list with SWIG source files replaced
by the generated C (or C++) files.
"""
new_sources = []
swig_sources = []
swig_targets = {}
# XXX this drops generated C/C++ files into the source tree, which
# is fine for developers who want to distribute the generated
# source -- but there should be an option to put SWIG output in
# the temp dir.
self.swig_cpp = 1
if self.swig_cpp:
target_ext = '.cpp'
else:
target_ext = '.c'
for source in sources:
(base, ext) = os.path.splitext(source)
if ext == ".i": # SWIG interface file
new_sources.append(base + target_ext)
swig_sources.append(source)
swig_targets[source] = new_sources[-1]
else:
new_sources.append(source)
if not swig_sources:
return new_sources
swig = self.find_swig()
swig_cmd = [swig, "-python", "-c++"] + build_swig_ext.options.split()
if 1 or self.inplace:
fullname = self.get_ext_fullname(self.ext.name)
modpath = string.split(fullname, '.')
package = string.join(modpath[0:-1], '.')
base = modpath[-1]
build_py = self.get_finalized_command('build_py')
package_dir = build_py.get_package_dir(package)
else:
package_dir = self.build_lib
for source in swig_sources:
target = swig_targets[source]
self.announce("swigging %s to %s" % (source, target))
self.spawn(swig_cmd + ["-o", target, source])
(base, ext) = os.path.splitext(source)
proxy_full = base + '.py'
proxy = os.path.basename(proxy_full)
proxy_lib = os.path.join(self.build_lib, os.path.join(package_dir, proxy))
print proxy_full, "=>", proxy_lib
os.rename(proxy_full, proxy_lib)
return new_sources
orig_build_ext = build_ext
distutils.command.build_ext.build_ext = build_swig_ext
if os.name == "posix":
# changes the compiler from gcc to g++
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def gpp_init_posix():
print 'gpp_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig._config_vars
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
sysconfig._init_posix = gpp_init_posix
sources = [
"BaseType",
"DataArchive",
"Date",
"Enum",
"Exception",
"External",
"GeoPos",
"HashUtility",
"InterfaceRegistry",
"Interpolate",
"List",
"LogStream",
"Math",
"Matrix3",
"Object",
"Pack",
"Path",
"Quaternion",
"Random",
"Spread",
"TypeAdapter",
"Vector3",
"Version",
]
headers = [
"BaseType.h",
"DataArchive.h",
"Date.h",
"Enum.h",
"Exception.h",
"Export.h",
"External.h",
"GeoPos.h",
"GlibCsp.h",
"hash_map.h",
"HashUtility.h",
"Integer.h",
"InterfaceRegistry.h",
"Interpolate.h",
"List.h",
"Log.h",
"LogStream.h",
"Math.h",
"Matrix3.h",
"ns-simdata.h",
"Object.h",
"ObjectInterface.h",
"Pack.h",
"Path.h",
"Quaternion.h",
"Random.h",
"Real.h",
"Spread.h",
"String.h",
"TypeAdapter.h",
"Types.h",
"Vector3.h",
"Version.h",
]
interfaces = [
"cSimData"
]
def fullpath(path, ext, list):
return map(lambda x: path+x+ext, list)
sources = fullpath("Source/", ".cpp", sources)
interfaces = fullpath("Source/", ".i", interfaces)
headers = fullpath("Include/SimData/", "", headers)
build_swig_ext.options = "-DUSE_NAMESPACE_SIMDATA -IInclude -noexcept"
includes = ["Include"]
defines = [("USE_NAMESPACE_SIMDATA", None), ("SIMDATA_VERSION", VERSION)]
libraries = ["swigpy", "dl"]
cflags = []
cSimData = Extension("SimData._cSimData",
sources + interfaces,
include_dirs = includes,
define_macros = defines,
libraries = libraries,
extra_compile_args = cflags,
)
setup(name="SimData",
version=VERSION,
description="Simulation Data Abstraction Library",
author="Mark Rose",
author_email="mr...@st...",
url="http://csp.sourceforge.net/wiki/",
packages=['SimData'],
headers = headers,
ext_modules = [cSimData],
)
Index: CHANGES.current
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/CHANGES.current,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CHANGES.current 15 Mar 2003 02:26:43 -0000 1.2
--- CHANGES.current 18 Mar 2003 10:03:59 -0000 1.3
***************
*** 2,5 ****
--- 2,35 ----
===========================
+ 2003-03-17: onsight
+ Fixes to MS VC.net fixes. Lather, rinse, repeat... ;-)
+
+ 2003-03-17: delta
+ Fixes for building with MS VC.Net
+
+ 2003-03-16: onsight
+ Created a new setup.py script to allow SimData to be build and
+ installed using Python DistUtils. This works on Linux/GCC but
+ needs to be tested on other platforms. The Makefile will remain
+ as a backup until the setup.py script is stable.
+
+ Restructured the installation as a SimData packages, with the
+ extension module (cSimData) and tools (DataCompiler) underneath.
+ SimData/__init__.py now contains the code that was in
+ SimData.py. The net effect is that you just import SimData as
+ usual, but the data compiler is now SimData.Compiler. I'm moving
+ away from a standalone compiler approach, since it depends on
+ the external library that you are compiling for. Instead, the
+ external program should load SimData, register its object
+ interfaces, and run the compiler if needed by creating an
+ instance of class Compile (from SimData.Compiler).
+
+ Restructured the argument processing and usage messages of
+ Compiler.Compile to interact better with the calling code (when
+ not used as a standalone compiler). The main application should
+ process any command line arguments it recognizes and pass the
+ rest to Compile.parse(), catching any exceptions that are
+ raised.
+
2003-03-13: onsight
Fixed several bugs related to std::vector types
***************
*** 17,20 ****
--- 47,52 ----
usual ostream operators (<<).
+ *** NEW FEATURE ***
+ *** POTENTIAL INCOMPATIBILITY ***
Added a new postCreate() method in Object which is called after
unpack() is complete. You can extend this to do additional
***************
*** 22,25 ****
--- 54,58 ----
be the exact inverse operation of pack().
+ *** NEW FEATURE ***
Data compiler enhancements, mainly the ability to only reparse
xml files that have changed since the archive was last
***************
*** 28,31 ****
--- 61,65 ----
entire archive from scratch.
+ *** POTENTIAL INCOMPATIBILITY ***
Big simplification of the various smart pointer types.
PathPointer<T> is gone; now just use Pointer<T> for all object
Index: README
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/README,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** README 28 Jan 2003 23:26:04 -0000 1.2
--- README 18 Mar 2003 10:03:59 -0000 1.3
***************
*** 11,112 ****
CAVEATS
! This library is ALPHA! Do not expect it to be polished in any way.
! It does work, at least under the proper conditions, which is why it
! has been released. Only through testing and use will it evolve into
! a robust and stable platform for utilizing XML data in simulations.
SimData is written primarily for the Combat Simulator Project (CSP)
! <http://csp.sourceforge.net>. It is, nonetheless, intended to be
! a fully independent library that can be used with any application
! desiring fast runtime axis to large, static XML data sets.
! SimData was developed entirely under Linux using GCC 2.95 and 3.0.
! It is intended to compile with other versions of GCC and under other
! the Windows operating system, but this has not been tested and I
! expect there will be some initial incompatibilities. If you
! encounter problems, please report them (with patches if possible) to
! the CSP developer's forum at http://csp.sourceforge.net/forum.
! PRE-BUILDING
! There are Makefiles for Linux/GCC, but no build system for other
! platforms. I'm relying on users of such platforms to provide build
! scripts using the Linux Makefiles as a starting point. These will
! be included in CVS as soon as they are available.
! On Linux, edit the top level Makefile to customize any settings
! to your particular system. The path to the Python headers is an
! example of a parameter you might want to check. Eventually I'll
! make some autoconf scripts to handle this step automatically.
- You will need both SWIG and Python in order to utilize SimData.
- While it may be technically possible to build SimData without
- these tools, the Data Compiler (which is essential to the use
- of SimData) is currently written in Python and relies on the
- SWIG-wrapped interface to SimData, so there is little point in
- building SimData without these.
! Python can be obtained in a number of convenient installation
! packages from sources listed at http://www.python.org. Be sure
! to use Python 2.2 or higher. It may work with Python 2.1 but I
! make no guarantees.
! For SWIG, version 1.3.16 or higher is recommended. SWIG can
! be downloaded as source or binary from http://www.swig.org.
! BUILDING
! Just run make in the top-level directory. If all goes well
! this will create _cSimData.so and libSimData.a in the Source
! directory.
- TESTING
! As a quick test, change to the Source directory and run Python.
! Try typing "import SimData". You should see a line similar to
! "loaded @ 0x4883012". If not, something went wrong... post to
! the CSP developer's forum and we can try to find the problem.
- USING SIMDATA WITH CSPSIM
! The new CSP application called CSPSim relies on SimData in
! two ways. First, libSimData.a is statically linked to make
! the CSPSim executable. Second, the simulation data for CSPSim
! needs to be compiled from XML source files to a binary data
! archive using the data compiler application included with
! SimData. This Python program is found in the directory
! Tools/DataCompiler. Once you have built your CSPSim executable,
! go to Tools/DataCompiler and run Compiler.py (from a command
! prompt on windows you would probably need to type something like
! "python Compiler.py"). If the Compiler can't find CSPSim
! initially, it will prompt you to enter a path to CSPSim. This
! path is saved in a file named .csp_path so you shouldn't have
! to do this more than once. The Compiler will then print a
! usage message and exit. To compile the data for CSPSim, you
! must specify the top level data directory to archive, and the
! name of the output archive. Given the standard location of
! the files in CVS, you would type:
! ./Compiler.py ../../../CSPSim/Data/Sim ../../../CSPSim/Data/Sim.dar
- This will parse all the XML files under CSPSim/Data/Sim and create
- the a binary archive (named Sim.dar) needed to run CSPSim. A
- script named "make_simdar" that runs the above command is provided
- for your convienience. This must be rerun whenever you modify
- the XML data files to incorporate the changes into Sim.dar.
- BUILDING on Windows with msvc++6(sp5), stlport-4.5.3 (hints)
- 1) Install python2.2 and swig 1.3.17
- 2) Add python path to your global path
- 3) Load SimDataMSVC.dsw
- 4) Build it in release mode; in process, it should create a new file
- called cSimData_wrap.cpp (this file name should already be in
- project/Source) from cSimData.i which is parsed by swig.
- 5) Testing procedure is same as above.
\ No newline at end of file
--- 11,90 ----
CAVEATS
! This library is ALPHA! Do not expect it to be polished in any way. It
! does work, at least under the proper conditions, which is why it has
! been released. Only through testing and use will it evolve into a robust
! and stable platform for utilizing XML data in simulations.
SimData is written primarily for the Combat Simulator Project (CSP)
! <http://csp.sourceforge.net>. It is, nonetheless, intended to be a fully
! independent library that can be used with any application desiring fast
! runtime access to large, static XML data sets.
! SimData was initially developed under Linux using GCC 2.95 and 3.0.
! Current development occurs mainly under GCC 3.2. The library also
! receives routine testing under MS VC6 and now .NET as part of the Combat
! Simulator Project. If you encounter problems, please report them (with
! patches if possible) to the CSP developer's forum at
! http://csp.sourceforge.net/forum.
+ REQUIREMENTS
! Minimally, SimData can operate as a standalone library that provides
! a number of C++ data classes useful for simulations. In this mode
! there are no external dependencies.
! To use the XML interface and data archiving features, however, requires
! both SWIG and Python. SWIG is available from http://www.swig.org, and
! should be version 1.3.16 or newer. Python is preinstalled on many
! Linux systems, and prepackaged distributions for both Windows and
! Linux are available from http://www.python.org. Python version 2.2 or
! newer is required. Under Windows, be sure to add the Python path to
! your global path so that VC can find it.
! If you are using MS VC6 you will also need have at least SP5 installed
! and a functional STL implementation, such as STLport (version 4.5.3 or
! newer).
! BUILDING: ANNOUNCEMENT
! The build process is currently depends on Makefiles (Linux) and VC
! project files (Windows), but will likely transition to Python's
! DistUtils soon. Stay tuned....
! BUILDING: LINUX
! On Linux, edit the top level Makefile to customize any settings to your
! particular system. The path to the Python headers is an example of a
! parameter you might want to check.
+ Next, just run make in the top-level directory. If all goes well this
+ will create cSimData.py, _cSimData.so, and libSimData.a in the Source
+ directory.
! BUILDING: VC6/.NET
+ Load SimDataMSVC.dsw and build it in release mode. In the process, it
+ should create a new file called cSimData_wrap.cpp (this file name should
+ already be in project/Source) from cSimData.i which is parsed by SWIG.
! TESTING
! As a quick test, change to the Source directory and run Python. Try
! typing "import SimData". You should see a line similar to "loaded @
! 0x4883012". If not, something went wrong... post to the CSP developer's
! forum and we can try to find the problem.
+ INSTALLING AND USING SIMDATA
+
+ Currently you should not do anything to install SimData. CSPSim expects
+ SimData to be in the same relative path as it is in the CVS tree. This
+ situation is not optimal and will change as soon as the DistUtils
+ installer is working.
|