-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsetup.py
More file actions
26 lines (20 loc) · 881 Bytes
/
Copy pathsetup.py
File metadata and controls
26 lines (20 loc) · 881 Bytes
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
import glob
import os
from setuptools import setup
from setuptools.command.install import install
class PostInstallCommand(install):
"""Copy bundled binaries from bin/ into the install scripts directory."""
def run(self):
install.run(self)
if not os.path.isdir(self.install_scripts):
os.makedirs(self.install_scripts)
source_dir = os.path.dirname(os.path.abspath(__file__))
source_files = glob.glob(os.path.join(source_dir, "bin") + "/*")
for source in source_files:
target = os.path.join(self.install_scripts, os.path.basename(source))
if os.path.isfile(target):
os.remove(target)
with open(source, "rb") as src, open(target, "wb") as dst:
dst.write(src.read())
os.chmod(target, 0o755)
setup(cmdclass={"install": PostInstallCommand})