Show More
@@ -1,23 +1,24 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """The IPython1 kernel. |
|
3 | 3 | |
|
4 | 4 | The IPython kernel actually refers to three things: |
|
5 | 5 | |
|
6 | 6 | * The IPython Engine |
|
7 | 7 | * The IPython Controller |
|
8 | 8 | * Clients to the IPython Controller |
|
9 | 9 | |
|
10 | 10 | The kernel module implements the engine, controller and client and all the |
|
11 | 11 | network protocols needed for the various entities to talk to each other. |
|
12 | 12 | |
|
13 | 13 | An end user should probably begin by looking at the `client.py` module |
|
14 | 14 | if they need blocking clients or in `asyncclient.py` if they want asynchronous, |
|
15 | 15 | deferred/Twisted using clients. |
|
16 | 16 | """ |
|
17 | 17 | __docformat__ = "restructuredtext en" |
|
18 | 18 | #------------------------------------------------------------------------------- |
|
19 | 19 | # Copyright (C) 2008 The IPython Development Team |
|
20 | 20 | # |
|
21 | 21 | # Distributed under the terms of the BSD License. The full license is in |
|
22 | 22 | # the file COPYING, distributed as part of this software. |
|
23 | 23 | #------------------------------------------------------------------------------- |
|
24 | No newline at end of file |
@@ -1,40 +1,43 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | """This file contains unittests for the kernel.engineservice.py module. |
|
4 | 4 | |
|
5 | 5 | Things that should be tested: |
|
6 | 6 | |
|
7 | 7 | - Should the EngineService return Deferred objects? |
|
8 | 8 | - Run the same tests that are run in shell.py. |
|
9 | 9 | - Make sure that the Interface is really implemented. |
|
10 | 10 | - The startService and stopService methods. |
|
11 | 11 | """ |
|
12 | 12 | |
|
13 | 13 | __docformat__ = "restructuredtext en" |
|
14 | 14 | |
|
15 | 15 | #------------------------------------------------------------------------------- |
|
16 | 16 | # Copyright (C) 2008 The IPython Development Team |
|
17 | 17 | # |
|
18 | 18 | # Distributed under the terms of the BSD License. The full license is in |
|
19 | 19 | # the file COPYING, distributed as part of this software. |
|
20 | 20 | #------------------------------------------------------------------------------- |
|
21 | 21 | |
|
22 | 22 | #------------------------------------------------------------------------------- |
|
23 | 23 | # Imports |
|
24 | 24 | #------------------------------------------------------------------------------- |
|
25 | 25 | |
|
26 | try: | |
|
26 | 27 | from twisted.application.service import IService |
|
27 | 28 | from IPython.kernel.controllerservice import ControllerService |
|
28 | 29 | from IPython.kernel.tests import multienginetest as met |
|
29 | 30 | from controllertest import IControllerCoreTestCase |
|
30 | 31 | from IPython.testing.util import DeferredTestCase |
|
31 | ||
|
32 | except ImportError: | |
|
33 | pass | |
|
34 | else: | |
|
32 | 35 | class BasicControllerServiceTest(DeferredTestCase, |
|
33 | 36 | IControllerCoreTestCase): |
|
34 | 37 | |
|
35 | 38 | def setUp(self): |
|
36 | 39 | self.controller = ControllerService() |
|
37 | 40 | self.controller.startService() |
|
38 | 41 | |
|
39 | 42 | def tearDown(self): |
|
40 | 43 | self.controller.stopService() |
@@ -1,89 +1,92 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | """This file contains unittests for the enginepb.py module.""" |
|
4 | 4 | |
|
5 | 5 | __docformat__ = "restructuredtext en" |
|
6 | 6 | |
|
7 | 7 | #------------------------------------------------------------------------------- |
|
8 | 8 | # Copyright (C) 2008 The IPython Development Team |
|
9 | 9 | # |
|
10 | 10 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | 11 | # the file COPYING, distributed as part of this software. |
|
12 | 12 | #------------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | #------------------------------------------------------------------------------- |
|
15 | 15 | # Imports |
|
16 | 16 | #------------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | ||
|
18 | try: | |
|
19 | 19 | from twisted.python import components |
|
20 | 20 | from twisted.internet import reactor, defer |
|
21 | 21 | from twisted.spread import pb |
|
22 | 22 | from twisted.internet.base import DelayedCall |
|
23 | 23 | DelayedCall.debug = True |
|
24 | 24 | |
|
25 | 25 | import zope.interface as zi |
|
26 | 26 | |
|
27 | 27 | from IPython.kernel.fcutil import Tub, UnauthenticatedTub |
|
28 | 28 | from IPython.kernel import engineservice as es |
|
29 | 29 | from IPython.testing.util import DeferredTestCase |
|
30 | 30 | from IPython.kernel.controllerservice import IControllerBase |
|
31 | 31 | from IPython.kernel.enginefc import FCRemoteEngineRefFromService, IEngineBase |
|
32 | 32 | from IPython.kernel.engineservice import IEngineQueued |
|
33 | 33 | from IPython.kernel.engineconnector import EngineConnector |
|
34 | 34 | |
|
35 | 35 | from IPython.kernel.tests.engineservicetest import \ |
|
36 | 36 | IEngineCoreTestCase, \ |
|
37 | 37 | IEngineSerializedTestCase, \ |
|
38 | 38 | IEngineQueuedTestCase |
|
39 | ||
|
39 | except ImportError: | |
|
40 | print "we got an error!!!" | |
|
41 | pass | |
|
42 | else: | |
|
40 | 43 | class EngineFCTest(DeferredTestCase, |
|
41 | 44 | IEngineCoreTestCase, |
|
42 | 45 | IEngineSerializedTestCase, |
|
43 | 46 | IEngineQueuedTestCase |
|
44 | 47 | ): |
|
45 | 48 | |
|
46 | 49 | zi.implements(IControllerBase) |
|
47 | 50 | |
|
48 | 51 | def setUp(self): |
|
49 | 52 | |
|
50 | 53 | # Start a server and append to self.servers |
|
51 | 54 | self.controller_reference = FCRemoteEngineRefFromService(self) |
|
52 | 55 | self.controller_tub = Tub() |
|
53 | 56 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') |
|
54 | 57 | self.controller_tub.setLocation('127.0.0.1:10105') |
|
55 | 58 | |
|
56 | 59 | furl = self.controller_tub.registerReference(self.controller_reference) |
|
57 | 60 | self.controller_tub.startService() |
|
58 | 61 | |
|
59 | 62 | # Start an EngineService and append to services/client |
|
60 | 63 | self.engine_service = es.EngineService() |
|
61 | 64 | self.engine_service.startService() |
|
62 | 65 | self.engine_tub = Tub() |
|
63 | 66 | self.engine_tub.startService() |
|
64 | 67 | engine_connector = EngineConnector(self.engine_tub) |
|
65 | 68 | d = engine_connector.connect_to_controller(self.engine_service, furl) |
|
66 | 69 | # This deferred doesn't fire until after register_engine has returned and |
|
67 | 70 | # thus, self.engine has been defined and the tets can proceed. |
|
68 | 71 | return d |
|
69 | 72 | |
|
70 | 73 | def tearDown(self): |
|
71 | 74 | dlist = [] |
|
72 | 75 | # Shut down the engine |
|
73 | 76 | d = self.engine_tub.stopService() |
|
74 | 77 | dlist.append(d) |
|
75 | 78 | # Shut down the controller |
|
76 | 79 | d = self.controller_tub.stopService() |
|
77 | 80 | dlist.append(d) |
|
78 | 81 | return defer.DeferredList(dlist) |
|
79 | 82 | |
|
80 | 83 | #--------------------------------------------------------------------------- |
|
81 | 84 | # Make me look like a basic controller |
|
82 | 85 | #--------------------------------------------------------------------------- |
|
83 | 86 | |
|
84 | 87 | def register_engine(self, engine_ref, id=None, ip=None, port=None, pid=None): |
|
85 | 88 | self.engine = IEngineQueued(IEngineBase(engine_ref)) |
|
86 | 89 | return {'id':id} |
|
87 | 90 | |
|
88 | 91 | def unregister_engine(self, id): |
|
89 | 92 | pass No newline at end of file |
@@ -1,64 +1,66 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | """This file contains unittests for the kernel.engineservice.py module. |
|
4 | 4 | |
|
5 | 5 | Things that should be tested: |
|
6 | 6 | |
|
7 | 7 | - Should the EngineService return Deferred objects? |
|
8 | 8 | - Run the same tests that are run in shell.py. |
|
9 | 9 | - Make sure that the Interface is really implemented. |
|
10 | 10 | - The startService and stopService methods. |
|
11 | 11 | """ |
|
12 | 12 | |
|
13 | 13 | __docformat__ = "restructuredtext en" |
|
14 | 14 | |
|
15 | 15 | #------------------------------------------------------------------------------- |
|
16 | 16 | # Copyright (C) 2008 The IPython Development Team |
|
17 | 17 | # |
|
18 | 18 | # Distributed under the terms of the BSD License. The full license is in |
|
19 | 19 | # the file COPYING, distributed as part of this software. |
|
20 | 20 | #------------------------------------------------------------------------------- |
|
21 | 21 | |
|
22 | 22 | #------------------------------------------------------------------------------- |
|
23 | 23 | # Imports |
|
24 | 24 | #------------------------------------------------------------------------------- |
|
25 | 25 | |
|
26 | try: | |
|
26 | 27 | from twisted.internet import defer |
|
27 | 28 | from twisted.application.service import IService |
|
28 | 29 | |
|
29 | 30 | from IPython.kernel import engineservice as es |
|
30 | 31 | from IPython.testing.util import DeferredTestCase |
|
31 | 32 | from IPython.kernel.tests.engineservicetest import \ |
|
32 | 33 | IEngineCoreTestCase, \ |
|
33 | 34 | IEngineSerializedTestCase, \ |
|
34 | 35 | IEngineQueuedTestCase, \ |
|
35 | 36 | IEnginePropertiesTestCase |
|
36 | ||
|
37 | ||
|
37 | except ImportError: | |
|
38 | pass | |
|
39 | else: | |
|
38 | 40 | class BasicEngineServiceTest(DeferredTestCase, |
|
39 | 41 | IEngineCoreTestCase, |
|
40 | 42 | IEngineSerializedTestCase, |
|
41 | 43 | IEnginePropertiesTestCase): |
|
42 | 44 | |
|
43 | 45 | def setUp(self): |
|
44 | 46 | self.engine = es.EngineService() |
|
45 | 47 | self.engine.startService() |
|
46 | 48 | |
|
47 | 49 | def tearDown(self): |
|
48 | 50 | return self.engine.stopService() |
|
49 | 51 | |
|
50 | 52 | class QueuedEngineServiceTest(DeferredTestCase, |
|
51 | 53 | IEngineCoreTestCase, |
|
52 | 54 | IEngineSerializedTestCase, |
|
53 | 55 | IEnginePropertiesTestCase, |
|
54 | 56 | IEngineQueuedTestCase): |
|
55 | 57 | |
|
56 | 58 | def setUp(self): |
|
57 | 59 | self.rawEngine = es.EngineService() |
|
58 | 60 | self.rawEngine.startService() |
|
59 | 61 | self.engine = es.IEngineQueued(self.rawEngine) |
|
60 | 62 | |
|
61 | 63 | def tearDown(self): |
|
62 | 64 | return self.rawEngine.stopService() |
|
63 | 65 | |
|
64 | 66 |
@@ -1,52 +1,54 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | """""" |
|
4 | 4 | |
|
5 | 5 | __docformat__ = "restructuredtext en" |
|
6 | 6 | |
|
7 | 7 | #------------------------------------------------------------------------------- |
|
8 | 8 | # Copyright (C) 2008 The IPython Development Team |
|
9 | 9 | # |
|
10 | 10 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | 11 | # the file COPYING, distributed as part of this software. |
|
12 | 12 | #------------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | #------------------------------------------------------------------------------- |
|
15 | 15 | # Imports |
|
16 | 16 | #------------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | try: | |
|
18 | 19 | from twisted.internet import defer |
|
19 | 20 | from IPython.testing.util import DeferredTestCase |
|
20 | 21 | from IPython.kernel.controllerservice import ControllerService |
|
21 | 22 | from IPython.kernel import multiengine as me |
|
22 | 23 | from IPython.kernel.tests.multienginetest import (IMultiEngineTestCase, |
|
23 | 24 | ISynchronousMultiEngineTestCase) |
|
24 | ||
|
25 | ||
|
25 | except ImportError: | |
|
26 | pass | |
|
27 | else: | |
|
26 | 28 | class BasicMultiEngineTestCase(DeferredTestCase, IMultiEngineTestCase): |
|
27 | 29 | |
|
28 | 30 | def setUp(self): |
|
29 | 31 | self.controller = ControllerService() |
|
30 | 32 | self.controller.startService() |
|
31 | 33 | self.multiengine = me.IMultiEngine(self.controller) |
|
32 | 34 | self.engines = [] |
|
33 | 35 | |
|
34 | 36 | def tearDown(self): |
|
35 | 37 | self.controller.stopService() |
|
36 | 38 | for e in self.engines: |
|
37 | 39 | e.stopService() |
|
38 | 40 | |
|
39 | 41 | |
|
40 | 42 | class SynchronousMultiEngineTestCase(DeferredTestCase, ISynchronousMultiEngineTestCase): |
|
41 | 43 | |
|
42 | 44 | def setUp(self): |
|
43 | 45 | self.controller = ControllerService() |
|
44 | 46 | self.controller.startService() |
|
45 | 47 | self.multiengine = me.ISynchronousMultiEngine(me.IMultiEngine(self.controller)) |
|
46 | 48 | self.engines = [] |
|
47 | 49 | |
|
48 | 50 | def tearDown(self): |
|
49 | 51 | self.controller.stopService() |
|
50 | 52 | for e in self.engines: |
|
51 | 53 | e.stopService() |
|
52 | 54 |
@@ -1,68 +1,70 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # encoding: utf-8 |
|
3 | 3 | |
|
4 | 4 | __docformat__ = "restructuredtext en" |
|
5 | 5 | |
|
6 | 6 | #------------------------------------------------------------------------------- |
|
7 | 7 | # Copyright (C) 2008 The IPython Development Team |
|
8 | 8 | # |
|
9 | 9 | # Distributed under the terms of the BSD License. The full license is in |
|
10 | 10 | # the file COPYING, distributed as part of this software. |
|
11 | 11 | #------------------------------------------------------------------------------- |
|
12 | 12 | |
|
13 | 13 | #------------------------------------------------------------------------------- |
|
14 | 14 | # Imports |
|
15 | 15 | #------------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | try: | |
|
17 | 18 | from twisted.internet import defer, reactor |
|
18 | 19 | |
|
19 | 20 | from IPython.kernel.fcutil import Tub, UnauthenticatedTub |
|
20 | 21 | |
|
21 | 22 | from IPython.testing.util import DeferredTestCase |
|
22 | 23 | from IPython.kernel.controllerservice import ControllerService |
|
23 | 24 | from IPython.kernel.multiengine import IMultiEngine |
|
24 | 25 | from IPython.kernel.tests.multienginetest import IFullSynchronousMultiEngineTestCase |
|
25 | 26 | from IPython.kernel.multienginefc import IFCSynchronousMultiEngine |
|
26 | 27 | from IPython.kernel import multiengine as me |
|
27 | 28 | from IPython.kernel.clientconnector import ClientConnector |
|
28 | ||
|
29 | ||
|
29 | except ImportError: | |
|
30 | pass | |
|
31 | else: | |
|
30 | 32 | class FullSynchronousMultiEngineTestCase(DeferredTestCase, IFullSynchronousMultiEngineTestCase): |
|
31 | 33 | |
|
32 | 34 | def setUp(self): |
|
33 | 35 | |
|
34 | 36 | self.engines = [] |
|
35 | 37 | |
|
36 | 38 | self.controller = ControllerService() |
|
37 | 39 | self.controller.startService() |
|
38 | 40 | self.imultiengine = IMultiEngine(self.controller) |
|
39 | 41 | self.mec_referenceable = IFCSynchronousMultiEngine(self.imultiengine) |
|
40 | 42 | |
|
41 | 43 | self.controller_tub = Tub() |
|
42 | 44 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') |
|
43 | 45 | self.controller_tub.setLocation('127.0.0.1:10105') |
|
44 | 46 | |
|
45 | 47 | furl = self.controller_tub.registerReference(self.mec_referenceable) |
|
46 | 48 | self.controller_tub.startService() |
|
47 | 49 | |
|
48 | 50 | self.client_tub = ClientConnector() |
|
49 | 51 | d = self.client_tub.get_multiengine_client(furl) |
|
50 | 52 | d.addCallback(self.handle_got_client) |
|
51 | 53 | return d |
|
52 | 54 | |
|
53 | 55 | def handle_got_client(self, client): |
|
54 | 56 | self.multiengine = client |
|
55 | 57 | |
|
56 | 58 | def tearDown(self): |
|
57 | 59 | dlist = [] |
|
58 | 60 | # Shut down the multiengine client |
|
59 | 61 | d = self.client_tub.tub.stopService() |
|
60 | 62 | dlist.append(d) |
|
61 | 63 | # Shut down the engines |
|
62 | 64 | for e in self.engines: |
|
63 | 65 | e.stopService() |
|
64 | 66 | # Shut down the controller |
|
65 | 67 | d = self.controller_tub.stopService() |
|
66 | 68 | d.addBoth(lambda _: self.controller.stopService()) |
|
67 | 69 | dlist.append(d) |
|
68 | 70 | return defer.DeferredList(dlist) |
@@ -1,99 +1,102 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | """This file contains unittests for the shell.py module.""" |
|
4 | 4 | |
|
5 | 5 | __docformat__ = "restructuredtext en" |
|
6 | 6 | |
|
7 | 7 | #------------------------------------------------------------------------------- |
|
8 | 8 | # Copyright (C) 2008 The IPython Development Team |
|
9 | 9 | # |
|
10 | 10 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | 11 | # the file COPYING, distributed as part of this software. |
|
12 | 12 | #------------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | #------------------------------------------------------------------------------- |
|
15 | 15 | # Imports |
|
16 | 16 | #------------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | try: | |
|
18 | 19 | import zope.interface as zi |
|
19 | 20 | from twisted.trial import unittest |
|
20 | 21 | from IPython.testing.util import DeferredTestCase |
|
21 | 22 | |
|
22 | 23 | from IPython.kernel.newserialized import \ |
|
23 | 24 | ISerialized, \ |
|
24 | 25 | IUnSerialized, \ |
|
25 | 26 | Serialized, \ |
|
26 | 27 | UnSerialized, \ |
|
27 | 28 | SerializeIt, \ |
|
28 | 29 | UnSerializeIt |
|
29 | ||
|
30 | except ImportError: | |
|
31 | pass | |
|
32 | else: | |
|
30 | 33 | #------------------------------------------------------------------------------- |
|
31 | 34 | # Tests |
|
32 | 35 | #------------------------------------------------------------------------------- |
|
33 | 36 | |
|
34 | 37 | class SerializedTestCase(unittest.TestCase): |
|
35 | 38 | |
|
36 | 39 | def setUp(self): |
|
37 | 40 | pass |
|
38 | 41 | |
|
39 | 42 | def tearDown(self): |
|
40 | 43 | pass |
|
41 | 44 | |
|
42 | 45 | def testSerializedInterfaces(self): |
|
43 | 46 | |
|
44 | 47 | us = UnSerialized({'a':10, 'b':range(10)}) |
|
45 | 48 | s = ISerialized(us) |
|
46 | 49 | uss = IUnSerialized(s) |
|
47 | 50 | self.assert_(ISerialized.providedBy(s)) |
|
48 | 51 | self.assert_(IUnSerialized.providedBy(us)) |
|
49 | 52 | self.assert_(IUnSerialized.providedBy(uss)) |
|
50 | 53 | for m in list(ISerialized): |
|
51 | 54 | self.assert_(hasattr(s, m)) |
|
52 | 55 | for m in list(IUnSerialized): |
|
53 | 56 | self.assert_(hasattr(us, m)) |
|
54 | 57 | for m in list(IUnSerialized): |
|
55 | 58 | self.assert_(hasattr(uss, m)) |
|
56 | 59 | |
|
57 | 60 | def testPickleSerialized(self): |
|
58 | 61 | obj = {'a':1.45345, 'b':'asdfsdf', 'c':10000L} |
|
59 | 62 | original = UnSerialized(obj) |
|
60 | 63 | originalSer = ISerialized(original) |
|
61 | 64 | firstData = originalSer.getData() |
|
62 | 65 | firstTD = originalSer.getTypeDescriptor() |
|
63 | 66 | firstMD = originalSer.getMetadata() |
|
64 | 67 | self.assert_(firstTD == 'pickle') |
|
65 | 68 | self.assert_(firstMD == {}) |
|
66 | 69 | unSerialized = IUnSerialized(originalSer) |
|
67 | 70 | secondObj = unSerialized.getObject() |
|
68 | 71 | for k, v in secondObj.iteritems(): |
|
69 | 72 | self.assert_(obj[k] == v) |
|
70 | 73 | secondSer = ISerialized(UnSerialized(secondObj)) |
|
71 | 74 | self.assert_(firstData == secondSer.getData()) |
|
72 | 75 | self.assert_(firstTD == secondSer.getTypeDescriptor() ) |
|
73 | 76 | self.assert_(firstMD == secondSer.getMetadata()) |
|
74 | 77 | |
|
75 | 78 | def testNDArraySerialized(self): |
|
76 | 79 | try: |
|
77 | 80 | import numpy |
|
78 | 81 | except ImportError: |
|
79 | 82 | pass |
|
80 | 83 | else: |
|
81 | 84 | a = numpy.linspace(0.0, 1.0, 1000) |
|
82 | 85 | unSer1 = UnSerialized(a) |
|
83 | 86 | ser1 = ISerialized(unSer1) |
|
84 | 87 | td = ser1.getTypeDescriptor() |
|
85 | 88 | self.assert_(td == 'ndarray') |
|
86 | 89 | md = ser1.getMetadata() |
|
87 | 90 | self.assert_(md['shape'] == a.shape) |
|
88 | 91 | self.assert_(md['dtype'] == a.dtype.str) |
|
89 | 92 | buff = ser1.getData() |
|
90 | 93 | self.assert_(buff == numpy.getbuffer(a)) |
|
91 | 94 | s = Serialized(buff, td, md) |
|
92 | 95 | us = IUnSerialized(s) |
|
93 | 96 | final = us.getObject() |
|
94 | 97 | self.assert_(numpy.getbuffer(a) == numpy.getbuffer(final)) |
|
95 | 98 | self.assert_(a.dtype.str == final.dtype.str) |
|
96 | 99 | self.assert_(a.shape == final.shape) |
|
97 | 100 | |
|
98 | 101 | |
|
99 | 102 | No newline at end of file |
@@ -1,215 +1,218 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # encoding: utf-8 |
|
3 | 3 | |
|
4 | 4 | """Tests for pendingdeferred.py""" |
|
5 | 5 | |
|
6 | 6 | __docformat__ = "restructuredtext en" |
|
7 | 7 | |
|
8 | 8 | #------------------------------------------------------------------------------- |
|
9 | 9 | # Copyright (C) 2008 The IPython Development Team |
|
10 | 10 | # |
|
11 | 11 | # Distributed under the terms of the BSD License. The full license is in |
|
12 | 12 | # the file COPYING, distributed as part of this software. |
|
13 | 13 | #------------------------------------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | #------------------------------------------------------------------------------- |
|
16 | 16 | # Imports |
|
17 | 17 | #------------------------------------------------------------------------------- |
|
18 | 18 | |
|
19 | try: | |
|
19 | 20 | from twisted.internet import defer |
|
20 | 21 | from twisted.python import failure |
|
21 | 22 | |
|
22 | 23 | from IPython.testing import tcommon |
|
23 | 24 | from IPython.testing.tcommon import * |
|
24 | 25 | from IPython.testing.util import DeferredTestCase |
|
25 | 26 | import IPython.kernel.pendingdeferred as pd |
|
26 | 27 | from IPython.kernel import error |
|
27 | 28 | from IPython.kernel.util import printer |
|
28 | ||
|
29 | except ImportError: | |
|
30 | pass | |
|
31 | else: | |
|
29 | 32 | |
|
30 | 33 | #------------------------------------------------------------------------------- |
|
31 | 34 | # Setup for inline and standalone doctests |
|
32 | 35 | #------------------------------------------------------------------------------- |
|
33 | 36 | |
|
34 | 37 | |
|
35 | 38 | # If you have standalone doctests in a separate file, set their names in the |
|
36 | 39 | # dt_files variable (as a single string or a list thereof): |
|
37 | 40 | dt_files = [] |
|
38 | 41 | |
|
39 | 42 | # If you have any modules whose docstrings should be scanned for embedded tests |
|
40 | 43 | # as examples accorging to standard doctest practice, set them here (as a |
|
41 | 44 | # single string or a list thereof): |
|
42 | 45 | dt_modules = [] |
|
43 | 46 | |
|
44 | 47 | #------------------------------------------------------------------------------- |
|
45 | 48 | # Regular Unittests |
|
46 | 49 | #------------------------------------------------------------------------------- |
|
47 | 50 | |
|
48 | 51 | |
|
49 | 52 | class Foo(object): |
|
50 | 53 | |
|
51 | 54 | def bar(self, bahz): |
|
52 | 55 | return defer.succeed('blahblah: %s' % bahz) |
|
53 | 56 | |
|
54 | 57 | class TwoPhaseFoo(pd.PendingDeferredManager): |
|
55 | 58 | |
|
56 | 59 | def __init__(self, foo): |
|
57 | 60 | self.foo = foo |
|
58 | 61 | pd.PendingDeferredManager.__init__(self) |
|
59 | 62 | |
|
60 | 63 | @pd.two_phase |
|
61 | 64 | def bar(self, bahz): |
|
62 | 65 | return self.foo.bar(bahz) |
|
63 | 66 | |
|
64 | 67 | class PendingDeferredManagerTest(DeferredTestCase): |
|
65 | 68 | |
|
66 | 69 | def setUp(self): |
|
67 | 70 | self.pdm = pd.PendingDeferredManager() |
|
68 | 71 | |
|
69 | 72 | def tearDown(self): |
|
70 | 73 | pass |
|
71 | 74 | |
|
72 | 75 | def testBasic(self): |
|
73 | 76 | dDict = {} |
|
74 | 77 | # Create 10 deferreds and save them |
|
75 | 78 | for i in range(10): |
|
76 | 79 | d = defer.Deferred() |
|
77 | 80 | did = self.pdm.save_pending_deferred(d) |
|
78 | 81 | dDict[did] = d |
|
79 | 82 | # Make sure they are begin saved |
|
80 | 83 | for k in dDict.keys(): |
|
81 | 84 | self.assert_(self.pdm.quick_has_id(k)) |
|
82 | 85 | # Get the pending deferred (block=True), then callback with 'foo' and compare |
|
83 | 86 | for did in dDict.keys()[0:5]: |
|
84 | 87 | d = self.pdm.get_pending_deferred(did,block=True) |
|
85 | 88 | dDict[did].callback('foo') |
|
86 | 89 | d.addCallback(lambda r: self.assert_(r=='foo')) |
|
87 | 90 | # Get the pending deferreds with (block=False) and make sure ResultNotCompleted is raised |
|
88 | 91 | for did in dDict.keys()[5:10]: |
|
89 | 92 | d = self.pdm.get_pending_deferred(did,block=False) |
|
90 | 93 | d.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) |
|
91 | 94 | # Now callback the last 5, get them and compare. |
|
92 | 95 | for did in dDict.keys()[5:10]: |
|
93 | 96 | dDict[did].callback('foo') |
|
94 | 97 | d = self.pdm.get_pending_deferred(did,block=False) |
|
95 | 98 | d.addCallback(lambda r: self.assert_(r=='foo')) |
|
96 | 99 | |
|
97 | 100 | def test_save_then_delete(self): |
|
98 | 101 | d = defer.Deferred() |
|
99 | 102 | did = self.pdm.save_pending_deferred(d) |
|
100 | 103 | self.assert_(self.pdm.quick_has_id(did)) |
|
101 | 104 | self.pdm.delete_pending_deferred(did) |
|
102 | 105 | self.assert_(not self.pdm.quick_has_id(did)) |
|
103 | 106 | |
|
104 | 107 | def test_save_get_delete(self): |
|
105 | 108 | d = defer.Deferred() |
|
106 | 109 | did = self.pdm.save_pending_deferred(d) |
|
107 | 110 | d2 = self.pdm.get_pending_deferred(did,True) |
|
108 | 111 | d2.addErrback(lambda f: self.assertRaises(error.AbortedPendingDeferredError, f.raiseException)) |
|
109 | 112 | self.pdm.delete_pending_deferred(did) |
|
110 | 113 | return d2 |
|
111 | 114 | |
|
112 | 115 | def test_double_get(self): |
|
113 | 116 | d = defer.Deferred() |
|
114 | 117 | did = self.pdm.save_pending_deferred(d) |
|
115 | 118 | d2 = self.pdm.get_pending_deferred(did,True) |
|
116 | 119 | d3 = self.pdm.get_pending_deferred(did,True) |
|
117 | 120 | d3.addErrback(lambda f: self.assertRaises(error.InvalidDeferredID, f.raiseException)) |
|
118 | 121 | |
|
119 | 122 | def test_get_after_callback(self): |
|
120 | 123 | d = defer.Deferred() |
|
121 | 124 | did = self.pdm.save_pending_deferred(d) |
|
122 | 125 | d.callback('foo') |
|
123 | 126 | d2 = self.pdm.get_pending_deferred(did,True) |
|
124 | 127 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) |
|
125 | 128 | self.assert_(not self.pdm.quick_has_id(did)) |
|
126 | 129 | |
|
127 | 130 | def test_get_before_callback(self): |
|
128 | 131 | d = defer.Deferred() |
|
129 | 132 | did = self.pdm.save_pending_deferred(d) |
|
130 | 133 | d2 = self.pdm.get_pending_deferred(did,True) |
|
131 | 134 | d.callback('foo') |
|
132 | 135 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) |
|
133 | 136 | self.assert_(not self.pdm.quick_has_id(did)) |
|
134 | 137 | d = defer.Deferred() |
|
135 | 138 | did = self.pdm.save_pending_deferred(d) |
|
136 | 139 | d2 = self.pdm.get_pending_deferred(did,True) |
|
137 | 140 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) |
|
138 | 141 | d.callback('foo') |
|
139 | 142 | self.assert_(not self.pdm.quick_has_id(did)) |
|
140 | 143 | |
|
141 | 144 | def test_get_after_errback(self): |
|
142 | 145 | class MyError(Exception): |
|
143 | 146 | pass |
|
144 | 147 | d = defer.Deferred() |
|
145 | 148 | did = self.pdm.save_pending_deferred(d) |
|
146 | 149 | d.errback(failure.Failure(MyError('foo'))) |
|
147 | 150 | d2 = self.pdm.get_pending_deferred(did,True) |
|
148 | 151 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
149 | 152 | self.assert_(not self.pdm.quick_has_id(did)) |
|
150 | 153 | |
|
151 | 154 | def test_get_before_errback(self): |
|
152 | 155 | class MyError(Exception): |
|
153 | 156 | pass |
|
154 | 157 | d = defer.Deferred() |
|
155 | 158 | did = self.pdm.save_pending_deferred(d) |
|
156 | 159 | d2 = self.pdm.get_pending_deferred(did,True) |
|
157 | 160 | d.errback(failure.Failure(MyError('foo'))) |
|
158 | 161 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
159 | 162 | self.assert_(not self.pdm.quick_has_id(did)) |
|
160 | 163 | d = defer.Deferred() |
|
161 | 164 | did = self.pdm.save_pending_deferred(d) |
|
162 | 165 | d2 = self.pdm.get_pending_deferred(did,True) |
|
163 | 166 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
164 | 167 | d.errback(failure.Failure(MyError('foo'))) |
|
165 | 168 | self.assert_(not self.pdm.quick_has_id(did)) |
|
166 | 169 | |
|
167 | 170 | def test_noresult_noblock(self): |
|
168 | 171 | d = defer.Deferred() |
|
169 | 172 | did = self.pdm.save_pending_deferred(d) |
|
170 | 173 | d2 = self.pdm.get_pending_deferred(did,False) |
|
171 | 174 | d2.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) |
|
172 | 175 | |
|
173 | 176 | def test_with_callbacks(self): |
|
174 | 177 | d = defer.Deferred() |
|
175 | 178 | d.addCallback(lambda r: r+' foo') |
|
176 | 179 | d.addCallback(lambda r: r+' bar') |
|
177 | 180 | did = self.pdm.save_pending_deferred(d) |
|
178 | 181 | d2 = self.pdm.get_pending_deferred(did,True) |
|
179 | 182 | d.callback('bam') |
|
180 | 183 | d2.addCallback(lambda r: self.assertEquals(r,'bam foo bar')) |
|
181 | 184 | |
|
182 | 185 | def test_with_errbacks(self): |
|
183 | 186 | class MyError(Exception): |
|
184 | 187 | pass |
|
185 | 188 | d = defer.Deferred() |
|
186 | 189 | d.addCallback(lambda r: 'foo') |
|
187 | 190 | d.addErrback(lambda f: 'caught error') |
|
188 | 191 | did = self.pdm.save_pending_deferred(d) |
|
189 | 192 | d2 = self.pdm.get_pending_deferred(did,True) |
|
190 | 193 | d.errback(failure.Failure(MyError('bam'))) |
|
191 | 194 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
192 | 195 | |
|
193 | 196 | def test_nested_deferreds(self): |
|
194 | 197 | d = defer.Deferred() |
|
195 | 198 | d2 = defer.Deferred() |
|
196 | 199 | d.addCallback(lambda r: d2) |
|
197 | 200 | did = self.pdm.save_pending_deferred(d) |
|
198 | 201 | d.callback('foo') |
|
199 | 202 | d3 = self.pdm.get_pending_deferred(did,False) |
|
200 | 203 | d3.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) |
|
201 | 204 | d2.callback('bar') |
|
202 | 205 | d3 = self.pdm.get_pending_deferred(did,False) |
|
203 | 206 | d3.addCallback(lambda r: self.assertEquals(r,'bar')) |
|
204 | 207 | |
|
205 | 208 | #------------------------------------------------------------------------------- |
|
206 | 209 | # Regular Unittests |
|
207 | 210 | #------------------------------------------------------------------------------- |
|
208 | 211 | |
|
209 | 212 | # This ensures that the code will run either standalone as a script, or that it |
|
210 | 213 | # can be picked up by Twisted's `trial` test wrapper to run all the tests. |
|
211 | 214 | if tcommon.pexpect is not None: |
|
212 | 215 | if __name__ == '__main__': |
|
213 | 216 | unittest.main(testLoader=IPDocTestLoader(dt_files,dt_modules)) |
|
214 | 217 | else: |
|
215 | 218 | testSuite = lambda : makeTestSuite(__name__,dt_files,dt_modules) |
@@ -1,47 +1,50 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | |
|
3 | 3 | """This file contains unittests for the kernel.task.py module.""" |
|
4 | 4 | |
|
5 | 5 | __docformat__ = "restructuredtext en" |
|
6 | 6 | |
|
7 | 7 | #------------------------------------------------------------------------------- |
|
8 | 8 | # Copyright (C) 2008 The IPython Development Team |
|
9 | 9 | # |
|
10 | 10 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | 11 | # the file COPYING, distributed as part of this software. |
|
12 | 12 | #------------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | #------------------------------------------------------------------------------- |
|
15 | 15 | # Imports |
|
16 | 16 | #------------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | try: | |
|
18 | 19 | import time |
|
19 | 20 | |
|
20 | 21 | from twisted.internet import defer |
|
21 | 22 | from twisted.trial import unittest |
|
22 | 23 | |
|
23 | 24 | from IPython.kernel import task, controllerservice as cs, engineservice as es |
|
24 | 25 | from IPython.kernel.multiengine import IMultiEngine |
|
25 | 26 | from IPython.testing.util import DeferredTestCase |
|
26 | 27 | from IPython.kernel.tests.tasktest import ITaskControllerTestCase |
|
27 | ||
|
28 | except ImportError: | |
|
29 | pass | |
|
30 | else: | |
|
28 | 31 | #------------------------------------------------------------------------------- |
|
29 | 32 | # Tests |
|
30 | 33 | #------------------------------------------------------------------------------- |
|
31 | 34 | |
|
32 | 35 | class BasicTaskControllerTestCase(DeferredTestCase, ITaskControllerTestCase): |
|
33 | 36 | |
|
34 | 37 | def setUp(self): |
|
35 | 38 | self.controller = cs.ControllerService() |
|
36 | 39 | self.controller.startService() |
|
37 | 40 | self.multiengine = IMultiEngine(self.controller) |
|
38 | 41 | self.tc = task.ITaskController(self.controller) |
|
39 | 42 | self.tc.failurePenalty = 0 |
|
40 | 43 | self.engines=[] |
|
41 | 44 | |
|
42 | 45 | def tearDown(self): |
|
43 | 46 | self.controller.stopService() |
|
44 | 47 | for e in self.engines: |
|
45 | 48 | e.stopService() |
|
46 | 49 | |
|
47 | 50 |
@@ -1,86 +1,90 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # encoding: utf-8 |
|
3 | 3 | |
|
4 | 4 | __docformat__ = "restructuredtext en" |
|
5 | 5 | |
|
6 | 6 | #------------------------------------------------------------------------------- |
|
7 | 7 | # Copyright (C) 2008 The IPython Development Team |
|
8 | 8 | # |
|
9 | 9 | # Distributed under the terms of the BSD License. The full license is in |
|
10 | 10 | # the file COPYING, distributed as part of this software. |
|
11 | 11 | #------------------------------------------------------------------------------- |
|
12 | 12 | |
|
13 | 13 | #------------------------------------------------------------------------------- |
|
14 | 14 | # Imports |
|
15 | 15 | #------------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | try: | |
|
17 | 18 | import time |
|
18 | 19 | |
|
19 | 20 | from twisted.internet import defer, reactor |
|
20 | 21 | |
|
21 | 22 | from IPython.kernel.fcutil import Tub, UnauthenticatedTub |
|
22 | 23 | |
|
23 | 24 | from IPython.kernel import task as taskmodule |
|
24 | 25 | from IPython.kernel import controllerservice as cs |
|
25 | 26 | import IPython.kernel.multiengine as me |
|
26 | 27 | from IPython.testing.util import DeferredTestCase |
|
27 | 28 | from IPython.kernel.multienginefc import IFCSynchronousMultiEngine |
|
28 | 29 | from IPython.kernel.taskfc import IFCTaskController |
|
29 | 30 | from IPython.kernel.util import printer |
|
30 | 31 | from IPython.kernel.tests.tasktest import ITaskControllerTestCase |
|
31 | 32 | from IPython.kernel.clientconnector import ClientConnector |
|
33 | except ImportError: | |
|
34 | pass | |
|
35 | else: | |
|
32 | 36 | |
|
33 | 37 | #------------------------------------------------------------------------------- |
|
34 | 38 | # Tests |
|
35 | 39 | #------------------------------------------------------------------------------- |
|
36 | 40 | |
|
37 | 41 | class TaskTest(DeferredTestCase, ITaskControllerTestCase): |
|
38 | 42 | |
|
39 | 43 | def setUp(self): |
|
40 | 44 | |
|
41 | 45 | self.engines = [] |
|
42 | 46 | |
|
43 | 47 | self.controller = cs.ControllerService() |
|
44 | 48 | self.controller.startService() |
|
45 | 49 | self.imultiengine = me.IMultiEngine(self.controller) |
|
46 | 50 | self.itc = taskmodule.ITaskController(self.controller) |
|
47 | 51 | self.itc.failurePenalty = 0 |
|
48 | 52 | |
|
49 | 53 | self.mec_referenceable = IFCSynchronousMultiEngine(self.imultiengine) |
|
50 | 54 | self.tc_referenceable = IFCTaskController(self.itc) |
|
51 | 55 | |
|
52 | 56 | self.controller_tub = Tub() |
|
53 | 57 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') |
|
54 | 58 | self.controller_tub.setLocation('127.0.0.1:10105') |
|
55 | 59 | |
|
56 | 60 | mec_furl = self.controller_tub.registerReference(self.mec_referenceable) |
|
57 | 61 | tc_furl = self.controller_tub.registerReference(self.tc_referenceable) |
|
58 | 62 | self.controller_tub.startService() |
|
59 | 63 | |
|
60 | 64 | self.client_tub = ClientConnector() |
|
61 | 65 | d = self.client_tub.get_multiengine_client(mec_furl) |
|
62 | 66 | d.addCallback(self.handle_mec_client) |
|
63 | 67 | d.addCallback(lambda _: self.client_tub.get_task_client(tc_furl)) |
|
64 | 68 | d.addCallback(self.handle_tc_client) |
|
65 | 69 | return d |
|
66 | 70 | |
|
67 | 71 | def handle_mec_client(self, client): |
|
68 | 72 | self.multiengine = client |
|
69 | 73 | |
|
70 | 74 | def handle_tc_client(self, client): |
|
71 | 75 | self.tc = client |
|
72 | 76 | |
|
73 | 77 | def tearDown(self): |
|
74 | 78 | dlist = [] |
|
75 | 79 | # Shut down the multiengine client |
|
76 | 80 | d = self.client_tub.tub.stopService() |
|
77 | 81 | dlist.append(d) |
|
78 | 82 | # Shut down the engines |
|
79 | 83 | for e in self.engines: |
|
80 | 84 | e.stopService() |
|
81 | 85 | # Shut down the controller |
|
82 | 86 | d = self.controller_tub.stopService() |
|
83 | 87 | d.addBoth(lambda _: self.controller.stopService()) |
|
84 | 88 | dlist.append(d) |
|
85 | 89 | return defer.DeferredList(dlist) |
|
86 | 90 |
@@ -1,31 +1,36 | |||
|
1 | 1 | include README_Windows.txt |
|
2 | 2 | include win32_manual_post_install.py |
|
3 | 3 | include ipython.py |
|
4 | 4 | |
|
5 | 5 | graft scripts |
|
6 | 6 | |
|
7 | 7 | graft setupext |
|
8 | 8 | |
|
9 | 9 | graft IPython/UserConfig |
|
10 | 10 | |
|
11 | graft IPython/kernel | |
|
12 | graft IPython/config | |
|
13 | graft IPython/testing | |
|
14 | graft IPython/tools | |
|
15 | ||
|
11 | 16 | graft doc |
|
12 | 17 | exclude doc/\#* |
|
13 | 18 | exclude doc/*.1 |
|
14 | 19 | exclude doc/ChangeLog.* |
|
15 | 20 | exclude doc/update_version.sh |
|
16 | 21 | |
|
17 | 22 | # There seems to be no way of excluding whole subdirectories, other than |
|
18 | 23 | # manually excluding all their subdirs. distutils really is horrible... |
|
19 | 24 | exclude doc/attic/* |
|
20 | 25 | exclude doc/build/doctrees/* |
|
21 | 26 | exclude doc/build/html/_sources/* |
|
22 | 27 | exclude doc/build/html/_static/* |
|
23 | 28 | exclude doc/build/html/* |
|
24 | 29 | exclude doc/build/latex/* |
|
25 | 30 | |
|
26 | 31 | global-exclude *~ |
|
27 | 32 | global-exclude *.flc |
|
28 | 33 | global-exclude *.pyc |
|
29 | 34 | global-exclude .dircopy.log |
|
30 | 35 | global-exclude .svn |
|
31 | 36 | global-exclude .bzr |
@@ -1,165 +1,169 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # -*- coding: utf-8 -*- |
|
3 | 3 | """Setup script for IPython. |
|
4 | 4 | |
|
5 | 5 | Under Posix environments it works like a typical setup.py script. |
|
6 | 6 | Under Windows, the command sdist is not supported, since IPython |
|
7 | 7 | requires utilities which are not available under Windows.""" |
|
8 | 8 | |
|
9 | 9 | #------------------------------------------------------------------------------- |
|
10 | 10 | # Copyright (C) 2008 The IPython Development Team |
|
11 | 11 | # |
|
12 | 12 | # Distributed under the terms of the BSD License. The full license is in |
|
13 | 13 | # the file COPYING, distributed as part of this software. |
|
14 | 14 | #------------------------------------------------------------------------------- |
|
15 | 15 | |
|
16 | 16 | #------------------------------------------------------------------------------- |
|
17 | 17 | # Imports |
|
18 | 18 | #------------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | # Stdlib imports |
|
21 | 21 | import os |
|
22 | 22 | import sys |
|
23 | 23 | |
|
24 | 24 | from glob import glob |
|
25 | 25 | |
|
26 | 26 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
27 | 27 | # update it when the contents of directories change. |
|
28 | 28 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
29 | 29 | |
|
30 | 30 | from distutils.core import setup |
|
31 | 31 | |
|
32 | 32 | # Local imports |
|
33 | 33 | from IPython.genutils import target_update |
|
34 | 34 | |
|
35 | 35 | from setupbase import ( |
|
36 | 36 | setup_args, |
|
37 | 37 | find_packages, |
|
38 | 38 | find_package_data, |
|
39 | 39 | find_scripts, |
|
40 | 40 | find_data_files, |
|
41 | 41 | check_for_dependencies |
|
42 | 42 | ) |
|
43 | 43 | |
|
44 | 44 | isfile = os.path.isfile |
|
45 | 45 | |
|
46 | 46 | #------------------------------------------------------------------------------- |
|
47 | 47 | # Handle OS specific things |
|
48 | 48 | #------------------------------------------------------------------------------- |
|
49 | 49 | |
|
50 | 50 | if os.name == 'posix': |
|
51 | 51 | os_name = 'posix' |
|
52 | 52 | elif os.name in ['nt','dos']: |
|
53 | 53 | os_name = 'windows' |
|
54 | 54 | else: |
|
55 | 55 | print 'Unsupported operating system:',os.name |
|
56 | 56 | sys.exit(1) |
|
57 | 57 | |
|
58 | 58 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
59 | 59 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
60 | 60 | # actually works. |
|
61 | 61 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
62 | 62 | print 'The sdist command is not available under Windows. Exiting.' |
|
63 | 63 | sys.exit(1) |
|
64 | 64 | |
|
65 | 65 | #------------------------------------------------------------------------------- |
|
66 | 66 | # Things related to the IPython documentation |
|
67 | 67 | #------------------------------------------------------------------------------- |
|
68 | 68 | |
|
69 | 69 | # update the manuals when building a source dist |
|
70 | 70 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
71 | 71 | import textwrap |
|
72 | 72 | |
|
73 | 73 | # List of things to be updated. Each entry is a triplet of args for |
|
74 | 74 | # target_update() |
|
75 | to_update = [ # The do_sphinx scripts builds html and pdf, so just one | |
|
76 | # target is enough to cover all manual generation | |
|
77 | ('doc/manual/ipython.pdf', | |
|
78 | ['IPython/Release.py','doc/source/ipython.rst'], | |
|
79 | "cd doc && python do_sphinx.py" ), | |
|
80 | ||
|
75 | to_update = [ | |
|
81 | 76 | # FIXME - Disabled for now: we need to redo an automatic way |
|
82 | 77 | # of generating the magic info inside the rst. |
|
83 | 78 | #('doc/magic.tex', |
|
84 | 79 | #['IPython/Magic.py'], |
|
85 | 80 | #"cd doc && ./update_magic.sh" ), |
|
86 | 81 | |
|
87 | 82 | ('doc/ipython.1.gz', |
|
88 | 83 | ['doc/ipython.1'], |
|
89 | 84 | "cd doc && gzip -9c ipython.1 > ipython.1.gz"), |
|
90 | 85 | |
|
91 | 86 | ('doc/pycolor.1.gz', |
|
92 | 87 | ['doc/pycolor.1'], |
|
93 | 88 | "cd doc && gzip -9c pycolor.1 > pycolor.1.gz"), |
|
94 | 89 | ] |
|
95 | 90 | |
|
91 | try: | |
|
92 | import sphinx | |
|
93 | except ImportError: | |
|
94 | pass | |
|
95 | else: | |
|
96 | # The do_sphinx scripts builds html and pdf, so just one | |
|
97 | # target is enough to cover all manual generation | |
|
98 | to_update.append( | |
|
99 | ('doc/manual/ipython.pdf', | |
|
100 | ['IPython/Release.py','doc/source/ipython.rst'], | |
|
101 | "cd doc && python do_sphinx.py") | |
|
102 | ) | |
|
96 | 103 | [ target_update(*t) for t in to_update ] |
|
97 | 104 | |
|
98 | 105 | #--------------------------------------------------------------------------- |
|
99 | 106 | # Find all the packages, package data, scripts and data_files |
|
100 | 107 | #--------------------------------------------------------------------------- |
|
101 | 108 | |
|
102 | 109 | packages = find_packages() |
|
103 | 110 | package_data = find_package_data() |
|
104 | 111 | scripts = find_scripts() |
|
105 | 112 | data_files = find_data_files() |
|
106 | 113 | |
|
107 | 114 | #--------------------------------------------------------------------------- |
|
108 | 115 | # Handle dependencies and setuptools specific things |
|
109 | 116 | #--------------------------------------------------------------------------- |
|
110 | 117 | |
|
111 | 118 | # This dict is used for passing extra arguments that are setuptools |
|
112 | 119 | # specific to setup |
|
113 | 120 | setuptools_extra_args = {} |
|
114 | 121 | |
|
115 | 122 | if 'setuptools' in sys.modules: |
|
116 | 123 | setuptools_extra_args['zip_safe'] = False |
|
117 | 124 | setuptools_extra_args['entry_points'] = { |
|
118 | 125 | 'console_scripts': [ |
|
119 | 126 | 'ipython = IPython.ipapi:launch_new_instance', |
|
120 | 127 | 'pycolor = IPython.PyColorize:main', |
|
121 | 128 | 'ipcontroller = IPython.kernel.scripts.ipcontroller:main', |
|
122 | 129 | 'ipengine = IPython.kernel.scripts.ipengine:main', |
|
123 | 130 | 'ipcluster = IPython.kernel.scripts.ipcluster:main' |
|
124 | 131 | ] |
|
125 | 132 | } |
|
126 | 133 | setup_args["extras_require"] = dict( |
|
127 | 134 | kernel = [ |
|
128 | 135 | "zope.interface>=3.4.1", |
|
129 | 136 | "Twisted>=8.0.1", |
|
130 | 137 | "foolscap>=0.2.6" |
|
131 | 138 | ], |
|
132 | 139 | doc=['Sphinx>=0.3','pygments'], |
|
133 | 140 | test='nose>=0.10.1', |
|
134 | 141 | security=["pyOpenSSL>=0.6"] |
|
135 | 142 | ) |
|
136 | 143 | # Allow setuptools to handle the scripts |
|
137 | 144 | scripts = [] |
|
138 | 145 | # eggs will lack docs, examples |
|
139 | 146 | data_files = [] |
|
140 | 147 | else: |
|
141 | 148 | # package_data of setuptools was introduced to distutils in 2.4 |
|
142 | 149 | cfgfiles = filter(isfile, glob('IPython/UserConfig/*')) |
|
143 | 150 | if sys.version_info < (2,4): |
|
144 | 151 | data_files.append(('lib', 'IPython/UserConfig', cfgfiles)) |
|
145 | 152 | # If we are running without setuptools, call this function which will |
|
146 | 153 | # check for dependencies an inform the user what is needed. This is |
|
147 | 154 | # just to make life easy for users. |
|
148 | 155 | check_for_dependencies() |
|
149 | 156 | |
|
150 | 157 | |
|
151 | 158 | #--------------------------------------------------------------------------- |
|
152 | 159 | # Do the actual setup now |
|
153 | 160 | #--------------------------------------------------------------------------- |
|
154 | 161 | |
|
155 | print packages | |
|
156 | ||
|
157 | ||
|
158 | 162 | setup_args['packages'] = packages |
|
159 | 163 | setup_args['package_data'] = package_data |
|
160 | 164 | setup_args['scripts'] = scripts |
|
161 | 165 | setup_args['data_files'] = data_files |
|
162 | 166 | setup_args.update(setuptools_extra_args) |
|
163 | 167 | |
|
164 | 168 | if __name__ == '__main__': |
|
165 | 169 | setup(**setup_args) |
@@ -1,20 +1,20 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | """Wrapper to run setup.py using setuptools.""" |
|
3 | 3 | |
|
4 | 4 | import os |
|
5 | 5 | import sys |
|
6 | 6 | |
|
7 | 7 | # Add my local path to sys.path |
|
8 | 8 | home = os.environ['HOME'] |
|
9 | 9 | sys.path.insert(0,'%s/usr/local/lib/python%s/site-packages' % |
|
10 | 10 | (home,sys.version[:3])) |
|
11 | 11 | |
|
12 | 12 | # now, import setuptools and call the actual setup |
|
13 | 13 | import setuptools |
|
14 | print sys.argv | |
|
14 | # print sys.argv | |
|
15 | 15 | #sys.argv=['','bdist_egg'] |
|
16 | 16 | execfile('setup.py') |
|
17 | 17 | |
|
18 | 18 | # clean up the junk left around by setuptools |
|
19 | 19 | if "develop" not in sys.argv: |
|
20 | 20 | os.system('rm -rf ipython.egg-info build') |
General Comments 0
You need to be logged in to leave comments.
Login now