Skip to content
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

Replacement for --no-setup-py in version 1.x #116

Closed
HealsCodes opened this issue Aug 30, 2023 · 7 comments
Closed

Replacement for --no-setup-py in version 1.x #116

HealsCodes opened this issue Aug 30, 2023 · 7 comments
Labels
question Further information is requested

Comments

@HealsCodes
Copy link

As the release notes for 1.0 state "some command line options have been removed" - that's all nice and well but is there any equivalent to --no-setup-py from 0.16 or are there any plans to provide it?

My company is using stubgen in one of our projects and rely on the ability to run with that flag so currently need to pin to ~= 0.16.

@sizmailov
Copy link
Owner

The setup.py is not generated, therefore no option is needed.

@sizmailov
Copy link
Owner

The argparse rejects any unknown argument. There is no way 1.0+ would run with --no-setup-py. What errors do you get?

@HealsCodes
Copy link
Author

The argparse rejects any unknown argument. There is no way 1.0+ would run with --no-setup-py. What errors do you get?

that was related to 0.16.2, which is why I deleted the comment.

In 1.0 and 1.1 I get errors about stubgen being unable to find / import modules that 0.16.2 would only throw at me if I didn't have '--no-setup-py' in the call.

Mainly errors like this:

(running pybind11-stubgen -o /tmp/build/pypi.tmp/stubs mymod.PyUI._PyUIManager)
pybind11_stubgen - [  ERROR] In mymod.PyUI._PyUIManager : Can't find/import 'Gf.Vec3d'
pybind11_stubgen - [  ERROR] In mymod.PyUI._PyUIManager : Can't find/import 'Gf.Vec2d'
pybind11_stubgen - [  ERROR] In mymod.PyUI._PyUIManager : Can't find/import 'Sdf.Path'
pybind11_stubgen - [  ERROR] In mymod.PyUI._PyUIManager : Can't find/import 'function'
pybind11_stubgen - [  ERROR] In mymod.PyUI._PyUIManager : Can't find/import 'Usd.Stage'
pybind11_stubgen - [  ERROR] In mymod.PyUI._PyUIManager : Can't find/import 'Gf.Vec2i'

The Gf and Usd types are provided by external modules installed in the same venv and referenced by the binary module I'm trying to generate stubs for.

@sizmailov
Copy link
Owner

Now pybind11-stubgen tries to infer missing imports from the annotations. Before inserting an import stubgen tries to import the corresponding name, so you see the errors above. You could either ignore the errors with --ignore-unresolved-names flag or make them available during stub generation.

@sizmailov sizmailov added the question Further information is requested label Aug 30, 2023
@HealsCodes
Copy link
Author

HealsCodes commented Aug 30, 2023

I think we can close this as the option I'm asking about is definitely NOT what caused the errors.

Adding the --ignore-unresolved-names regex for Gf/Sdf/Usd worked, even though I'm not sure how stubgen detects the names (all three of these are submodules of the Pixar-USD module and are referenced as pxr.Gf, pxr.Sdf etc. so trying to import pxr.Gf, pxr.Sdf and pxr.Usd works in this pyenv and is what the binary module does)

The one thing I'm not entirely sure why stubgen complains about is 'function', because that really is not a module used by anything in our codebase but I'm fine just ignoring it as "who knows?".

[EDIT: missing an important NOT]

@sizmailov
Copy link
Owner

The function warning probably comes from smth like:

def foo(): ...
def my_func(callback: type(foo)): ... # <--  type of `calllback` arg  is "function" 

This should be fixed in #119

Names are harvested from signatures (possibly restored from docstring) and actual values (e.g. module attributes). You could see all the names in output *.pyi files. A static analysis tool should complain about the same unknown names.

@sizmailov
Copy link
Owner

I'm going to close this one. If you find new "auto-import" feature don't do what you expect to, please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants