Skip to content

Commit cc219a2

Browse files
committed
Propagate translated maven version to setup.py.
1 parent 492dadd commit cc219a2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

project/PythonBuildPlugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ object PythonBuildPlugin extends AutoPlugin {
114114
val wd = copyPySources.value
115115
val args = spaceDelimited("<args>").parsed
116116
val cmd = Seq(pythonCommand.value, "setup.py") ++ args
117-
val ver = version.value
117+
val ver = (Python / version).value
118118
s.log.info(s"Running '${cmd.mkString(" ")}' in '$wd'")
119119
val ec = Process(cmd, wd, "RASTERFRAMES_VERSION" -> ver).!
120120
if (ec != 0)

pyrasterframes/src/main/python/setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@
2020

2121
# Always prefer setuptools over distutils
2222
from setuptools import setup
23-
from os import path
23+
from os import path, environ, mkdir
2424
import sys
2525
from glob import glob
2626
from io import open
2727
import distutils.cmd
2828

2929
try:
30+
enver = environ.get('RASTERFRAMES_VERSION')
31+
if enver is not None:
32+
open('pyrasterframes/version.py', mode="w").write(f"__version__: str = '{enver}'\n")
3033
exec(open('pyrasterframes/version.py').read()) # executable python script contains __version__; credit pyspark
31-
except IOError:
32-
print("Run setup via `sbt 'pySetup arg1 arg2'` to ensure correct access to all source files and binaries.")
34+
except IOError as e:
35+
print(e)
36+
print("Try running setup via `sbt 'pySetup arg1 arg2'` to ensure correct access to all source files and binaries.")
3337
sys.exit(-1)
3438

35-
3639
VERSION = __version__
3740

3841
here = path.abspath(path.dirname(__file__))

0 commit comments

Comments
 (0)