forked from linode/linode-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·105 lines (85 loc) · 2.66 KB
/
setup.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
import pathlib
import subprocess
import sys
import platform
from setuptools import setup, find_packages
from os import path
here = pathlib.Path().absolute()
# get the long description from the README.md
with open(here / "README.md", encoding="utf-8") as f:
long_description = f.read()
def get_baked_files():
"""
A helper to retrieve the baked files included with this package. This is
to assist with building from source, where baked files may not be present
on a fresh clone
"""
data_files = []
completion_dir = "/etc/bash_completion.d"
if path.isfile("linode-cli.sh") and platform.system() != "Windows":
data_files.append((completion_dir, ["linode-cli.sh"]))
return data_files
def get_version():
"""
Uses the version file to calculate this package's version
"""
return (
subprocess.check_output([sys.executable, "./version"])
.decode("utf-8")
.rstrip()
)
def get_baked_version():
"""
Attempts to read the version from the baked_version file
"""
with open("./baked_version", "r", encoding="utf-8") as f:
result = f.read()
return result
def bake_version(v):
"""
Writes the given version to the baked_version file
"""
with open("./baked_version", "w", encoding="utf-8") as f:
f.write(v)
# If there's already a baked version, use it rather than attempting
# to resolve the version from env.
# This is useful for installing from an SDist where the version
# cannot be dynamically resolved.
#
# NOTE: baked_version is deleted when running `make build` and `make install`,
# so it should always be recreated during the build process.
if path.isfile("baked_version"):
version = get_baked_version()
else:
# Otherwise, retrieve and bake the version as normal
version = get_version()
bake_version(version)
with open("requirements.txt") as f:
requirements = f.read().splitlines()
setup(
name="linode-cli",
version=version,
description="CLI for the Linode API",
long_description=long_description,
long_description_content_type="text/markdown",
author="Linode",
author_email="developers@linode.com",
url="https://www.linode.com/docs/api/",
packages=find_packages(include=["linodecli*"]),
license="BSD 3-Clause License",
install_requires=requirements,
extras_require={
"obj": ["boto3"],
},
entry_points={
"console_scripts": [
"linode-cli = linodecli:main",
"linode = linodecli:main",
"lin = linodecli:main",
]
},
data_files=get_baked_files(),
python_requires=">=3.8",
include_package_data=True,
)