update pyproject name and save location again

main
Justin Barnett 2025-04-08 11:10:01 -04:00
parent b8c8910323
commit 0aa191c7e3
2 changed files with 21 additions and 20 deletions

View File

@ -9,7 +9,7 @@ namespace UnityMcpBridge.Editor.Helpers
{ {
public static class ServerInstaller public static class ServerInstaller
{ {
private const string PackageName = "unity-mcp-server"; private const string PackageName = "UnityMcpServer";
private const string BranchName = "feature/install-overhaul"; // Adjust branch as needed private const string BranchName = "feature/install-overhaul"; // Adjust branch as needed
private const string GitUrl = "https://github.com/justinpbarnett/unity-mcp.git"; private const string GitUrl = "https://github.com/justinpbarnett/unity-mcp.git";
private const string PyprojectUrl = private const string PyprojectUrl =
@ -124,29 +124,29 @@ namespace UnityMcpBridge.Editor.Helpers
/// </summary> /// </summary>
private static void InstallServer(string location) private static void InstallServer(string location)
{ {
// Create the directory if it doesn't exist // Create the src directory where the server code will reside
string serverDir = Path.Combine(location, "src"); string serverDir = Path.Combine(location, "src");
Directory.CreateDirectory(serverDir); Directory.CreateDirectory(serverDir);
// Initialize git repo // Initialize git repo in the src directory
RunCommand("git", $"init", workingDirectory: location); RunCommand("git", $"init", workingDirectory: serverDir);
// Add remote // Add remote
RunCommand("git", $"remote add origin {GitUrl}", workingDirectory: location); RunCommand("git", $"remote add origin {GitUrl}", workingDirectory: serverDir);
// Configure sparse checkout // Configure sparse checkout
RunCommand("git", "config core.sparseCheckout true", workingDirectory: location); RunCommand("git", "config core.sparseCheckout true", workingDirectory: serverDir);
// Set sparse checkout path to only include UnityMcpServer folder // Set sparse checkout path to only include UnityMcpServer folder
string sparseCheckoutPath = Path.Combine(location, ".git", "info", "sparse-checkout"); string sparseCheckoutPath = Path.Combine(serverDir, ".git", "info", "sparse-checkout");
File.WriteAllText(sparseCheckoutPath, "UnityMcpServer/"); File.WriteAllText(sparseCheckoutPath, "UnityMcpServer/");
// Fetch and checkout the branch // Fetch and checkout the branch
RunCommand("git", $"fetch --depth=1 origin {BranchName}", workingDirectory: location); RunCommand("git", $"fetch --depth=1 origin {BranchName}", workingDirectory: serverDir);
RunCommand("git", $"checkout {BranchName}", workingDirectory: location); RunCommand("git", $"checkout {BranchName}", workingDirectory: serverDir);
// Create version.txt file based on the pyproject.toml // Create version.txt file based on pyproject.toml, stored at the root level
string pyprojectPath = Path.Combine(location, "UnityMcpServer", "pyproject.toml"); string pyprojectPath = Path.Combine(serverDir, "UnityMcpServer", "pyproject.toml");
if (File.Exists(pyprojectPath)) if (File.Exists(pyprojectPath))
{ {
string pyprojectContent = File.ReadAllText(pyprojectPath); string pyprojectContent = File.ReadAllText(pyprojectPath);
@ -158,7 +158,7 @@ namespace UnityMcpBridge.Editor.Helpers
throw new Exception("Failed to find pyproject.toml after checkout"); throw new Exception("Failed to find pyproject.toml after checkout");
} }
// Set up virtual environment // Set up virtual environment at the root level
string venvPath = Path.Combine(location, "venv"); string venvPath = Path.Combine(location, "venv");
RunCommand("python", $"-m venv \"{venvPath}\""); RunCommand("python", $"-m venv \"{venvPath}\"");
@ -173,12 +173,12 @@ namespace UnityMcpBridge.Editor.Helpers
// Install uv into the virtual environment // Install uv into the virtual environment
RunCommand(pythonPath, "-m pip install uv"); RunCommand(pythonPath, "-m pip install uv");
// Use uv to install dependencies from the UnityMcpServer subdirectory // Use uv to install dependencies from the UnityMcpServer subdirectory in src
string uvPath = Path.Combine( string uvPath = Path.Combine(
venvPath, venvPath,
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Scripts\\uv.exe" : "bin/uv" RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Scripts\\uv.exe" : "bin/uv"
); );
RunCommand(uvPath, "pip install ./UnityMcpServer", workingDirectory: location); RunCommand(uvPath, "pip install ./src/UnityMcpServer", workingDirectory: location);
} }
/// <summary> /// <summary>
@ -205,11 +205,12 @@ namespace UnityMcpBridge.Editor.Helpers
/// </summary> /// </summary>
private static void UpdateServer(string location) private static void UpdateServer(string location)
{ {
// Pull only the sparse checkout paths (UnityMcpServer folder) // Pull latest changes in the src directory
RunCommand("git", "pull origin " + BranchName, workingDirectory: location); string serverDir = Path.Combine(location, "src");
RunCommand("git", $"pull origin {BranchName}", workingDirectory: serverDir);
// Update version.txt file // Update version.txt file based on pyproject.toml in src
string pyprojectPath = Path.Combine(location, "UnityMcpServer", "pyproject.toml"); string pyprojectPath = Path.Combine(serverDir, "UnityMcpServer", "pyproject.toml");
if (File.Exists(pyprojectPath)) if (File.Exists(pyprojectPath))
{ {
string pyprojectContent = File.ReadAllText(pyprojectPath); string pyprojectContent = File.ReadAllText(pyprojectPath);
@ -223,7 +224,7 @@ namespace UnityMcpBridge.Editor.Helpers
venvPath, venvPath,
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Scripts\\uv.exe" : "bin/uv" RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Scripts\\uv.exe" : "bin/uv"
); );
RunCommand(uvPath, "pip install -U ./UnityMcpServer", workingDirectory: location); RunCommand(uvPath, "pip install -U ./src/UnityMcpServer", workingDirectory: location);
} }
/// <summary> /// <summary>

View File

@ -1,5 +1,5 @@
[project] [project]
name = "unity-mcp-server" name = "UnityMcpServer"
version = "2.0.0" version = "2.0.0"
description = "Unity MCP Server: A Unity package for Unity Editor integration via the Model Context Protocol (MCP)." description = "Unity MCP Server: A Unity package for Unity Editor integration via the Model Context Protocol (MCP)."
readme = "README.md" readme = "README.md"