Skip to content

Commit 02d03d5

Browse files
nfxJCZuurmond
andauthored
Added reproducible wheel and egg sources (#1832)
This PR adds reproducible wheel and egg builder. --------- Co-authored-by: Cor <[email protected]>
1 parent 49dcb08 commit 02d03d5

File tree

17 files changed

+87
-10
lines changed

17 files changed

+87
-10
lines changed
Binary file not shown.

tests/integration/source_code/test_jobs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ def test_workflow_linter_lints_job_with_egg_dependency(
229229
make_notebook,
230230
make_directory,
231231
):
232-
expected_problem_message = "Could not locate import: pkgdir"
233-
egg_file = Path(__file__).parent / "samples" / "library-egg" / "demo_egg-0.0.1-py3.6.egg"
232+
expected_problem_message = "Could not locate import: thingy"
233+
egg_file = Path(__file__).parent / "../../unit/source_code/samples/distribution/dist/thingy-0.0.1-py3.10.egg"
234234

235235
entrypoint = make_directory()
236236

@@ -239,7 +239,7 @@ def test_workflow_linter_lints_job_with_egg_dependency(
239239
ws.workspace.upload(remote_egg_file, f.read(), format=ImportFormat.AUTO)
240240
library = compute.Library(egg=remote_egg_file)
241241

242-
notebook = make_notebook(path=f"{entrypoint}/notebook.ipynb", content=b"import pkgdir")
242+
notebook = make_notebook(path=f"{entrypoint}/notebook.ipynb", content=b"import thingy")
243243
job_with_egg_dependency = make_job(notebook_path=notebook, libraries=[library])
244244

245245
problems = simple_ctx.workflow_linter.lint_job(job_with_egg_dependency.job_id)

tests/unit/source_code/notebooks/test_cells.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def test_pip_cell_build_dependency_graph_resolves_installed_library(mock_path_lo
8585
dependency_resolver = DependencyResolver(pip_resolver, notebook_resolver, import_resolver, mock_path_lookup)
8686
graph = DependencyGraph(dependency, None, dependency_resolver, mock_path_lookup)
8787

88-
whl = Path(__file__).parent / '../samples/library-wheel/demo_egg-0.0.1-py3-none-any.whl'
88+
whl = Path(__file__).parent / '../samples/distribution/dist/thingy-0.0.1-py2.py3-none-any.whl'
8989

90-
code = f"%pip install {whl.as_posix()}" # installs pkgdir
90+
code = f"%pip install {whl.as_posix()}" # installs thingy
9191
cell = PipCell(code)
9292

9393
problems = cell.build_dependency_graph(graph)
9494

9595
assert len(problems) == 0
96-
assert graph.path_lookup.resolve(Path("pkgdir")).exists()
96+
assert graph.path_lookup.resolve(Path("thingy")).exists()
9797

9898

9999
def test_pip_cell_build_dependency_graph_handles_multiline_code():
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
dist: pyproject.toml thingy/__init__.py thingy/__main__.py setup.py Makefile
2+
hatch build
3+
4+
dist/thingy-0.0.1.tar.gz: dist
5+
@:
6+
7+
dist/thingy-0.0.1-py3-none-any.whl: dist
8+
@:
9+
10+
dist/thingy-0.0.1-py3.10.egg: Makefile
11+
python setup.py bdist_egg
12+
git add dist/thingy-0.0.1-py3.10.egg -f
13+
rm -fr build thingy.egg-info
14+
15+
all: dist/thingy-0.0.1.tar.gz dist/thingy-0.0.1-py3-none-any.whl dist/thingy-0.0.1-py3.10.egg
16+
@:
17+
18+
clean:
19+
rm -fr dist build thingy.egg-info
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Demo wheel
2+
3+
This contains sources for a wheel and an egg.
4+
5+
Use `make all` to rebuild the wheel and egg after changing any content in this folder.
6+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "thingy"
7+
version = "0.0.1"
8+
description = 'This package does nothing useful and is meant for testing code distributions.'
9+
10+
[project.entry-points.databricks]
11+
runtime = "thingy:main"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name="thingy",
5+
version="0.0.1",
6+
description='This package does nothing useful and is meant for testing eggs.',
7+
)

0 commit comments

Comments
 (0)