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

Please make pydantic optional dependency, not required one #2777

Closed
barracuda156 opened this issue May 16, 2024 · 9 comments · Fixed by #2778
Closed

Please make pydantic optional dependency, not required one #2777

barracuda156 opened this issue May 16, 2024 · 9 comments · Fixed by #2778
Assignees
Milestone

Comments

@barracuda156
Copy link

@nicolargo Please consider making pydantic an optional dependency: forcing a dependency on Rust is undesirable for several reasons (it is a very heavy dependency to build, it is broken on some platforms and cannot be built there at all, it is questionable from security point of view, since it requires itself to build).

@RazCrimson
Copy link
Collaborator

@barracuda156

I understand that you would like to avoid using Pydantic. But currently the Webserver dependency (fastapi) would require it.

Could you please list the platform which you use and currently don't have pydantic binaries?

Btw rust being required to build rust is totally normal in the compiler world? Even gcc and clang are Self-hosting compilers.

I don't really understand your security concern. But I get that it's going to be a pain to build when no binaries are available.

@barracuda156
Copy link
Author

@RazCrimson Thank you for responding! Rust does not build on older macOS (all powerpc, some older x86), I think it does not build for powerpc on OpenBSD as well (perhaps even on FreeBSD for ppc 32-bit). I am pretty sure there are other non-mainstream platforms where Rust does not build.

P. S. Both gcc and clang can be built with other C/C++ compilers, they do not require themselves to build.

@barracuda156
Copy link
Author

@RazCrimson It will be sufficient to add a configure option to disable Pydantic and whatever needs it. I.e. nothing will change by default, but at the same time we could unbreak the package for Rustless systems.

@RazCrimson
Copy link
Collaborator

RazCrimson commented May 16, 2024

Sure, I think that should be possible as long as we don't require the webserver plugin

@barracuda156
Copy link
Author

@RazCrimson That would be awesome!

@nicolargo
Copy link
Owner

The default "pip install glances" do not install the Webserver requirements.

Pydantic should be installed only if you use "pip install glances[web]" or "pip install glances[all]".

@nicolargo
Copy link
Owner

So we have to move pydantic from requirements.txt to requirements-webui.txt ?

@RazCrimson
Copy link
Collaborator

Yea, but I think there was some pydantic import that was failing.

We'll probably have to fix that and check if everything works right.

@barracuda156
Copy link
Author

I tried to remove pydantic from requirements in the portfile, it installed, but does not run:

36-173% glances
Traceback (most recent call last):
  File "/opt/local/bin/glances", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/glances/__init__.py", line 184, in main
    start(config=core.get_config(), args=core.get_args())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/glances/__init__.py", line 94, in start
    from glances.standalone import GlancesStandalone as GlancesMode
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/glances/standalone.py", line 20, in <module>
    from glances.outputs.glances_curses import GlancesCursesStandalone
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/glances/outputs/glances_curses.py", line 18, in <module>
    from glances.events_list import glances_events
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/glances/events_list.py", line 14, in <module>
    from pydantic import RootModel
ModuleNotFoundError: No module named 'pydantic'

It looks like MacPorts does not specifically configure it in some way: https://github.com/macports/macports-ports/blob/master/sysutils/glances/Portfile
Requirement for pydantic was added in macports/macports-ports@fddf466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants