diff --git a/src/tower/__init__.py b/src/tower/__init__.py index 4261b6b2..27c1bc1d 100644 --- a/src/tower/__init__.py +++ b/src/tower/__init__.py @@ -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 @@ -39,6 +38,7 @@ # Sub-packages to expose # from . import info +from . import packages def __getattr__(name: str): diff --git a/src/tower/packages/__init__.py b/src/tower/packages/__init__.py new file mode 100644 index 00000000..9774b68b --- /dev/null +++ b/src/tower/packages/__init__.py @@ -0,0 +1 @@ +from .._native import build_package diff --git a/tests/tower/test_build_package.py b/tests/tower/test_build_package.py index 2de9dc94..8426cbb0 100644 --- a/tests/tower/test_build_package.py +++ b/tests/tower/test_build_package.py @@ -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): @@ -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) @@ -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 @@ -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"]) @@ -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 @@ -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 @@ -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 @@ -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"]) @@ -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"]) @@ -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"]) @@ -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] @@ -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 = """\ @@ -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)