forked from hifi/heisenbridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
47 lines (34 loc) · 1.18 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
# Included to allow for editable installs
import importlib.util
from setuptools import Command
from setuptools import setup
from setuptools.command.build_py import build_py
from setuptools.command.sdist import sdist
# pull git or local version
spec = importlib.util.spec_from_file_location("version", "heisenbridge/version.py")
version = importlib.util.module_from_spec(spec)
spec.loader.exec_module(version)
class GenerateVersionCommand(Command):
description = "Generate version.txt"
user_options = []
def run(self):
with open("heisenbridge/version.txt", "w") as version_file:
version_file.write(version.__version__)
def initialize_options(self):
pass
def finalize_options(self):
pass
class BuildPyCommand(build_py):
def run(self):
self.run_command("gen_version")
build_py.run(self)
class SDistCommand(sdist):
def run(self):
self.run_command("gen_version")
sdist.run(self)
setup(
version=version.__version__,
cmdclass={"gen_version": GenerateVersionCommand, "build_py": BuildPyCommand, "sdist": SDistCommand},
packages=["heisenbridge"],
package_data={"heisenbridge": ["version.txt"]},
)