-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
88 lines (76 loc) · 2.65 KB
/
setup.py
File metadata and controls
88 lines (76 loc) · 2.65 KB
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
import os
import sys
from setuptools import setup, find_packages
from distutils.core import setup, Command
from pip.req import parse_requirements
import pip.download
import boto3
from boto3.s3.transfer import S3Transfer, TransferConfig
if 'deploy' not in sys.argv or 'sdist' not in sys.argv:
print "You must call this setup script with both 'sdist' and 'deploy' commands"
sys.exit(1)
def update_version():
version = None
try:
with open("VERSION") as f:
version = f.read().strip()
# increment version each time the script is called
t = [int(p) for p in version.split(".")]
t[-1]+=1
version = ".".join(str(p) for p in t)
except:
version = "0.1.0"
with open("VERSION", "wb") as f:
f.write(version + "\n")
return version
version = update_version()
REGION = "eu-west-1"
BUCKET_NAME = "directive-tiers.dg-api.com"
UE4_BUILDS_FOLDER = "ue4-builds"
class DeployCommand(Command):
description = "Deploy build to S3 so that daemons will pick it up and install"
user_options = []
def initialize_options(self):
self.cwd = None
def finalize_options(self):
self.cwd = os.getcwd()
def upload_build(self, local_filename, upload_filename):
client = boto3.client('s3', REGION)
base_name = "{}/{}".format(
UE4_BUILDS_FOLDER,
upload_filename
)
transfer = S3Transfer(client)
p = os.path.join('dist', local_filename)
p = os.path.abspath(p)
transfer.upload_file(p, BUCKET_NAME, base_name)
print "Done uploading build '%s' to S3 as %s" % (local_filename, base_name)
def run(self):
assert os.getcwd() == self.cwd, 'Must be in package root: %s' % self.cwd
local_filename = os.path.join('drift-serverdaemon-%s.zip' % version)
remote_filename = 'drift-serverdaemon-%s.zip' % version #! temporary hack
self.upload_build(local_filename, remote_filename)
latest_filename = os.path.join('drift-serverdaemon-latest.zip')
self.upload_build(local_filename, latest_filename)
setup_args = dict(
name="drift-serverdaemon",
version=version,
author="Directive Games",
author_email="info@directivegames.com",
description="Server Daemon Application",
packages=find_packages(
exclude=["*.tests", "*.tests.*", "tests.*", "tests"]
),
include_package_data=True,
install_requires=[
str(i.req)
for i in parse_requirements(
"requirements.txt", session=pip.download.PipSession()
)
],
cmdclass={
'deploy': DeployCommand
}
)
if __name__ == "__main__":
setup(**setup_args)