From 4d7793021ebcb5f5163921e05f77a103dd852652 Mon Sep 17 00:00:00 2001
From: Jan Caron <j.caron@fz-juelich.de>
Date: Wed, 24 Jul 2013 12:19:49 +0200
Subject: [PATCH] Minor commit before rename, run_tests deleted (testing now by
 setuptools)

---
 pyramid/numcore/phase_mag_real.c |  2 +-
 scripts/create_logo.py           |  1 +
 setup.py                         | 42 +++++++++++++++-----------------
 test/__init__.py                 | 26 ++++++++++++++++++++
 test/run_tests.py                | 35 --------------------------
 test/test_compliance.py          |  6 +++--
 6 files changed, 51 insertions(+), 61 deletions(-)
 delete mode 100644 test/run_tests.py

diff --git a/pyramid/numcore/phase_mag_real.c b/pyramid/numcore/phase_mag_real.c
index 7d7b55e..3d391e9 100644
--- a/pyramid/numcore/phase_mag_real.c
+++ b/pyramid/numcore/phase_mag_real.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.19.1 on Tue Jul 23 11:18:13 2013 */
+/* Generated by Cython 0.19.1 on Tue Jul 23 16:03:31 2013 */
 
 #define PY_SSIZE_T_CLEAN
 #ifndef CYTHON_USE_PYLONG_INTERNALS
diff --git a/scripts/create_logo.py b/scripts/create_logo.py
index 070a48d..a83af16 100644
--- a/scripts/create_logo.py
+++ b/scripts/create_logo.py
@@ -1,3 +1,4 @@
+#! python
 # -*- coding: utf-8 -*-
 """Create the Pyramid-Logo."""
 
diff --git a/setup.py b/setup.py
index 1b9a5b4..d905996 100644
--- a/setup.py
+++ b/setup.py
@@ -15,40 +15,43 @@ import numpy
 import os
 import sys
 import sysconfig
+#import glob
 
-from distutils.core import setup
+#from distutils.core import setup
 from distutils.command.build import build
-from distutils.extension import Extension
+#from distutils.extension import Extension
+
 from Cython.Distutils import build_ext
 
-class custom_build(build):
-    def run(self):
-        build.run(self)
-        print 'Test'
+from setuptools import setup, find_packages
 
-def distutils_dir_name(dname):
-    '''Returns the name of a distutils build directory'''
-    path = "{dirname}.{platform}-{version[0]}.{version[1]}"
-    return path.format(dirname=dname, platform=sysconfig.get_platform(), version=sys.version_info)
+from setuptools.extension import Extension
 
 
-print '\n------------------------------------------------------------------------------'
+def make_hgrevision(target, source, env):
+    import subprocess as sp
+    output = sp.Popen(["hg", "id", "-i"], stdout=sp.PIPE).communicate()[0]
+    hgrevision_cc = file(str(target[0]), "w")
+    hgrevision_cc.write('HG_Revision = "{0}"\n'.format(output.strip()))
+    hgrevision_cc.close()
 
