Zack Williams | 821c502 | 2020-01-15 15:11:46 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright 2020-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import os |
| 18 | from setuptools import setup |
| 19 | from shutil import copyfile |
| 20 | |
| 21 | LIBRARY_NAME = "CORDRobot" |
| 22 | |
| 23 | |
| 24 | def version(): |
| 25 | # Copy VERSION file of parent to module directory if not found |
| 26 | version_path = os.path.join(LIBRARY_NAME, "VERSION") |
| 27 | if not os.path.exists(version_path): |
| 28 | copyfile("../VERSION", version_path) |
| 29 | with open(version_path) as f: |
| 30 | return f.read().strip() |
| 31 | |
| 32 | |
| 33 | def parse_requirements(filename): |
| 34 | # parse a requirements.txt file, allowing for blank lines and comments |
| 35 | requirements = [] |
| 36 | for line in open(filename): |
| 37 | if line and not line.startswith("#"): |
| 38 | requirements.append(line) |
| 39 | return requirements |
| 40 | |
| 41 | |
| 42 | setup( |
| 43 | name="cord-robot", |
| 44 | version=version(), |
| 45 | description="CORD Project Robot Libraries and common Resources", |
| 46 | author="CORD Developers", |
| 47 | include_package_data=True, |
| 48 | packages=[LIBRARY_NAME], |
| 49 | package_data={ |
| 50 | LIBRARY_NAME: ["rf-resources/*.resource", "VERSION"] |
| 51 | }, |
| 52 | install_requires=parse_requirements("requirements.txt"), |
| 53 | ) |