Something went wrong on our end
-
Mikhail Karnevskiy authoredMikhail Karnevskiy authored
setup.py 2.30 KiB
from setuptools import setup
from setuptools.command.install import install
from subprocess import check_call, check_output
from distutils.command.build import build
import sys
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
# check if this is a karabo installation
python_path = sys.executable
if "karabo" in python_path:
print("Karabo installation detected, checking for PyDetLib installation")
try:
import XFELDetAna
print("...found!")
return
except:
"No PyDetLib installation found, attempting to install"
check_call("karabo -g https://in.xfel.eu/gitlab install pyDetLib master".split())
else:
print("Python environment seems to not be a Karabo environment. "+
"Please install PyDetLib manually.")
class PreInstallCommand(build):
"""Pre-installation for installation mode."""
def run(self):
version = check_output(['git', 'describe', '--tag']).decode('utf8')
version = version.replace("\n", "")
file = open('xfel_calibrate/VERSION.py', 'w')
file.write('__version__="{}"'.format(version))
file.close()
build.run(self)
from xfel_calibrate.notebooks import notebooks
data_files = []
for ctypes in notebooks.values():
for nb in ctypes.values():
data_files.append(nb["notebook"])
setup(
name='European XFEL Offline Calibration',
version="1.0",
packages=['cal_tools', 'xfel_calibrate'],
package_dir={'cal_tools': 'cal_tools/cal_tools',
'xfel_calibrate': 'xfel_calibrate',
'xfel_calibrate.notebooks': 'xfel_calibrate/notebooks',
},
package_data={
'xfel_calibrate': ['bin/*.sh']+data_files
},
cmdclass={
'build' : PreInstallCommand,
'install': PostInstallCommand,
},
url='',
license='(c) European XFEL GmbH 2018',
author='Steffen Hauf',
author_email='steffen.hauf@xfel.eu',
description='',
entry_points = {
'console_scripts': [
'xfel-calibrate = xfel_calibrate.calibrate:run',
],
},
)