-
Notifications
You must be signed in to change notification settings - Fork 60
/
setup_template.py
65 lines (57 loc) · 2.11 KB
/
setup_template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# This template for the setup script is used to build several pypi packages
# from the T0 codebase. The variable package_name controls which package
# is built. PACKAGE_TO_BUILD is manipulated via tools/build_pypi_packages.sh
# at build time.
#
# The version number comes from T0/__init__.py and needs to
# follow PEP 440 conventions
from __future__ import print_function, division
import os
import sys
from setuptools import setup, Command
from setup_build import list_static_files, things_to_build
from setup_dependencies import dependencies
# get the t0 version (thanks rucio devs)
sys.path.insert(0, os.path.abspath('src/python'))
from T0 import __version__
t0_version = __version__
# the contents of package_name are modified via tools/build_pypi_packages.sh
package_name = "t0"
packages, py_modules = things_to_build(package_name, pypi=True)
data_files = list_static_files(dependencies[package_name])
# we need to override 'clean' command to remove specific files
class CleanCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system ('rm -rfv ./dist ./src/python/*.egg-info')
def parse_requirements(requirements_file):
"""
Create a list for the 'install_requires' component of the setup function
by parsing a requirements file
"""
if os.path.exists(requirements_file):
# return a list that contains each line of the requirements file
return open(requirements_file, 'r').read().splitlines()
else:
print("ERROR: requirements file " + requirements_file + " not found.")
sys.exit(1)
setup(name=package_name,
version=t0_version,
package_dir={'': 'src/python/'},
packages=packages,
py_modules=py_modules,
data_files=data_files,
install_requires=parse_requirements("requirements.txt"),
maintainer='CMS DMWM Group',
maintainer_email='[email protected]',
cmdclass={
'clean': CleanCommand,
},
url="https://github.com/dmwm/T0",
license="Apache License, Version 2.0",
)