diff --git a/dfhack/python/build-linux b/dfhack/python/build-linux new file mode 100755 index 000000000..43145b5aa --- /dev/null +++ b/dfhack/python/build-linux @@ -0,0 +1,4 @@ +#!/bin/bash +python linsetup.py build_ext +cp build/lib.linux-i686-2.6/pydfhack.so . +rm -r build diff --git a/dfhack/python/linsetup.py b/dfhack/python/linsetup.py index 356300304..d29ae9103 100644 --- a/dfhack/python/linsetup.py +++ b/dfhack/python/linsetup.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- from distutils.core import setup, Extension +from os import path e = Extension("pydfhack", sources=["DF_API.cpp", "DF_Buildings.cpp", "DF_Constructions.cpp", "DF_CreatureManager.cpp", "DF_GUI.cpp", "DF_Maps.cpp", "DF_Material.cpp", "DF_Position.cpp", "DF_Translate.cpp", "DF_Vegetation.cpp", "pydfhack.cpp"], - include_dirs=["../", "../include", "../depends/md5", "../depends/tinyxml"], - library_dirs=["../../output"], - extra_compile_args=["-DLINUX_BUILD"], - libraries=["dfhack-debug"], - export_symbols=["initpydfhack", "ReadRaw", "WriteRaw"]) + include_dirs=["../", path.join("..", "include"), path.join("..","depends","md5"), path.join("..","depends","tinyxml")], + library_dirs=[path.join("..","..","output")], + extra_compile_args=["-DLINUX_BUILD", "-w"], + libraries=["dfhack"], + export_symbols=["initpydfhack", "ReadRaw", "WriteRaw"]) setup(name="PyDFHack", version="1.0", ext_modules=[e]) diff --git a/dfhack/python/pydfapi.py b/dfhack/python/pydfapi.py index 76aea332c..0cb4c5be3 100644 --- a/dfhack/python/pydfapi.py +++ b/dfhack/python/pydfapi.py @@ -1,21 +1,28 @@ -from pydfhack import * +import pydfhack, os -class API(_API): - def __init__(self, *args, **kwds): - _API.__init__(self, args, kwds) - - self._map_mgr_type = Map - self._vegetation_mgr_type = Vegetation - self._gui_mgr_type = GUI +class API(pydfhack._API): + for file in ["Memory.xml", os.path.join("..","..","output","Memory.xml")]: + if os.path.isfile(file): + datafile = file + break + else: + raise ImportError, "Memory.xml not found." + + def __init__(self, *args, **kwds): + pydfhack._API.__init__(self, API.datafile) + + self._map_mgr_type = Map + self._vegetation_mgr_type = Vegetation + self._gui_mgr_type = GUI -class Map(_MapManager): - def __init__(self, *args, **kwds): - _MapManager.__init__(self, args, kwds) +class Map(pydfhack._MapManager): + def __init__(self, *args, **kwds): + pydfhack._MapManager.__init__(self, args, kwds) -class Vegetation(_VegetationManager): - def __init__(self, *args, **kwds): - _VegetationManager.__init__(self, args, kwds) +class Vegetation(pydfhack._VegetationManager): + def __init__(self, *args, **kwds): + pydfhack._VegetationManager.__init__(self, args, kwds) -class GUI(_GUIManager): - def __init__(self, *args, **kwds): - _GUIManager.__init__(self, args, kwds) \ No newline at end of file +class GUI(pydfhack._GUIManager): + def __init__(self, *args, **kwds): + pydfhack._GUIManager.__init__(self, args, kwds) diff --git a/dfhack/python/test.py b/dfhack/python/test.py index 802c64b2b..558fb38c4 100644 --- a/dfhack/python/test.py +++ b/dfhack/python/test.py @@ -1,2 +1,9 @@ # -*- coding: utf-8 -*- -import pydfhack +import pydfapi + +print "Attempting to initialize pydfhack...", +DF = pydfapi.API() +Map = pydfapi.Map() +Vegetation = pydfapi.Vegetation() +GUI = pydfapi.GUI() +print "OK"