setup.py•3.29 kB
#!/usr/bin/env python3
"""
Setup script for robot-navigation-mcp package.
This script enables editable installation with pip install -e .
"""
from setuptools import setup
from setuptools.config.setupcfg import read_configuration
import os
import sys
# Try to import tomllib for Python 3.11+ or use toml for older versions
try:
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
except ImportError:
try:
import tomli as tomllib
except ImportError:
print("Error: Requires tomli package for Python < 3.11")
print("Please run: pip install tomli")
sys.exit(1)
def read_pyproject_toml():
"""Read configuration from pyproject.toml file."""
pyproject_path = os.path.join(os.path.dirname(__file__), 'pyproject.toml')
if not os.path.exists(pyproject_path):
raise FileNotFoundError(f"pyproject.toml not found at {pyproject_path}")
with open(pyproject_path, 'rb') as f:
return tomllib.load(f)
def main():
"""Main setup function."""
try:
config = read_pyproject_toml()
project_config = config.get('project', {})
# Extract project information
name = project_config.get('name', 'robot-navigation-mcp')
version = project_config.get('version', '0.1.0')
description = project_config.get('description', '')
readme = project_config.get('readme', 'README.md')
requires_python = project_config.get('requires-python', '>=3.8')
license_text = project_config.get('license', {}).get('text', 'MIT')
authors = project_config.get('authors', [])
classifiers = project_config.get('classifiers', [])
dependencies = project_config.get('dependencies', [])
# Handle optional dependencies
optional_dependencies = project_config.get('optional-dependencies', {})
# Handle scripts
scripts = project_config.get('scripts', {})
# Read README file if it exists
long_description = ''
if readme and os.path.exists(readme):
with open(readme, 'r', encoding='utf-8') as f:
long_description = f.read()
# Format author information
author = ', '.join([author.get('name', '') for author in authors])
# Setup package
setup(
name=name,
version=version,
description=description,
long_description=long_description,
long_description_content_type='text/markdown' if readme.endswith('.md') else 'text/plain',
author=author,
license=license_text,
classifiers=classifiers,
python_requires=requires_python,
install_requires=dependencies,
extras_require=optional_dependencies,
entry_points={
'console_scripts': [
f'{cmd}={module}' for cmd, module in scripts.items()
]
},
package_dir={'': 'src'},
packages=['robot_navigation_mcp'],
zip_safe=False,
)
except Exception as e:
print(f"Error during setup: {e}")
sys.exit(1)
if __name__ == '__main__':
main()