Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/databricks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages
# This file should only contain the following line. Otherwise other sub-packages databricks.* namespace
# may not be importable.
# See: https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages
#
# This file must only contain the following line, or other packages in the databricks.* namespace
# may not be importable. The contents of this file must be byte-for-byte equivalent across all packages.
# If they are not, parallel package installation may lead to clobbered and invalid files.
# Also see https://github.com/databricks/databricks-sdk-py/issues/343.
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
19 changes: 19 additions & 0 deletions tests/unit/test_init_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import hashlib


class TestInitFile:
"""
Micro test to confirm the contents of `databricks/__init__.py` does not change.

Also see https://github.com/databricks/databricks-sdk-py/issues/343#issuecomment-1866029118.
"""

def test_init_file_contents(self):
with open("src/databricks/__init__.py") as f:
init_file_contents = f.read()

# This hash is the expected hash of the contents of `src/databricks/__init__.py`.
# It must not change, or else parallel package installation may lead to clobbered and invalid files.
expected_sha1 = "2772edbf52e517542acf8c039479c4b57b6ca2cd"
actual_sha1 = hashlib.sha1(init_file_contents.encode("utf-8")).hexdigest()
assert expected_sha1 == actual_sha1