把黎曼猜想的 Lean 证明,写成人能读懂的证明
把黎曼猜想的 Lean 证明写成数学家能读的证明文章,以及人人能看懂的证明思路
Support long original source paths on Windows
Browse files+17 −14 routes/cogito-source-provenance/prepare_sources.py View file
| @@ -19,7 +19,9 @@ def main(): | ||
| 19 | 19 | p.add_argument('--cache',required=True,type=Path) |
| 20 | 20 | p.add_argument('--private-root',required=True,type=Path) |
| 21 | 21 | p.add_argument('--report',required=True,type=Path) |
| 22 | - a=p.parse_args();verify(a.cache);root=a.private_root.resolve();root.mkdir(parents=True,exist_ok=True) | |
| 22 | + a=p.parse_args();verify(a.cache);root=a.private_root.resolve() | |
| 23 | + if os.name=='nt':root=Path('\\\\?\\'+str(root)) | |
| 24 | + root.mkdir(parents=True,exist_ok=True) | |
| 23 | 25 | count=0 |
| 24 | 26 | with io.BufferedReader(Parts([a.cache/n for n in PARTS])) as stream: |
| 25 | 27 | with tarfile.open(fileobj=stream,mode='r|gz') as archive: |
| @@ -38,24 +40,25 @@ def main(): | ||
| 38 | 40 | subprocess.run([curl,'-fsSL','--retry','4','--retry-all-errors', |
| 39 | 41 | f'https://raw.githubusercontent.com/leanprover-community/riemann-hypothesis/{BASELINE}/{relative}', |
| 40 | 42 | '-o',str(root/relative)],check=True) |
| 41 | - git=['git','-c','credential.helper=','-c','http.sslBackend=schannel'] if os.name=='nt' else ['git','-c','credential.helper='] | |
| 42 | - if not (root/'.git').exists():subprocess.run(git+['init',str(root)],check=True) | |
| 43 | + git=['git','-c','core.longpaths=true','-c','credential.helper=','-c','http.sslBackend=schannel'] if os.name=='nt' else ['git','-c','credential.helper='] | |
| 44 | + def git_path(path):return str(path).removeprefix('\\\\?\\') | |
| 45 | + if not (root/'.git').exists():subprocess.run(git+['init',git_path(root)],check=True) | |
| 43 | 46 | for key,value in [('core.autocrlf','false'),('user.name','cogito-curator'),('user.email','cogito-curator@users.noreply')]: |
| 44 | - subprocess.run(git+['-C',str(root),'config',key,value],check=True) | |
| 45 | - subprocess.run(git+['-C',str(root),'add','src','lakefile.toml','lake-manifest.json','lean-toolchain'],check=True) | |
| 46 | - tree=subprocess.check_output(git+['-C',str(root),'write-tree'],text=True).strip() | |
| 47 | - src_tree=subprocess.check_output(git+['-C',str(root),'rev-parse',tree+':src'],text=True).strip() | |
| 47 | + subprocess.run(git+['-C',git_path(root),'config',key,value],check=True) | |
| 48 | + subprocess.run(git+['-C',git_path(root),'add','src','lakefile.toml','lake-manifest.json','lean-toolchain'],check=True) | |
| 49 | + tree=subprocess.check_output(git+['-C',git_path(root),'write-tree'],text=True).strip() | |
| 50 | + src_tree=subprocess.check_output(git+['-C',git_path(root),'rev-parse',tree+':src'],text=True).strip() | |
| 48 | 51 | if src_tree!=CACHE_TREE:raise ValueError('staged source does not match the pinned cache source tree') |
| 49 | - diff=subprocess.run(git+['-C',str(root),'diff','--cached','--quiet']).returncode | |
| 50 | - if diff:subprocess.run(git+['-C',str(root),'commit','-m','Stage private original source with challenge-only cache wrapper'],check=True) | |
| 52 | + diff=subprocess.run(git+['-C',git_path(root),'diff','--cached','--quiet']).returncode | |
| 53 | + if diff:subprocess.run(git+['-C',git_path(root),'commit','--quiet','-m','Stage private original source with challenge-only cache wrapper'],check=True) | |
| 51 | 54 | manifest=json.loads((root/'lake-manifest.json').read_text());packages=root/'.lake/packages';packages.mkdir(parents=True,exist_ok=True) |
| 52 | 55 | for package in manifest['packages']: |
| 53 | 56 | dest=packages/package['name'];revision=package['rev'] |
| 54 | - if not (dest/'.git').exists():subprocess.run(git+['init',str(dest)],check=True) | |
| 55 | - present=subprocess.run(git+['-C',str(dest),'cat-file','-e',revision+'^{commit}'],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL).returncode==0 | |
| 56 | - if not present:subprocess.run(git+['-C',str(dest),'fetch','--depth=1',package['url'],revision],check=True) | |
| 57 | - subprocess.run(git+['-C',str(dest),'checkout','--detach',revision],check=True) | |
| 58 | - actual=subprocess.check_output(git+['-C',str(dest),'rev-parse','HEAD'],text=True).strip() | |
| 57 | + if not (dest/'.git').exists():subprocess.run(git+['init',git_path(dest)],check=True) | |
| 58 | + present=subprocess.run(git+['-C',git_path(dest),'cat-file','-e',revision+'^{commit}'],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL).returncode==0 | |
| 59 | + if not present:subprocess.run(git+['-C',git_path(dest),'fetch','--depth=1',package['url'],revision],check=True) | |
| 60 | + subprocess.run(git+['-C',git_path(dest),'checkout','--detach',revision],check=True) | |
| 61 | + actual=subprocess.check_output(git+['-C',git_path(dest),'rev-parse','HEAD'],text=True).strip() | |
| 59 | 62 | if actual!=revision:raise ValueError('dependency checkout mismatch') |
| 60 | 63 | print('Pinned dependency ready: '+package['name']+' '+actual,flush=True) |
| 61 | 64 | a.report.write_text(json.dumps({'source_files':count,'source_tree_with_challenge':src_tree,'mathlib_revision':MATHLIB, |