setup.py 2.76 KB
Newer Older
1
#!/usr/bin/env python
2 3
import os
import subprocess
4 5 6 7

from setuptools import setup
from setuptools.command.install import install

8 9
from distutils.sysconfig import get_python_lib

10 11 12
class alin_install(install):
	def run(self):
		install.run(self)
13

14 15 16
        # This portion of the code has not the expected result. The environment variable created is not kept for always.
        # it is just created on the python sessions where this is lanched.
        # TODO: imporve this in the future.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
		py_folder = get_python_lib()
		alin_folder = py_folder+"/alin"
			
		res = os.environ.get('ALINPATH', 'Not Set')
		if res == 'Not Set':

			
			os.environ['ALINPATH'] = alin_folder
			
			# Generate environment profile for ALINPAT
			profile_folder = '/etc/profile.d/'
			profile_name = "alin.sh"
			with open(profile_folder+profile_name,"w") as f:
				f.write("export ALINPATH="+alin_folder)
			
			subprocess.call(profile_name, shell=True)
			
		# Generate documentation
		if os.path.isfile("alin_docconfig"):
			os.system("doxygen alin_docconfig")
			
			# Move generated doc folder to its porper location together witht the python module
			os.system("cp -rf doc/man/man10 /usr/share/man/")
			os.system("mandb")
			
			cmd = "cp -rf doc/ "+alin_folder+"/doc"
			os.system(cmd)
44
			
45
		print "\nInstallation completed!!!\n\n*** PLEASE restart session to apply changes ***\n"
46 47 48 49 50 51 52


def main():
	uname_folder = os.uname()[2]
	system_folder = '/lib/modules/'+uname_folder+'/extra'
	
	setup(name='AlIn',
53
			version='1.2',
54 55 56 57 58
			description='Alba Instrument',
			author='Manolo Broseta',
			author_email='mbroseta@cells.es',
			url='git@gitcomputing.cells.es:electronics/em2.git',
			cmdclass={'install': alin_install},
59
			packages=['alin', 'alin.tools','alin.tools.panel','alin.tools.telnet'],
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
			scripts = ['scripts/alin',
						'scripts/alinecho',
						'scripts/alingen',
						'scripts/alinpanel',
						'scripts/alinpaneloff',
						'scripts/alinsave'
						],
			long_description=open('README.txt').read(),
			
			data_files=[('/lib/firmware/fmc', ['resources/binaries/spec-init.bin']),
						('/usr/lib/', ['resources/lib/libspec.so']),						
						(system_folder, ['resources/kernel/spec.ko',
										'resources/kernel/fmc.ko',
										'resources/kernel/fmc-chardev.ko',
										'resources/kernel/fmc-fakedev.ko',
										'resources/kernel/fmc-trivial.ko',
										'resources/kernel/fmc-write-eeprom.ko',
										'resources/kernel/wr-nic.ko'
										]),
79 80 81 82
						#('/usr/lib/alin', ['tools/alininfo.py','tools/alingen.py','tools/alinsave.py']),
						#('/usr/lib/alin/panel', ['tools/panel/image_res.py','tools/panel/panel.py','tools/panel/paneldrv.py','tools/panel/paneloff.py']),
						#('/usr/lib/alin/telnet', ['tools/telnet/echo_client.py','tools/telnet/echo_server.py'])
						]
83 84 85 86
			)
				
if __name__ == "__main__":
    main()