Expose delta version in python as delta.__version__
#5891
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which Delta project/connector is this regarding?
Description
This PR exposes
delta-sparkversion in python asdelta.__version__. The user will be able to get it usingfrom delta import __version__. The variable will contain the package version in thex.y.zformat. This is a common (although optional) pattern in python packages and is provided in numpy, pandas, pyspark, and many other packages.Delta version is stored in
version.sbt. This is a single source of truth for getting the package version and is used by thebuild.sbtfile to add the version to the Scala package and by setup.py when building a delta-spark whl.This PR adds a new
generatePythonVersionsbt task. This task will read the version fromversion.sbtfile and will autogenerate thepython/delta/version.pyfile. The autogeneration code can be run manuallybuild/sbt sparkV1/generatePythonVersionand is run automatically on eachbuild/sbt sparkV1/compileorbuild/sbt compilerun.PR also contains premerge tests that compare if the version in
version.sbtandversion.pymatch. This means that if theversion.sbtversion is changed andversion.pyisn't (although the latter should be updated automatically during sbt compile), CI will block the PR and tell the developer to runbuild/sbt sparkV1/generatePythonVersion.Additionally, this PR fixes some failing linter checks:
How was this patch tested?
test_version.pyverifies ifdelta.__version__is valid and if it's up to date withversion.sbt.Does this PR introduce any user-facing changes?
Python users will be able to read delta version via
from delta import __version__.