chore: 初始化 MCM/ICM Toolkit 仓库骨架
审查并精简 ChatGPT 的建库建议后落地的第一版骨架,只定接口不写实现。 - 建议审查:14 个包 → 7 个;约 250 个函数 → 约 40 个;5 个 Result 类 → 1 个 (docs/01-suggestion-review.md) - docs/:架构、路线图(含永久不做清单)、环境、Git 工作流、函数卡片模板 - src/mcm_toolkit/:core / data / stats / models / solve / decision / viz 共 23 个模块,均为签名 + docstring + NotImplementedError - tests/:9 个文件,其中 test_api_surface.py 已通过(20 passed) - examples/ problems/ notebooks/ figures/ tables/ 骨架 - pyproject.toml(核心依赖 4 个 + 6 组 extras)、environment.yml - scripts/:setup-venv.ps1(ASCII + LF)、setup-conda.ps1、doctor.ps1 - 环境:.venv(system-site-packages)与 conda 环境 mcm-toolkit 均已建好, 数值栈版本与 base 完全对齐(numpy 2.4.6 / scipy 1.18.1 / pandas 3.0.6,MKL 后端)
This commit is contained in:
commit
5319589dfd
76 files changed
+6812
No files matched your search
@@ -0,0 +1,71 @@
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create .venv inside the repo and install mcm-toolkit in editable mode.
|
||||
|
||||
.DESCRIPTION
|
||||
Uses --system-site-packages so the venv reuses the scientific stack already
|
||||
installed in Anaconda base. That makes the whole step OFFLINE: no package is
|
||||
downloaded, yet numpy / scipy / pandas / matplotlib / sklearn / statsmodels /
|
||||
networkx / sympy are all importable.
|
||||
|
||||
The editable install uses --no-deps --no-build-isolation: dependencies are
|
||||
already provided by base, and pip must not go online for a build backend.
|
||||
|
||||
NOTE: this file is intentionally pure ASCII and UTF-8 without BOM.
|
||||
Windows PowerShell 5.1 parses .ps1 as ANSI when there is no BOM, so non-ASCII
|
||||
characters (e.g. Chinese) turn into illegal bytes and cause syntax errors.
|
||||
|
||||
.PARAMETER Python
|
||||
Interpreter used to create the venv. Default: D:\anaconda\python.exe
|
||||
|
||||
.PARAMETER Recreate
|
||||
Delete and recreate .venv if it already exists.
|
||||
|
||||
.EXAMPLE
|
||||
.\scripts\setup-venv.ps1
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Python = 'D:\anaconda\python.exe',
|
||||
[switch]$Recreate
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$venvDir = Join-Path $repoRoot '.venv'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $Python)) {
|
||||
$cmd = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $cmd) { throw "Python interpreter not found: $Python" }
|
||||
$Python = $cmd.Source
|
||||
Write-Host "Using python from PATH: $Python" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
if (Test-Path -LiteralPath $venvDir) {
|
||||
if (-not $Recreate) {
|
||||
Write-Host '.venv already exists. Use -Recreate to rebuild.' -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host 'Removing existing .venv ...'
|
||||
Remove-Item -LiteralPath $venvDir -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $venvDir)) {
|
||||
Write-Host '[1/3] creating .venv (--system-site-packages, reuses Anaconda base) ...'
|
||||
& $Python -m venv --system-site-packages --prompt 'mcm-toolkit' $venvDir
|
||||
if ($LASTEXITCODE -ne 0) { throw 'venv creation failed' }
|
||||
}
|
||||
|
||||
$venvPy = Join-Path $venvDir 'Scripts\python.exe'
|
||||
|
||||
Write-Host '[2/3] editable install of mcm-toolkit (--no-deps --no-build-isolation) ...'
|
||||
& $venvPy -m pip install -e $repoRoot --no-deps --no-build-isolation --disable-pip-version-check
|
||||
if ($LASTEXITCODE -ne 0) { throw 'pip install -e failed' }
|
||||
|
||||
Write-Host '[3/3] verifying ...'
|
||||
& $venvPy -c "import mcm_toolkit, numpy, scipy, pandas, matplotlib; print('mcm_toolkit', mcm_toolkit.__version__); print('numpy', numpy.__version__)"
|
||||
|
||||
Write-Host ''
|
||||
Write-Host 'Done. Activate with:' -ForegroundColor Green
|
||||
Write-Host ' .\.venv\Scripts\Activate.ps1'
|
||||
Reference in new issue
Block a user