Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[mypyc] Fix relative imports in__init__.pys#10543

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
msullivan merged 5 commits intopython:masterfromGobot1234:master
Jun 8, 2021
Merged

[mypyc] Fix relative imports in__init__.pys#10543

msullivan merged 5 commits intopython:masterfromGobot1234:master
Jun 8, 2021

Conversation

@Gobot1234
Copy link
Contributor

Description

Fixesmypyc/mypyc#842

Test Plan

Re ran the actions and nothing failed, and it solves the issues withimportlib.util.resolve_name failing.

Before:

(venv) James@Jamess-Air python-betterproto % mypyc src/betterproto/*.pyTraceback (most recent call last):  File"/Users/James/PycharmProjects/python-betterproto/build/setup.py", line 5,in<module>    ext_modules=mypycify(['src/betterproto/__init__.py','src/betterproto/_types.py','src/betterproto/_version.py','src/betterproto/casing.py'], opt_level="3"),  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/build.py", line 487,in mypycify    groups, group_cfilenames = mypyc_build(  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/build.py", line 400,in mypyc_build    group_cfiles, ops_text = generate_c(all_sources, options, groups, fscache,  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/build.py", line 200,in generate_c    modules, ctext = emitmodule.compile_modules_to_c(  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/codegen/emitmodule.py", line 410,in compile_modules_to_c    modules = compile_modules_to_ir(result, mapper, compiler_options, errors)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/codegen/emitmodule.py", line 258,in compile_modules_to_ir    scc_ir = compile_scc_to_ir(trees, result, mapper, compiler_options, errors)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/codegen/emitmodule.py", line 209,in compile_scc_to_ir    modules = build_ir(  File"/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 79,in innerreturn func(*args,**kwds)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/irbuild/main.py", line 80,in build_ir    transform_mypy_file(builder, module)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/irbuild/main.py", line 123,in transform_mypy_file    builder.accept(node)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/irbuild/builder.py", line 169,in accept    node.accept(self.visitor)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypy/nodes.py", line 379,in acceptreturn visitor.visit_import_from(self)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/irbuild/visitor.py", line 110,in visit_import_from    transform_import_from(self.builder, node)  File"/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/irbuild/statement.py", line 174,in transform_import_from    id = importlib.util.resolve_name('.'* node.relative + node.id, module_package)  File"/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 32,in resolve_name    raise ImportError(f'no package specified for {repr(name)}'src/betterproto/__init__.py:27: ImportError: no package specifiedfor'._types' (requiredfor relative module names)

After:

(venv) James@Jamess-Air python-betterproto % mypyc src/betterproto/*.pyrunning build_extbuilding '999479a26e36c714bed7__mypyc' extensiongcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/James/PycharmProjects/python-betterproto/venv/lib/python3.9/site-packages/mypyc/lib-rt -Ibuild -I/Users/James/PycharmProjects/python-betterproto/venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/__native_999479a26e36c714bed7.c -o build/temp.macosx-10.9-x86_64-3.9/build/__native_999479a26e36c714bed7.o -O3 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variablecreating build/lib.macosx-10.9-x86_64-3.9gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.9/build/__native_999479a26e36c714bed7.o -o build/lib.macosx-10.9-x86_64-3.9/999479a26e36c714bed7__mypyc.cpython-39-darwin.sobuilding 'betterproto.__init__' extensiongcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/James/PycharmProjects/python-betterproto/venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/betterproto.c -o build/temp.macosx-10.9-x86_64-3.9/build/betterproto.o -O3 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variablecreating build/lib.macosx-10.9-x86_64-3.9/betterprotogcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.9/build/betterproto.o -o build/lib.macosx-10.9-x86_64-3.9/betterproto/__init__.cpython-39-darwin.sobuilding 'betterproto._types' extensiongcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/James/PycharmProjects/python-betterproto/venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/betterproto/_types.c -o build/temp.macosx-10.9-x86_64-3.9/build/betterproto/_types.o -O3 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variablegcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.9/build/betterproto/_types.o -o build/lib.macosx-10.9-x86_64-3.9/betterproto/_types.cpython-39-darwin.sobuilding 'betterproto._version' extensiongcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/James/PycharmProjects/python-betterproto/venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/betterproto/_version.c -o build/temp.macosx-10.9-x86_64-3.9/build/betterproto/_version.o -O3 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variablegcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.9/build/betterproto/_version.o -o build/lib.macosx-10.9-x86_64-3.9/betterproto/_version.cpython-39-darwin.sobuilding 'betterproto.casing' extensiongcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/James/PycharmProjects/python-betterproto/venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/betterproto/casing.c -o build/temp.macosx-10.9-x86_64-3.9/build/betterproto/casing.o -O3 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variablegcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.9/build/betterproto/casing.o -o build/lib.macosx-10.9-x86_64-3.9/betterproto/casing.cpython-39-darwin.socopying build/lib.macosx-10.9-x86_64-3.9/999479a26e36c714bed7__mypyc.cpython-39-darwin.so -> copying build/lib.macosx-10.9-x86_64-3.9/betterproto/__init__.cpython-39-darwin.so -> betterprotocopying build/lib.macosx-10.9-x86_64-3.9/betterproto/_types.cpython-39-darwin.so -> betterprotocopying build/lib.macosx-10.9-x86_64-3.9/betterproto/_version.cpython-39-darwin.so -> betterprotocopying build/lib.macosx-10.9-x86_64-3.9/betterproto/casing.cpython-39-darwin.so -> betterproto

@msullivanmsullivan merged commit0af616e intopython:masterJun 8, 2021
JukkaL pushed a commit that referenced this pull requestOct 21, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Import issues with relative paths in module init

2 participants

@Gobot1234@msullivan

[8]ページ先頭

©2009-2025 Movatter.jp