Repository navigation
Expand file tree
/
Copy pathtest_installation.py
More file actions
executable file
·125 lines (103 loc) · 4.08 KB
/
Copy pathtest_installation.py
File metadata and controls
executable file
·125 lines (103 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3
"""
Test script to verify the parallax-maker package installation.
"""
import subprocess
import sys
import tempfile
from pathlib import Path
def run_command(cmd, description, capture_output=True, timeout=120):
"""Run a command and return success status."""
print(f"Testing: {description}")
print(f"Command: {cmd}")
try:
result = subprocess.run(
cmd,
shell=True,
capture_output=capture_output,
text=True,
timeout=timeout,
check=False,
)
if result.returncode == 0:
print("✅ Success")
if capture_output and result.stdout.strip():
print(f"Output: {result.stdout.strip()}")
return True
else:
print("❌ Failed")
if capture_output and result.stderr.strip():
print(f"Error: {result.stderr.strip()}")
return False
except subprocess.TimeoutExpired:
print("⏱️ Timeout")
return False
except Exception as e:
print(f"❌ Exception: {e}")
return False
def main():
"""Test the package installation."""
print("🧪 Testing Parallax Maker Package Installation")
print("=" * 50)
# Find the wheel file
dist_dir = Path("dist")
if not dist_dir.exists():
print("❌ No dist/ directory found. Run 'python -m build' first.")
sys.exit(1)
wheel_files = list(dist_dir.glob("*.whl"))
if not wheel_files:
print("❌ No wheel files found in dist/")
sys.exit(1)
wheel_file = wheel_files[0]
print(f"📦 Found wheel: {wheel_file}")
# Create a temporary virtual environment
with tempfile.TemporaryDirectory() as temp_dir:
venv_dir = Path(temp_dir) / "test_env"
print(f"\n🔧 Creating test environment in {venv_dir}")
# Create virtual environment
if not run_command(
f"python -m venv {venv_dir}", "Creating virtual environment"
):
return False
# Determine activation script
if sys.platform == "win32":
activate_script = venv_dir / "Scripts" / "activate"
python_exe = venv_dir / "Scripts" / "python.exe"
else:
activate_script = venv_dir / "bin" / "activate"
python_exe = venv_dir / "bin" / "python"
# Upgrade pip first
upgrade_cmd = f"{python_exe} -m pip install --upgrade pip"
if not run_command(upgrade_cmd, "Upgrading pip"):
return False
# Install the wheel with dependencies
install_cmd = f"{python_exe} -m pip install {wheel_file.absolute()}"
if not run_command(
install_cmd, "Installing parallax-maker wheel", capture_output=False
):
return False
# Test importing the package
import_cmd = f'{python_exe} -c "import parallax_maker; print(f\\"Parallax Maker v{{parallax_maker.__version__}} imported successfully\\")"'
if not run_command(import_cmd, "Testing package import"):
return False
# Test CLI commands
help_cmd = f"{python_exe} -c \"import sys; sys.argv=['parallax-maker', '--help']; from parallax_maker.server import main; main()\""
if not run_command(help_cmd, "Testing parallax-maker --help"):
return False
gltf_help_cmd = f"{python_exe} -c \"import sys; sys.argv=['parallax-gltf-cli', '--help']; from parallax_maker.gltf_cli import main; main()\""
if not run_command(gltf_help_cmd, "Testing parallax-gltf-cli --help"):
return False
print("\n🎉 All tests passed!")
print("📦 Package is ready for PyPI upload!")
print("\nNext steps:")
print(
"1. Upload to TestPyPI: python -m twine upload --repository testpypi dist/*"
)
print(
"2. Test from TestPyPI: pip install --index-url https://test.pypi.org/simple/ parallax-maker"
)
print("3. Upload to PyPI: python -m twine upload dist/*")
return True
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)