2015-06-10 21:04:49 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2021-06-03 15:20:39 +02:00
|
|
|
from pathlib import Path
|
|
|
|
from subprocess import call
|
|
|
|
|
|
|
|
from setuptools import setup
|
2015-06-10 21:04:49 +02:00
|
|
|
|
2015-06-24 01:02:55 +02:00
|
|
|
# Change directory since setuptools uses relative paths
|
|
|
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
2019-08-18 17:45:48 +02:00
|
|
|
print(script_path)
|
2015-06-24 01:02:55 +02:00
|
|
|
os.chdir(script_path)
|
|
|
|
|
2019-08-18 17:45:48 +02:00
|
|
|
install_args = ["install", "install_data", "develop"]
|
2015-06-24 17:11:46 +02:00
|
|
|
no_init = False
|
2015-06-23 21:10:02 +02:00
|
|
|
run_postinst = False
|
2015-06-10 21:04:49 +02:00
|
|
|
|
2015-06-12 18:50:35 +02:00
|
|
|
# XXX Definitely not the best way of doing this...
|
|
|
|
if sys.argv[1] in install_args and "--no-init-script" not in sys.argv:
|
2015-06-23 21:10:02 +02:00
|
|
|
run_postinst = True
|
2019-08-18 17:45:48 +02:00
|
|
|
data_files = [
|
|
|
|
("/etc/default", ["install/conf/airtime-celery"]),
|
|
|
|
("/etc/init.d", ["install/initd/airtime-celery"]),
|
|
|
|
]
|
2015-06-10 21:04:49 +02:00
|
|
|
else:
|
2015-06-18 21:05:32 +02:00
|
|
|
if "--no-init-script" in sys.argv:
|
2015-06-24 17:11:46 +02:00
|
|
|
no_init = True
|
2015-06-23 21:10:02 +02:00
|
|
|
run_postinst = True # We still want to run the postinst here
|
2015-06-18 21:05:32 +02:00
|
|
|
sys.argv.remove("--no-init-script")
|
2015-06-12 18:50:35 +02:00
|
|
|
data_files = []
|
2015-06-10 21:04:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
def postinst():
|
2020-05-13 17:10:14 +02:00
|
|
|
initd = Path("/etc/init.d/airtime-celery")
|
|
|
|
conf = Path("/etc/default/airtime-celery")
|
|
|
|
if not no_init and initd.is_file() and conf.is_file():
|
2015-06-24 17:11:46 +02:00
|
|
|
# Make /etc/init.d file executable and set proper
|
|
|
|
# permissions for the defaults config file
|
2019-08-18 17:45:48 +02:00
|
|
|
os.chmod("/etc/init.d/airtime-celery", 0o755)
|
|
|
|
os.chmod("/etc/default/airtime-celery", 0o640)
|
|
|
|
print('Run "sudo service airtime-celery restart" now.')
|
|
|
|
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name="airtime-celery",
|
|
|
|
version="0.1",
|
|
|
|
description="Airtime Celery service",
|
|
|
|
url="http://github.com/sourcefabric/Airtime",
|
|
|
|
author="Sourcefabric",
|
|
|
|
author_email="duncan.sommerville@sourcefabric.org",
|
|
|
|
license="MIT",
|
|
|
|
packages=["airtime-celery"],
|
2021-01-06 13:20:23 +01:00
|
|
|
install_requires=["celery==4.4.7", "kombu==4.6.10", "configobj"],
|
2019-08-18 17:45:48 +02:00
|
|
|
zip_safe=False,
|
|
|
|
data_files=data_files,
|
|
|
|
)
|
2015-06-10 21:04:49 +02:00
|
|
|
|
2015-06-23 21:10:02 +02:00
|
|
|
if run_postinst:
|
2015-06-10 21:04:49 +02:00
|
|
|
postinst()
|