forked from bartok765/galaxy_blizzard_plugin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasks.py
71 lines (55 loc) · 2.1 KB
/
tasks.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
import os
import sys
import json
import tempfile
from shutil import rmtree
from distutils.dir_util import copy_tree
from invoke import task
from galaxy.tools import zip_folder_to_file
with open(os.path.join("src", "manifest.json"), "r") as f:
MANIFEST = json.load(f)
if sys.platform == 'win32':
DIST_DIR = os.environ['localappdata'] + '\\GOG.com\\Galaxy\\plugins\\installed'
PIP_PLATFORM = "win32"
elif sys.platform == 'darwin':
DIST_DIR = os.path.realpath(os.path.expanduser("~/Library/Application Support/GOG.com/Galaxy/plugins/installed"))
PIP_PLATFORM = "macosx_10_13_x86_64" # @see https://github.com/FriendsOfGalaxy/galaxy-integrations-updater/blob/master/scripts.py
@task
def build(c, output='build', ziparchive=None):
if os.path.exists(output):
print('--> Removing {} directory'.format(output))
rmtree(output)
# Firstly dependencies needs to be "flatten" with pip-compile as pip requires --no-deps if --platform is used
print('--> Flattening dependencies to temporary requirements file')
with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp:
c.run(f'pip-compile requirements/app.txt --output-file=-', out_stream=tmp)
# Then install all stuff with pip to output folder
print('--> Installing with pip for specific version')
args = [
'pip', 'install',
'-r', tmp.name,
'--python-version', '37',
'--platform', PIP_PLATFORM,
'--target "{}"'.format(output),
'--no-compile',
'--no-deps'
]
c.run(" ".join(args), echo=True)
os.unlink(tmp.name)
print('--> Copying source files')
copy_tree("src", output)
if ziparchive is not None:
print('--> Compressing to {}'.format(ziparchive))
zip_folder_to_file(output, ziparchive)
@task
def test(c):
c.run('pytest')
@task
def install(c):
dist_path = os.path.join(DIST_DIR, "battlenet_" + MANIFEST['guid'])
build(c, output=dist_path)
@task
def pack(c):
output = "battlenet_" + MANIFEST['guid']
build(c, output=output, ziparchive='battlenet_v{}.zip'.format(MANIFEST['version']))
rmtree(output)