-build_path = os.path.join('build', distutils_dir_name('lib'))
+print '\n------------------------------------------------------------------------------'
 
 setup(
-
       name = 'Pyramid',
       version = '0.1',
       description = 'PYthon based Reconstruction Algorithm for MagnetIc Distributions',
       author = 'Jan Caron',
       author_email = 'j.caron@fz-juelich.de',
       
-      packages = ['pyramid', 'pyramid.numcore', 'pyramid.test'],
+      packages = find_packages(exclude=['test']),#['pyramid', 'pyramid.numcore', 'test', 'scripts'],
       include_dirs = [numpy.get_include()],
       requires = ['numpy', 'matplotlib'],
-                      
-      cmdclass = {'build_ext': build_ext, 'build': custom_build},
+      
+      scripts = ['scripts/create_logo.py'],
+      test_suite = 'test',
+      
+      cmdclass = {'build_ext': build_ext},
       ext_package = 'pyramid/numcore',
       ext_modules = [
           Extension('phase_mag_real', ['pyramid/numcore/phase_mag_real.pyx'], 
@@ -56,13 +59,6 @@ setup(
                     extra_compile_args=["-march=native", "-mtune=native"]
                     )
           ]
-
 )
 
-import os
-print os.getcwd()
-
 print '------------------------------------------------------------------------------\n'
-
-#import pyramid.test as test
-#test.run_tests()
diff --git a/test/__init__.py b/test/__init__.py
index e69de29..3827142 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -0,0 +1,26 @@
+import unittest
+from test_compliance import TestCaseCompliance
+from test_magcreator import TestCaseMagCreator
+from test_magdata import TestCaseMagData
+from test_projector import TestCaseProjector
+from test_phasemapper import TestCasePhaseMapper
+from test_phasemap import TestCasePhaseMap
+from test_holoimage import TestCaseHoloImage
+from test_analytic import TestCaseAnalytic
+from test_reconstructor import TestCaseReconstructor
+
+
+def load_suite():
+    
+    loader = unittest.TestLoader()
+    suite = unittest.TestSuite()
+    suite.addTest(loader.loadTestsFromTestCase(TestCaseCompliance))
+    suite.addTest(loader.loadTestsFromTestCase(TestCaseMagCreator))
+    suite.addTest(loader.loadTestsFromTestCase(TestCaseMagData))
+    suite.addTest(loader.loadTestsFromTestCase(TestCaseProjector))
+    suite.addTest(loader.loadTestsFromTestCase(TestCasePhaseMapper))
+    suite.addTest(loader.loadTestsFromTestCase(TestCasePhaseMap))
+    suite.addTest(loader.loadTestsFromTestCase(TestCaseHoloImage))
+    suite.addTest(loader.loadTestsFromTestCase(TestCaseAnalytic))
+    suite.addTest(loader.loadTestsFromTestCase(TestCaseReconstructor))
+    return suite
diff --git a/test/run_tests.py b/test/run_tests.py
deleted file mode 100644
index a3c6eb0..0000000
--- a/test/run_tests.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Unittests for pyramid."""
-
-import unittest
-from test_compliance import TestCaseCompliance
-from test_magcreator import TestCaseMagCreator
-from test_magdata import TestCaseMagData
-from test_projector import TestCaseProjector
-from test_phasemapper import TestCasePhaseMapper
-from test_phasemap import TestCasePhaseMap
-from test_holoimage import TestCaseHoloImage
-from test_analytic import TestCaseAnalytic
-from test_reconstructor import TestCaseReconstructor
-
-
-def run():
-
-    suite = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    runner = unittest.TextTestRunner(verbosity=2)
-
-    suite.addTest(loader.loadTestsFromTestCase(TestCaseCompliance))
-    suite.addTest(loader.loadTestsFromTestCase(TestCaseMagCreator))
-    suite.addTest(loader.loadTestsFromTestCase(TestCaseMagData))
-    suite.addTest(loader.loadTestsFromTestCase(TestCaseProjector))
-    suite.addTest(loader.loadTestsFromTestCase(TestCasePhaseMapper))
-    suite.addTest(loader.loadTestsFromTestCase(TestCasePhaseMap))
-    suite.addTest(loader.loadTestsFromTestCase(TestCaseHoloImage))
-    suite.addTest(loader.loadTestsFromTestCase(TestCaseAnalytic))
-    suite.addTest(loader.loadTestsFromTestCase(TestCaseReconstructor))
-    runner.run(suite)
-
-
-if __name__ == '__main__':
-    run()
diff --git a/test/test_compliance.py b/test/test_compliance.py
index ec901a1..a78ca84 100644
--- a/test/test_compliance.py
+++ b/test/test_compliance.py
@@ -30,14 +30,16 @@ class TestCaseCompliance(unittest.TestCase):
 
     def test_pep8(self):
         # TODO: Docstring
-        files = self.get_files_to_check('../../pyramid') + self.get_files_to_check('../../scripts')
+        files = self.get_files_to_check('pyramid') \
+              + self.get_files_to_check('scripts') \
+              + self.get_files_to_check('test')
         ignores = ('E226', 'E128')
         pep8.MAX_LINE_LENGTH = 99
         pep8style = pep8.StyleGuide(quiet=False)
         pep8style.options.ignore = ignores
 
         stdout_buffer = sys.stdout
-        with open(os.path.join('..', '..', 'output', 'pep8_log.txt'), 'w') as sys.stdout:
+        with open(os.path.join('output', 'pep8_log.txt'), 'w') as sys.stdout:
             print '<<< PEP8 LOGFILE >>>'
             print 'RUN:', datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
             print 'IGNORED RULES:', ', '.join(ignores)
-- 
GitLab