Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add setup_nbt.py and setupnbt64.bat. try to import _nbt without using…

… ImportError, in case it was built using setup_nbt.py
  • Loading branch information...
commit 3703015f8629f38112a4cedf509c7a6b36a2bc20 1 parent 6ba1634
@codewarrior0 authored
Showing with 26 additions and 3 deletions.
  1. +8 −3 nbt.py
  2. +12 −0 setup_nbt.py
  3. +6 −0 setupnbt64.bat
View
11 nbt.py
@@ -1,8 +1,13 @@
try:
import os
- os.environ['DISTUTILS_USE_SDK'] = "1"
- from pyximport import install; install()
- from _nbt import *
+ try:
+ import _nbt
+ from _nbt import *
+ except ImportError:
+ print "Import error loading precompiled _nbt extension. Trying pyximport..."
+ from pyximport import install; install()
+ import _nbt
+ from _nbt import *
except ImportError, e:
print "Import error loading _nbt extension", repr(e)
import traceback; traceback.print_exc()
View
12 setup_nbt.py
@@ -0,0 +1,12 @@
+
+from distutils.core import setup
+from distutils.extension import Extension
+from Cython.Distutils import build_ext
+
+ext_modules = [Extension("_nbt", ["_nbt.pyx"])]
+
+setup(
+ name = 'NBT library (Cython implementation)',
+ cmdclass = {'build_ext': build_ext},
+ ext_modules = ext_modules
+)
View
6 setupnbt64.bat
@@ -0,0 +1,6 @@
+call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat"
+set DISTUTILS_USE_SDK=1
+set MSSdk=1
+c:\python26-64\python setup_nbt.py build_ext
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.