1 | # -*- coding: utf-8 -*- |
---|
2 | # |
---|
3 | # Copyright (c) 2014 Virtual Cable S.L. |
---|
4 | # All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use in source and binary forms, with or without modification, |
---|
7 | # are permitted provided that the following conditions are met: |
---|
8 | # |
---|
9 | # * Redistributions of source code must retain the above copyright notice, |
---|
10 | # this list of conditions and the following disclaimer. |
---|
11 | # * Redistributions in binary form must reproduce the above copyright notice, |
---|
12 | # this list of conditions and the following disclaimer in the documentation |
---|
13 | # and/or other materials provided with the distribution. |
---|
14 | # * Neither the name of Virtual Cable S.L. nor the names of its contributors |
---|
15 | # may be used to endorse or promote products derived from this software |
---|
16 | # without specific prior written permission. |
---|
17 | # |
---|
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
---|
21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
---|
22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
---|
24 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
---|
25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
---|
26 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
28 | |
---|
29 | ''' |
---|
30 | @author: Adolfo Gómez, dkmaster at dkmon dot com |
---|
31 | ''' |
---|
32 | |
---|
33 | VERSION = '1.0.0' |
---|
34 | |
---|
35 | # ModuleFinder can't handle runtime changes to __path__, but win32com uses them |
---|
36 | try: |
---|
37 | # py2exe 0.6.4 introduced a replacement modulefinder. |
---|
38 | # This means we have to add package paths there, not to the built-in |
---|
39 | # one. If this new modulefinder gets integrated into Python, then |
---|
40 | # we might be able to revert this some day. |
---|
41 | # if this doesn't work, try import modulefinder |
---|
42 | try: |
---|
43 | import py2exe.mf as modulefinder |
---|
44 | except ImportError: |
---|
45 | import modulefinder |
---|
46 | import win32com, sys |
---|
47 | for p in win32com.__path__[1:]: |
---|
48 | modulefinder.AddPackagePath("win32com", p) |
---|
49 | for extra in ["win32com.shell"]: # ,"win32com.mapi" |
---|
50 | __import__(extra) |
---|
51 | m = sys.modules[extra] |
---|
52 | for p in m.__path__[1:]: |
---|
53 | modulefinder.AddPackagePath(extra, p) |
---|
54 | except ImportError: |
---|
55 | # no build path setup, no worries. |
---|
56 | pass |
---|
57 | |
---|
58 | from distutils.core import setup |
---|
59 | import py2exe |
---|
60 | import sys |
---|
61 | import os |
---|
62 | |
---|
63 | sys.argv.append('py2exe') |
---|
64 | |
---|
65 | def get_requests_cert_file(): |
---|
66 | """Add Python requests .pem file for installers.""" |
---|
67 | import requests |
---|
68 | f = os.path.join(os.path.dirname(requests.__file__), 'cacert.pem') |
---|
69 | return f |
---|
70 | |
---|
71 | |
---|
72 | class Target: |
---|
73 | |
---|
74 | def __init__(self, **kw): |
---|
75 | self.__dict__.update(kw) |
---|
76 | # for the versioninfo resources |
---|
77 | self.version = VERSION |
---|
78 | self.name = 'OGAgentService' |
---|
79 | self.description = 'OpenGnsys Agent Service' |
---|
80 | self.author = 'Adolfo Gomez' |
---|
81 | self.url = 'http://www.opengnsys.es' |
---|
82 | self.company_name = "VirtualCable S.L.U." |
---|
83 | self.copyright = "(c) 2014 VirtualCable S.L.U." |
---|
84 | self.name = "OpenGnsys Agent" |
---|
85 | |
---|
86 | # Now you need to pass arguments to setup |
---|
87 | # windows is a list of scripts that have their own UI and |
---|
88 | # thus don't need to run in a console. |
---|
89 | |
---|
90 | |
---|
91 | udsservice = Target( |
---|
92 | description='OpenGnsys Agent Service', |
---|
93 | modules=['opengnsys.windows.OGAgentService'], |
---|
94 | icon_resources=[(0, 'img\\oga.ico'), (1, 'img\\oga.ico')], |
---|
95 | cmdline_style='pywin32' |
---|
96 | ) |
---|
97 | |
---|
98 | # Some test_modules are hidden to py2exe by six, we ensure that they appear on "includes" |
---|
99 | HIDDEN_BY_SIX = ['SocketServer', 'SimpleHTTPServer', 'urllib'] |
---|
100 | |
---|
101 | setup( |
---|
102 | windows=[ |
---|
103 | { |
---|
104 | 'script': 'OGAgentUser.py', |
---|
105 | 'icon_resources': [(0, 'img\\oga.ico'), (1, 'img\\oga.ico')] |
---|
106 | }, |
---|
107 | ], |
---|
108 | console=[ |
---|
109 | { |
---|
110 | 'script': 'OGAServiceHelper.py' |
---|
111 | } |
---|
112 | ], |
---|
113 | service=[udsservice], |
---|
114 | data_files=[('', [get_requests_cert_file()]),('cfg', ['cfg/ogagent.cfg', 'cfg/ogclient.cfg'])], |
---|
115 | options={ |
---|
116 | 'py2exe': { |
---|
117 | 'bundle_files': 3, |
---|
118 | 'compressed': True, |
---|
119 | 'optimize': 2, |
---|
120 | 'includes': [ 'sip', 'PyQt4', 'win32com.shell', 'requests'] + HIDDEN_BY_SIX, |
---|
121 | 'excludes': [ 'doctest', 'unittest' ], |
---|
122 | 'dll_excludes': ['msvcp90.dll'], |
---|
123 | 'dist_dir': '..\\bin', |
---|
124 | } |
---|
125 | }, |
---|
126 | name='OpenGnsys Agent', |
---|
127 | version=VERSION, |
---|
128 | description='OpenGnsys Agent', |
---|
129 | author='Adolfo Gomez', |
---|
130 | author_email='agomez@virtualcable.es', |
---|
131 | zipfile='OGAgent.zip', |
---|
132 | ) |
---|