-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapply_and_rebuild.ps1
More file actions
270 lines (236 loc) · 10.5 KB
/
Copy pathapply_and_rebuild.ps1
File metadata and controls
270 lines (236 loc) · 10.5 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# ============================================================
# PiQrypt — Appliquer corrections v1.7.9 + rebuild + republier
# Depuis : C:\Users\julie\Documents\Papa\Github\piqrypt
#
# Usage : .\apply_and_rebuild.ps1
# .\apply_and_rebuild.ps1 -SkipPublish # build sans publier
# ============================================================
param([switch]$SkipPublish)
$ROOT = "C:\Users\julie\Documents\Papa\Github\piqrypt"
Set-Location $ROOT
function OK { param($msg) Write-Host " [OK] $msg" -ForegroundColor Green }
function FAIL { param($msg) Write-Host " [FAIL] $msg" -ForegroundColor Red }
function INFO { param($msg) Write-Host " [...] $msg" -ForegroundColor Cyan }
function SEP { Write-Host " ──────────────────────────────────────────────" -ForegroundColor DarkGray }
function SECTION { param($t) Write-Host ""; Write-Host " ═══ $t ═══" -ForegroundColor White; SEP }
# ── ÉTAPE 1 : Créer piqrypt/__init__.py ──────────────────────────────────────
SECTION "1. Création piqrypt/__init__.py"
if (-not (Test-Path "piqrypt")) {
New-Item -ItemType Directory -Force -Path "piqrypt" | Out-Null
OK "Dossier piqrypt/ créé"
} else {
INFO "Dossier piqrypt/ existant"
}
$initContent = @'
# SPDX-License-Identifier: Elastic-2.0
# Copyright (c) 2026 PiQrypt Inc.
# e-Soleau: DSO2026006483 (19/02/2026) -- DSO2026009143 (12/03/2026)
"""
PiQrypt — Trust & Continuity Layer for Autonomous AI Agents
AISS v2.0 Reference Implementation
"""
__version__ = "1.7.9"
__author__ = "PiQrypt Inc."
__email__ = "contact@piqrypt.com"
__license__ = "Elastic-2.0"
__url__ = "https://piqrypt.com"
try:
from aiss import ( # noqa: F401
generate_keypair,
derive_agent_id,
stamp_event,
stamp_genesis_event,
verify_signature,
verify_event,
export_identity,
)
from aiss.license import ( # noqa: F401
get_tier,
get_license_info,
activate_license,
is_pro,
)
except ImportError:
pass
__all__ = [
"__version__",
"generate_keypair", "derive_agent_id",
"stamp_event", "stamp_genesis_event",
"verify_signature", "verify_event",
"export_identity",
"get_tier", "get_license_info", "activate_license", "is_pro",
]
'@
$initContent | Out-File -FilePath "piqrypt\__init__.py" -Encoding utf8
OK "piqrypt/__init__.py écrit"
# Vérifier
$ver = python -c "import sys; sys.path.insert(0, '.'); import piqrypt; print(piqrypt.__version__)" 2>&1
if ($LASTEXITCODE -eq 0) {
OK "import piqrypt local → version $ver"
} else {
FAIL "import piqrypt local échoue : $ver"
}
# ── ÉTAPE 2 : Créer piqrypt/py.typed ─────────────────────────────────────────
SECTION "2. py.typed (PEP 561)"
"" | Out-File -FilePath "piqrypt\py.typed" -Encoding utf8
OK "piqrypt/py.typed créé"
# ── ÉTAPE 3 : Vérifier pyproject.toml ────────────────────────────────────────
SECTION "3. Vérification pyproject.toml"
$pyproj = Get-Content "pyproject.toml" -Raw
# Vérifier que piqrypt* est dans find.include
if ($pyproj -match '"piqrypt\*"') {
OK "piqrypt* déjà dans packages.find.include"
} else {
INFO "Ajout de piqrypt* dans packages.find.include..."
# Remplacement de la section include
$pyproj = $pyproj -replace '(include = \[)', '$1
"piqrypt*",'
$pyproj | Out-File -FilePath "pyproject.toml" -Encoding utf8
OK "piqrypt* ajouté à packages.find.include"
}
# Vérifier que "piqrypt" est dans package-data
if ($pyproj -match '"piqrypt"') {
OK "piqrypt dans package-data"
} else {
INFO "Ajout de piqrypt dans package-data..."
$pyproj = $pyproj -replace '(\[tool\.setuptools\.package-data\])', '$1
"piqrypt" = ["py.typed"]'
$pyproj | Out-File -FilePath "pyproject.toml" -Encoding utf8
OK "piqrypt ajouté à package-data"
}
# ── ÉTAPE 4 : Nettoyage dist/ ────────────────────────────────────────────────
SECTION "4. Nettoyage dist/"
if (Test-Path "dist") {
Remove-Item -Recurse -Force "dist"
OK "dist/ supprimé"
}
if (Test-Path "build") {
Remove-Item -Recurse -Force "build"
OK "build/ supprimé"
}
Get-ChildItem -Filter "*.egg-info" -Directory | Remove-Item -Recurse -Force
OK "*.egg-info supprimés"
# ── ÉTAPE 5 : Build ──────────────────────────────────────────────────────────
SECTION "5. Build wheel + sdist"
INFO "pip install build..."
python -m pip install --upgrade build --quiet
INFO "python -m build..."
python -m build 2>&1 | Tee-Object -Variable buildOut | Out-Null
if ($LASTEXITCODE -eq 0) {
$wheel = Get-ChildItem "dist\*.whl" | Select-Object -First 1
$sdist = Get-ChildItem "dist\*.tar.gz" | Select-Object -First 1
OK "Build réussi"
INFO "Wheel : $($wheel.Name) ($([math]::Round($wheel.Length/1KB, 0)) KB)"
INFO "SDist : $($sdist.Name) ($([math]::Round($sdist.Length/1KB, 0)) KB)"
} else {
FAIL "Build échoué"
Write-Host $buildOut -ForegroundColor Red
exit 1
}
# ── ÉTAPE 6 : Vérifier contenu du wheel ──────────────────────────────────────
SECTION "6. Vérification contenu du wheel"
INFO "Inspection du wheel..."
$wheelPath = (Get-ChildItem "dist\*.whl" | Select-Object -First 1).FullName
$wheelContent = python -c @"
import zipfile, sys
with zipfile.ZipFile(r'$wheelPath') as z:
names = z.namelist()
checks = {
'piqrypt/__init__.py': any('piqrypt/__init__' in n for n in names),
'aiss/__init__.py': any('aiss/__init__' in n for n in names),
'vigil/vigil_server.py': any('vigil/vigil_server' in n for n in names),
'vigil/vigil_v4_final.html': any('vigil_v4_final.html' in n for n in names),
'trustgate/trustgate_server.py':any('trustgate/trustgate_server' in n for n in names),
'cli/piqrypt_start.py': any('cli/piqrypt_start' in n for n in names),
'cli/auth_middleware.py': any('cli/auth_middleware' in n for n in names),
}
for k, v in checks.items():
print(f'{k}={"PRESENT" if v else "ABSENT"}')
"@ 2>&1
$allPresent = $true
$wheelContent | ForEach-Object {
if ($_ -match "=PRESENT") {
OK $_
} elseif ($_ -match "=ABSENT") {
FAIL "MANQUANT dans wheel : $_"
$allPresent = $false
} else {
INFO $_
}
}
if (-not $allPresent) {
FAIL "Des fichiers critiques manquent dans le wheel — ne pas publier"
exit 1
}
# ── ÉTAPE 7 : Test install local depuis wheel ─────────────────────────────────
SECTION "7. Test install local depuis wheel (venv isolé)"
$testVenv = "$env:TEMP\piqrypt_verify_$(Get-Random)"
python -m venv $testVenv 2>&1 | Out-Null
$testPY = "$testVenv\Scripts\python.exe"
INFO "Installation depuis le wheel local..."
& "$testVenv\Scripts\pip.exe" install $wheelPath --quiet 2>&1 | Out-Null
$testResult = & $testPY -c @"
import piqrypt
print(f'version={piqrypt.__version__}')
from aiss import generate_keypair, derive_agent_id, stamp_genesis_event, verify_signature
from aiss.chain import compute_event_hash
priv, pub = generate_keypair()
aid = derive_agent_id(pub)
g = stamp_genesis_event(priv, pub, aid, {'test': True})
ok = verify_signature(g, pub)
print(f'import_piqrypt=OK')
print(f'crypto={"OK" if ok else "FAIL"}')
# Vérifier que vigil_server est localisable
from pathlib import Path
pkg = Path(piqrypt.__file__).parent
vigil_html = pkg.parent / 'vigil' / 'vigil_v4_final.html'
vigil_srv = pkg.parent / 'vigil' / 'vigil_server.py'
print(f'vigil_html={"PRESENT" if vigil_html.exists() else "ABSENT"}')
print(f'vigil_server={"PRESENT" if vigil_srv.exists() else "ABSENT"}')
"@ 2>&1
$testResult | ForEach-Object {
if ($_ -match "=OK|=PRESENT") { OK $_ }
elseif ($_ -match "=FAIL|=ABSENT") { FAIL $_ }
else { INFO $_ }
}
Remove-Item -Recurse -Force $testVenv -ErrorAction SilentlyContinue
# ── ÉTAPE 8 : Commit Git ─────────────────────────────────────────────────────
SECTION "8. Commit Git"
git add piqrypt/__init__.py piqrypt/py.typed pyproject.toml 2>&1 | Out-Null
git status --short
$commitMsg = "feat: add piqrypt/ module package — fixes import piqrypt from PyPI"
git commit -m $commitMsg 2>&1
if ($LASTEXITCODE -eq 0) {
OK "Commit : $commitMsg"
} else {
INFO "Pas de changement à commiter (déjà en place ?)"
}
# ── ÉTAPE 9 : Publication PyPI ───────────────────────────────────────────────
SECTION "9. Publication PyPI"
if ($SkipPublish) {
INFO "Publication ignorée (-SkipPublish)"
INFO "Pour publier manuellement : twine upload dist/*"
} else {
INFO "Publication sur PyPI..."
INFO "(nécessite twine + credentials PyPI)"
python -m pip install --upgrade twine --quiet
python -m twine upload dist/* 2>&1
if ($LASTEXITCODE -eq 0) {
OK "Publié sur PyPI — https://pypi.org/project/piqrypt/"
} else {
FAIL "Publication échouée — vérifiez vos credentials PyPI"
}
}
Write-Host ""
Write-Host " ════════════════════════════════════════════════" -ForegroundColor White
Write-Host " CORRECTIONS APPLIQUÉES — PiQrypt v1.7.9" -ForegroundColor White
Write-Host " ════════════════════════════════════════════════" -ForegroundColor White
Write-Host ""
Write-Host " Fichiers créés/modifiés :" -ForegroundColor Cyan
Write-Host " piqrypt/__init__.py — nouveau module piqrypt" -ForegroundColor White
Write-Host " piqrypt/py.typed — marker PEP 561" -ForegroundColor White
Write-Host " pyproject.toml — piqrypt* dans find + package-data" -ForegroundColor White
Write-Host ""
Write-Host " Relancer le test complet :" -ForegroundColor Cyan
Write-Host " .\test_piqrypt_pypi.ps1" -ForegroundColor White
Write-Host ""