Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/tower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
secret,
)

from ._native import build_package

from ._native import _run_cli

from ._features import override_get_attr, get_available_features, is_feature_enabled

Expand All @@ -39,6 +38,7 @@
# Sub-packages to expose
#
from . import info
from . import packages


def __getattr__(name: str):
Expand Down
1 change: 1 addition & 0 deletions src/tower/packages/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .._native import build_package
35 changes: 18 additions & 17 deletions tests/tower/test_build_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

import pytest

_native = pytest.importorskip(
"tower._native",
reason="native extension not built (run: maturin develop --features pyo3)",
)
#tower.packages = pytest.importorskip(
# "tower.tower.packages",
# reason="native extension not built (run: maturin develop --features pyo3)",
#)
import tower


def _make_app(tmp_path, towerfile_content, files=None):
Expand Down Expand Up @@ -49,7 +50,7 @@ def test_produces_tar_gz(self, tmp_path):
app_dir = _make_app(tmp_path, SIMPLE_TOWERFILE, {"main.py": "print('hello')"})
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

assert os.path.isfile(output)
assert tarfile.is_tarfile(output)
Expand All @@ -58,7 +59,7 @@ def test_contains_manifest(self, tmp_path):
app_dir = _make_app(tmp_path, SIMPLE_TOWERFILE, {"main.py": "print('hello')"})
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
assert "MANIFEST" in entries
Expand All @@ -67,7 +68,7 @@ def test_manifest_is_valid_json(self, tmp_path):
app_dir = _make_app(tmp_path, SIMPLE_TOWERFILE, {"main.py": "print('hello')"})
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
manifest = json.loads(entries["MANIFEST"])
Expand All @@ -85,7 +86,7 @@ def test_contains_app_source_files(self, tmp_path):
)
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
assert "app/main.py" in entries
Expand All @@ -95,7 +96,7 @@ def test_contains_towerfile(self, tmp_path):
app_dir = _make_app(tmp_path, SIMPLE_TOWERFILE, {"main.py": "print('hello')"})
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
assert "Towerfile" in entries
Expand All @@ -118,7 +119,7 @@ def test_nested_source_files(self, tmp_path):
)
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
assert "app/main.py" in entries
Expand All @@ -136,7 +137,7 @@ def test_manifest_contains_schedule(self, tmp_path):
app_dir = _make_app(tmp_path, towerfile, {"job.py": "print('run')"})
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
manifest = json.loads(entries["MANIFEST"])
Expand All @@ -157,7 +158,7 @@ def test_manifest_contains_parameters(self, tmp_path):
app_dir = _make_app(tmp_path, towerfile, {"main.py": "print('run')"})
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
manifest = json.loads(entries["MANIFEST"])
Expand All @@ -169,7 +170,7 @@ def test_manifest_has_checksum(self, tmp_path):
app_dir = _make_app(tmp_path, SIMPLE_TOWERFILE, {"main.py": "print('hello')"})
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
manifest = json.loads(entries["MANIFEST"])
Expand All @@ -187,7 +188,7 @@ def test_excludes_pycache(self, tmp_path):
)
output = str(tmp_path / "out.tar.gz")

_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

entries = _read_package(output)
pycache_entries = [k for k in entries if "__pycache__" in k]
Expand All @@ -198,14 +199,14 @@ def test_error_missing_towerfile(self, tmp_path):
output = str(tmp_path / "out.tar.gz")

with pytest.raises(RuntimeError):
_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

def test_error_invalid_towerfile(self, tmp_path):
app_dir = _make_app(tmp_path, "this is not valid toml [[[", {"main.py": ""})
output = str(tmp_path / "out.tar.gz")

with pytest.raises(RuntimeError):
_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)

def test_error_missing_app_name(self, tmp_path):
towerfile = """\
Expand All @@ -216,4 +217,4 @@ def test_error_missing_app_name(self, tmp_path):
output = str(tmp_path / "out.tar.gz")

with pytest.raises(RuntimeError):
_native.build_package(app_dir, output)
tower.packages.build_package(app_dir, output)
Loading