skywind3000 / PyStand

:rocket: Python Standalone Deploy Environment !!
MIT License
641 stars 75 forks source link

Py_Main的部分行为和python -c 的不一致 #57

Closed junbaibai0719 closed 9 months ago

junbaibai0719 commented 9 months ago

用PyStand.exe启动一个统计目录里文件个数的程序,发现和直接python启动的运行结果不一致。 和Windows命令行的也不一致,在3.8.10和3.9.10均发现了这个问题。与命令行参数-I -s -S无关,纯粹就是Py_Main方法的问题。 Py_Main会直接忽略掉某些名字过长的文件,导致开发时候的运行结果和打包以后不一样,定位了好久。不知道还有没有别的地方有这种问题,打包方式可能又得换回pyinstaller了。 image image import pathlib s = pathlib.Path().rglob("*") s = filter(lambda f:f.is_file(), s) s = list(s) print(len(s))

junbaibai0719 commented 9 months ago

破案了,路径长度超出Windows的限制,然后我自己改注册表开了Windows长路径,这些文件不能直接用应用程序打开,但是能被explorer发现,不知道为啥Py_Main启动就发现不了这些文件,直接python shell里就可以。

skywind3000 commented 9 months ago

你可以多次改变当前路径来解决,或者自己检测后提示

junbaibai0719 commented 9 months ago

无法理解从dll里的Py_Main启动为啥对于那些路径长度超过260的文件直接判断不存在了,但是exe启动却没有。

junbaibai0719 commented 9 months ago

python.c的源码复制过来重新编译了一个exe,还是检测不到路径长度大于260的文件,但是原版的就可以,vcxproj我还看不懂,不知道要加啥编译设置。

skywind3000 commented 9 months ago

没搞过路径长度。

junbaibai0719 commented 9 months ago

定位了一天,发现python.manifest里有longPathAware这个东西,然后一搜,发现已经有人遇到过这个问题了https://www.jianshu.com/p/034716c81055