annotate setup-exe.py @ 205:166a23999bf7

Added confvar okexitcodemask; changed the validator protocol Callable validators now return three-tuples (number granted, bool correct, str comment) instead of two-tuples (number granted, str comment). They are still allowed to return single numbers. Callable validators must now explicitly raise upreckon.exceptions.WrongAnswer if they want the verdict to be Wrong Answer rather than Partly Correct. okexitcodemask specifies a bitmask ANDed with the exit code of the external validator to get a boolean flag showing whether the answer is to be marked as 'OK' rather than 'partly correct'. The bits covered by the bitmask are reset to zeroes before devising the number of points granted from the resulting number.
author Oleg Oshmyan <chortos@inbox.lv>
date Wed, 17 Aug 2011 20:44:54 +0300
parents fe03964896ef
children ad4362bf9858 9d21cef40e5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
147
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
1 #! /usr/bin/env python
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
2 from cx_Freeze import setup, Executable, build_exe
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
3 from distutils.core import Extension
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
4 from distutils.command.build_ext import build_ext
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
5 from distutils.errors import CCompilerError
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
6 from distutils import log
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
7 import os
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
8
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
9 class build_opt_ext(build_ext):
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
10 def build_extension(self, ext):
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
11 try:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
12 build_ext.build_extension(self, ext)
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
13 except CCompilerError:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
14 log.warn("Failed to build native extension '%s' (skipping)",
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
15 ext.name)
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
16
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
17 try:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
18 from sys import maxsize
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
19 except ImportError:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
20 from sys import maxint as maxsize
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
21 if maxsize < 2**32:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
22 arch = 'x86'
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
23 else:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
24 arch = 'amd64'
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
25 direct = (R'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\%s'
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
26 R'\Microsoft.VC90.CRT' % arch)
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
27 files = ['msvcr90.dll', 'Microsoft.VC90.CRT.manifest']
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
28 msvcrt_files = [os.path.join(direct, name) for name in files]
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
29
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
30 os.rename('upreckon/unix.py', 'upreckon/unix.py~')
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
31 try:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
32 setup(name='Upreckon',
184
4df9537ed261 Updated version numbers
Oleg Oshmyan <chortos@inbox.lv>
parents: 147
diff changeset
33 version='2.03.0dev',
147
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
34 author='Oleg Oshmyan',
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
35 author_email='chortos@inbox.lv',
188
fe03964896ef Updated home page URL
Oleg Oshmyan <chortos@inbox.lv>
parents: 184
diff changeset
36 url='http://chortos.selfip.net/~astiob/upreckon/',
147
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
37 #description='',
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
38 #long_description='',
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
39 download_url='https://bitbucket.org/astiob/upreckon/downloads',
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
40 #platforms=(),
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
41 #license='',
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
42 #ext_modules=[Extension('upreckon._unix',
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
43 # sources=['upreckon/_unixmodule.cpp'])],
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
44 executables=[Executable('upreckon/upreckon')],
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
45 data_files=[('', msvcrt_files)],
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
46 cmdclass={'build_ext': build_opt_ext},
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
47 )
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
48 finally:
37955420fd66 Added a cx_Freeze-based setup-exe.py for Windows
Oleg Oshmyan <chortos@inbox.lv>
parents:
diff changeset
49 os.rename('upreckon/unix.py~', 'upreckon/unix.py')