You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

131 lines
4.4 KiB

#!/usr/bin/env python3
"""
Setup script for PyStorm - Python bindings for StormLib
"""
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
from pathlib import Path
import subprocess
import sys
import os
class BuildStormLib(build_py):
"""Custom build command to compile StormLib if needed"""
def run(self):
"""Run the build"""
package_dir = Path(__file__).parent / 'pystorm'
# Check if library already exists in package
lib_patterns = ['*.so', '*.dll', '*.dylib']
lib_found_in_package = False
for pattern in lib_patterns:
if list(package_dir.glob(pattern)):
lib_found_in_package = True
print(f"Found StormLib library in package directory")
break
if not lib_found_in_package:
# Try to build StormLib
print("\n" + "="*70)
print("StormLib not found in package directory")
print("="*70)
print("\nAttempting to build StormLib automatically...")
try:
build_script = Path(__file__).parent / 'build_stormlib.py'
if build_script.exists():
result = subprocess.run(
[sys.executable, str(build_script)],
cwd=Path(__file__).parent
)
if result.returncode == 0:
print("✓ StormLib built successfully")
else:
print("✗ Failed to build StormLib automatically")
self._print_manual_instructions()
else:
self._print_manual_instructions()
except Exception as e:
print(f"Error during automatic build: {e}")
self._print_manual_instructions()
# Run the normal build
build_py.run(self)
def _print_manual_instructions(self):
"""Print manual installation instructions"""
print("\nTo build StormLib manually:")
print("\n python3 build_stormlib.py")
print("\nOr install StormLib system-wide:")
print("\n1. Clone the repository:")
print(" git clone https://github.com/ladislav-zezula/StormLib.git")
print("\n2. Build and install:")
print(" cd StormLib")
print(" mkdir build && cd build")
print(" cmake ..")
print(" make")
print(" sudo make install # Linux/macOS")
print("\n3. Then run: pip install -e .")
print("="*70 + "\n")
# Read the README file
readme_path = Path(__file__).parent / "README.md"
long_description = ""
if readme_path.exists():
long_description = readme_path.read_text(encoding="utf-8")
setup(
name="pystorm",
version="1.0.0",
description="Python bindings for StormLib - A library for working with MPQ archives",
long_description=long_description,
long_description_content_type="text/markdown",
author="Matteo Benedetto",
author_email="your.email@example.com",
url="https://github.com/enne2/pystorm",
license="MIT",
packages=find_packages(),
package_data={
'pystorm': ['*.so', '*.so.*', '*.dll', '*.dylib'],
},
include_package_data=True,
python_requires=">=3.7",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Archiving",
],
keywords="mpq stormlib blizzard archive mopaq",
project_urls={
"Homepage": "https://github.com/enne2/pystorm",
"Repository": "https://github.com/enne2/pystorm",
"Bug Tracker": "https://github.com/enne2/pystorm/issues",
"StormLib Repository": "https://github.com/ladislav-zezula/StormLib",
},
cmdclass={
'build_py': BuildStormLib,
},
extras_require={
'dev': [
'pytest>=7.0',
'black>=22.0',
'flake8>=4.0',
'mypy>=0.950',
],
},
)