CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Typing] 设置环境变量 SKIP_STUB_GEN
阻止 gen_tensor_stub.py
生成 stub 文件
#65657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
… tensor_stub_env
情况1:默认编译,编译通过。命令: 日志: changing mode of build/bdist.linux-x86_64/wheel/paddlepaddle_gpu-0.0.0.data/scripts/paddle to 775
-- Generate stub file tensor.pyi ...
-- End Generate stub file tensor.pyi ...
[100%] Built target paddle_copy
make -j6 2>&1 60.03s user 8.60s system 140% cpu 48.859 total
tee ../../pmake.log 0.00s user 0.04s system 0% cpu 48.859 total 情况2:默认编译,编译不通过。如导入 paddle 失败等情况。 命令同上: 日志: [100%] Built target inference_lib_dist
Traceback (most recent call last):
File "/home/shun/Documents/Projects/paddle/megemini/Paddle/tools/gen_tensor_stub.py", line 411, in try_import_paddle
return importlib.import_module('paddlea')
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'paddlea'
ERROR: Can NOT import paddle from `tools/gen_tensor_stub.py` before installation.
So the stub file `python/paddle/tensor/tensor.pyi` of `paddle.Tensor` may be lost.
We COULD import paddle without installation with all libs (.dll or .so) copied into dir `paddle/libs`,
or path already been set for the system. Try the following steps to locate the problem.
1. Build with `SKIP_STUB_GEN=ON make -j$(nproc)`.
2. Install the wheel from `build/python/dist`.
3. Try to `import paddle` and check the problems.
-- Generate stub file tensor.pyi ...
Traceback (most recent call last):
File "setup.py", line 1197, in <module>
generate_tensor_stub('/home/shun/Documents/Projects/paddle/megemini/Paddle/build', '/home/shun/Documents/Projects/paddle/megemini/Paddle')
File "setup.py", line 1183, in generate_tensor_stub
gen_tensor_stub.generate_stub_file(
File "/home/shun/Documents/Projects/paddle/megemini/Paddle/tools/gen_tensor_stub.py", line 566, in generate_stub_file
tensor_members = get_tensor_members(module)
File "/home/shun/Documents/Projects/paddle/megemini/Paddle/tools/gen_tensor_stub.py", line 432, in get_tensor_members
raise (
ModuleNotFoundError: Can NOT import paddle from tools/gen_tensor_stub.py.
make[2]: *** [python/CMakeFiles/paddle_copy.dir/build.make:73: python/build/.timestamp_wheel] Error 1
make[1]: *** [CMakeFiles/Makefile2:55102: python/CMakeFiles/paddle_copy.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
make -j6 2>&1 27.52s user 5.71s system 233% cpu 14.250 total
tee ../../pmake.log 0.00s user 0.02s system 0% cpu 14.250 total 情况3:跳过生成 stub,编译通过。命令: 日志: removing build/bdist.linux-x86_64/wheel
[100%] Built target paddle_copy |
emmm,之后这种完全不相关的事情最好拆出去单独一个 PR |
This reverts commit c93447b.
python/setup.py.in
Outdated
@@ -1193,7 +1193,8 @@ def generate_tensor_stub(paddle_binary_dir, paddle_source_dir): | |||
print('-'*2, 'End Generate stub file tensor.pyi ... ') | |||
|
|||
# generate stub file `tensor.pyi` | |||
generate_tensor_stub('${PADDLE_BINARY_DIR}', '${PADDLE_SOURCE_DIR}') | |||
if not os.getenv("SKIP_STUB_GEN", None) == 'ON': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not os.getenv("SKIP_STUB_GEN", None) == 'ON': | |
if not os.getenv("SKIP_STUB_GEN", None).lower() in ['y', 'yes', 't', 'true', 'on', '1']: |
稍微增加下容错吧,这些都是常见的表示环境变量开启的 value,setup.py 同
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for setup.py.in
PR Category
User Experience
PR Types
Improvements
Description
设置环境变量
SKIP_STUB_GEN
阻止gen_tensor_stub.py
生成 stub 文件如果接受此 PR 的方案,则可以关闭 #65646
@SigureMo
closes #65646