~smoser/cloud-init/azure_dhcp

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Brent Baude
  • Date: 2016-08-02 19:05:04 UTC
  • Revision ID: bbaude@redhat.com-20160802190504-30i8uihedcr27odn
Set python binary (2 vs 3) during install phase.  Also, removed
use of entry_point and hook scripts now use -m instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
elif os.path.isfile('/etc/redhat-release'):
104
104
    USR_LIB_EXEC = "/usr/libexec"
105
105
 
 
106
PYTHON_BINARY = 'python2' if sys.version_info[0] < 3 else 'python3'
106
107
 
107
108
# Avoid having datafiles installed in a virtualenv...
108
109
def in_virtualenv():
137
138
          (", ".join(INITSYS_TYPES)))),
138
139
    ]
139
140
 
 
141
 
140
142
    def initialize_options(self):
 
143
        print(PYTHON_BINARY)
141
144
        install.initialize_options(self)
142
145
        self.init_system = ""
143
146
 
168
171
        self.distribution.reinitialize_command('install_data', True)
169
172
 
170
173
 
 
174
def set_python_version(files):
 
175
    for file in files:
 
176
        tmpl = file + '.tmpl'
 
177
        with open(file, "wt") as file_out:
 
178
            with open(tmpl, "rt") as t:
 
179
                for line in t:
 
180
                    file_out.write(line.replace('%%PYTHON_BINARY%%', PYTHON_BINARY))
 
181
    return files
 
182
 
 
183
 
171
184
if in_virtualenv():
172
185
    data_files = []
173
186
    cmdclass = {}
176
189
        (ETC + '/cloud', glob('config/*.cfg')),
177
190
        (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
178
191
        (ETC + '/cloud/templates', glob('templates/*')),
179
 
        (ETC + '/NetworkManager/dispatcher.d/', ['tools/hook-network-manager']),
180
 
        (ETC + '/dhcp/dhclient-exit-hooks.d/', ['tools/hook-dhclient']),
 
192
        (ETC + '/NetworkManager/dispatcher.d/', set_python_version(['tools/hook-network-manager'])),
 
193
        (ETC + '/dhcp/dhclient-exit-hooks.d/', set_python_version(['tools/hook-dhclient'])),
181
194
        (USR_LIB_EXEC + '/cloud-init', ['tools/uncloud-init',
182
195
                                        'tools/write-ssh-key-fingerprints']),
183
196
        (USR + '/share/doc/cloud-init', [f for f in glob('doc/*') if is_f(f)]),
213
226
    cmdclass=cmdclass,
214
227
    entry_points={
215
228
        'console_scripts': [
216
 
            'cloud-init = cloudinit.cmd.main:main',
217
 
            'cloud-init-dhclient-hook = cloudinit.cmd.dhclient_hook:main'
 
229
            'cloud-init = cloudinit.cmd.main:main'
218
230
        ],
219
231
    }
220
232
)