@@ -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+
4351def serverJar = configurations. engine. singleFile
4452
4553task 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
107112task unpackClient () {}
108113
109- task run (dependsOn : [' unpackClient' ]) {}
114+ task run (dependsOn : [' unpackClient' , ' headless ' ]) {}
110115
111116if (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
118122task runClient {
0 commit comments