source: ogAgent-Git/src/setup.py

qndtest
Last change on this file was af35fd9, checked in by Ramón M. Gómez <ramongomez@…>, 4 years ago

#992: OGAgent sends the session type when user logs in.

  • Property mode set to 100644
File size: 4.9 KB
Line 
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@author: Ramón M. Gómez, ramongomez at us dot es
32"""
33
34# ModuleFinder can't handle runtime changes to __path__, but win32com uses them
35try:
36    # py2exe 0.6.4 introduced a replacement modulefinder.
37    # This means we have to add package paths there, not to the built-in
38    # one.  If this new modulefinder gets integrated into Python, then
39    # we might be able to revert this some day.
40    # if this doesn't work, try import modulefinder
41    try:
42        import py2exe.mf as modulefinder
43    except ImportError:
44        import modulefinder
45    import win32com
46    import 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)
54except ImportError:
55    # no build path setup, no worries.
56    pass
57
58import os
59from distutils.core import setup
60import py2exe
61import sys
62
63# Reading version file:
64try:
65    with open('VERSION', 'r') as v:
66        VERSION = v.read().rstrip()
67except IOError:
68    VERSION = '1.1.0'
69
70sys.argv.append('py2exe')
71
72
73def get_requests_cert_file():
74    """Add Python requests or certifi .pem file for installers."""
75    import requests
76    f = os.path.join(os.path.dirname(requests.__file__), 'cacert.pem')
77    if not os.path.exists(f):
78        import certifi
79        f = os.path.join(os.path.dirname(certifi.__file__), 'cacert.pem')
80    return f
81
82
83class Target:
84
85    def __init__(self, **kw):
86        self.__dict__.update(kw)
87        # for the versioninfo resources
88        self.version = VERSION
89        self.name = 'OGAgentService'
90        self.description = 'OpenGnsys Agent Service'
91        self.author = 'Adolfo Gomez'
92        self.url = 'https://opengnsys.es/'
93        self.company_name = "OpenGnsys Project"
94        self.copyright = "(c) 2014 VirtualCable S.L.U."
95        self.name = "OpenGnsys Agent"
96
97# Now you need to pass arguments to setup
98# windows is a list of scripts that have their own UI and
99# thus don't need to run in a console.
100
101
102udsservice = Target(
103    description='OpenGnsys Agent Service',
104    modules=['opengnsys.windows.OGAgentService'],
105    icon_resources=[(0, 'img\\oga.ico'), (1, 'img\\oga.ico')],
106    cmdline_style='pywin32'
107)
108
109# Some test_modules are hidden to py2exe by six, we ensure that they appear on "includes"
110HIDDEN_BY_SIX = ['SocketServer', 'SimpleHTTPServer', 'urllib']
111
112setup(
113    windows=[
114        {
115            'script': 'OGAgentUser.py',
116            'icon_resources': [(0, 'img\\oga.ico'), (1, 'img\\oga.ico')]
117        },
118    ],
119    console=[
120        {
121            'script': 'OGAServiceHelper.py'
122        }
123    ],
124    service=[udsservice],
125    data_files=[('', [get_requests_cert_file()]), ('cfg', ['cfg/ogagent.cfg', 'cfg/ogclient.cfg'])],
126    options={
127        'py2exe': {
128            'bundle_files': 3,
129            'compressed': True,
130            'optimize': 2,
131            'includes': ['sip', 'PyQt4', 'win32com.shell', 'requests', 'encodings', 'encodings.utf_8'] + HIDDEN_BY_SIX,
132            'excludes': ['doctest', 'unittest'],
133            'dll_excludes': ['msvcp90.dll'],
134            'dist_dir': '..\\bin',
135        }
136    },
137    name='OpenGnsys Agent',
138    version=VERSION,
139    description='OpenGnsys Agent',
140    author='Adolfo Gomez',
141    author_email='agomez@virtualcable.es',
142    zipfile='OGAgent.zip',
143)
Note: See TracBrowser for help on using the repository browser.