Skip to content

Commit 040e94e

Browse files
committed
Merge branch 'master' into engine-release
2 parents 7f5673a + f399f52 commit 040e94e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

build.gradle

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ dependencies {
4040
bots project(":example-bots")
4141
}
4242

43+
task installPythonPackage(type: Exec) {
44+
if (project.findProperty('forceInstallPythonPackage') ?: false) {
45+
commandLine 'python', '-m', 'pip', 'install', '-e', 'engine/src/crossplay_python'
46+
} else {
47+
commandLine 'python', '-c', "import importlib.util,subprocess,sys; pkg='battlecode26'; importlib.util.find_spec(pkg) or subprocess.check_call([sys.executable,'-m','pip','install','-e',pkg])"
48+
}
49+
}
50+
4351
def serverJar = configurations.engine.singleFile
4452

4553
task buildMap(type: JavaExec, dependsOn: [':engine:build']) {
@@ -91,28 +99,24 @@ task headless(type: JavaExec, dependsOn: [':engine:build', ':example-bots:build'
9199
]
92100
}
93101

94-
task crossPlayPy(type: Exec, dependsOn: [':engine:build']) {
95-
commandLine 'python', 'engine/src/crossplay_python/main.py',
102+
task crossPlayPy(type: Exec, dependsOn: ['installPythonPackage']) {
103+
commandLine 'python', '-m', 'battlecode26',
96104
'--teamA', (project.findProperty('languageA') == 'java' ? '/' : project.property('teamA')),
97105
'--teamB', (project.findProperty('languageB') == 'java' ? '/' : project.property('teamB')),
98106
'--dirA', 'example-bots/src/crossplay_python',
99107
'--dirB', 'example-bots/src/crossplay_python',
100108
'--new-process'
101109
}
102110

103-
task headlessPy(dependsOn: ['headless']) {}
104-
headlessPy.mustRunAfter crossPlayPy
105-
106111
// keep the client happy because it references this step
107112
task unpackClient() {}
108113

109-
task run(dependsOn: ['unpackClient']) {}
114+
task run(dependsOn: ['unpackClient', 'headless']) {}
110115

111116
if (project.hasProperty('languageA') && project.property('languageA') == 'python' ||
112117
project.hasProperty('languageB') && project.property('languageB') == 'python') {
113-
run.dependsOn crossPlayPy, headlessPy
114-
} else {
115-
run.dependsOn headless
118+
run.dependsOn crossPlayPy
119+
headless.mustRunAfter crossPlayPy
116120
}
117121

118122
task runClient {

engine/src/crossplay_python/battlecode26/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ def main(args=None):
261261
if parsed_args.new_process:
262262
new_args = [
263263
sys.executable,
264-
__file__,
264+
"-m",
265+
"battlecode26",
265266
"--teamA",
266267
team_a,
267268
"--teamB",

0 commit comments

Comments
 (0)