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

HelloWorld Tutorial: fprime-util build -j4 fails with "ModuleNotFoundError: No module named 'cgi'" #3102

Closed
ntrawny opened this issue Jan 2, 2025 · 3 comments
Labels

Comments

@ntrawny
Copy link

ntrawny commented Jan 2, 2025

F´ Version v3.5.1
Affected Component fprime-util

Problem Description

HelloWorld Tutorial: fprime-util build -j4 fails with ModuleNotFoundError: No module named 'cgi'

cgi is no longer part of the Python standard library. It was removed in Python 3.13 after being deprecated in Python 3.11. The removal was decided in PEP 594.

Workaround is to manually
pip install legacy-cgi
This is a copy of the cgi module on PyPI, no longer maintained or supported by the core Python team.

Context / Environment

Execute fprime-util version-check and share the output.

(fprime-venv) ntrawny@xxx MyProject % fprime-util version-check
Operating System: Darwin
CPU Architecture: x86_64
Platform: macOS-14.7.2-x86_64-i386-64bit-Mach-O
Python version: 3.13.1
CMake version: 3.31.3
Pip version: 24.3.1
Pip packages:
    fprime-tools==3.5.1
    fprime-gds==3.5.1
    fprime-fpp-*==2.2.1
Project submodules:
    https://github.com/nasa/fprime.git @ v3.5.1

How to Reproduce

  1. On MacOS, follow 'Hello World' Tutorial until step "Adding The Hello World Component"
  2. Execute fprime-util build -j4
(fprime-venv) ntrawny@xxx HelloWorldDeployment % fprime-util build -j4
make: *** No rule to make target `HelloWorldDeployment'.  Stop.
[CMAKE] CMake failed to detect target, attempting CMake cache refresh and retry
-- [python3] python3 found at: ~/fprime/MyProject/fprime-venv/bin/python3
-- [fpp-tools] fpp-depend found at: ~/fprime/MyProject/fprime-venv/bin/fpp-depend
-- [fpp-tools] fpp-to-xml found at: ~/fprime/MyProject/fprime-venv/bin/fpp-to-xml
-- [fpp-tools] fpp-to-cpp found at: ~/fprime/MyProject/fprime-venv/bin/fpp-to-cpp
-- [fpp-tools] fpp-to-dict found at: ~/fprime/MyProject/fprime-venv/bin/fpp-to-dict
-- [fpp-tools] fpp-locate-defs found at: ~/fprime/MyProject/fprime-venv/bin/fpp-locate-defs
-- [FPRIME] Module locations: ~/fprime/MyProject/fprime;~/fprime/MyProject
-- [FPRIME] Configuration module: ~/fprime/MyProject/fprime/config
-- [FPRIME] Installation directory: ~/fprime/MyProject/build-artifacts
-- Target build toolchain/platform: Darwin/Darwin
-- Including ~/fprime/MyProject/fprime/cmake/platform/Darwin.cmake
-- Requiring thread library
-- [sub-build] Performing sub-build: info-cache
-- [sub-build] Generating: info-cache with target/fpp_locs;target/fpp_depend
-- [sub-build] Executing: info-cache with fpp_locs
-- [sub-build] Executing: info-cache with fpp_depend
-- [sub-build] Performing sub-build: info-cache - DONE
-- [LIBRARY] Adding modules from F´ framework
-- Adding Library: config
-- Adding Library: Fw_Buffer
-- Adding Library: Fw_Cmd
-- Adding Library: Fw_Com
-- Adding Library: Fw_Dp
-- Adding Library: Fw_Log
-- Adding Library: Fw_Logger
-- Adding Library: Fw_Prm
-- Adding Library: Fw_Time
-- Adding Library: Fw_Tlm
-- Adding Library: Fw_Cfg
-- Adding Library: Fw_Comp
-- Adding Library: Fw_CompQueued
-- Adding Library: Fw_Sm
-- Adding Library: Fw_FilePacket
-- Adding Library: Fw_Obj
-- Adding Library: Fw_Port
-- Adding Library: Fw_Ports_SuccessCondition
-- Adding Library: Fw_SerializableFile
-- Adding Library: Fw_Test
-- Adding Library: Fw_Types
-- Adding Library: Svc_Cycle
-- Adding Library: Svc_Fatal
-- Adding Library: Svc_Ping
-- Adding Library: Svc_PolyIf
-- Adding Library: Svc_Sched
-- Adding Library: Svc_Seq
-- Adding Library: Svc_WatchDog
-- Adding Library: Svc_ActiveLogger
-- Adding Library: Svc_ActiveRateGroup
-- Adding Library: Svc_AssertFatalAdapter
-- Adding Library: Svc_BufferAccumulator
-- Adding Library: Svc_BufferManager
-- Adding Library: Svc_BufferLogger
-- Adding Library: Svc_BufferRepeater
-- Adding Library: Svc_ChronoTime
-- Adding Library: Svc_ComLogger
-- Adding Library: Svc_ComQueue
-- Adding Library: Svc_ComSplitter
-- Adding Library: Svc_ComStub
-- Adding Library: Svc_CmdDispatcher
-- Adding Library: Svc_CmdSequencer
-- Adding Library: Svc_CmdSplitter
-- Adding Library: Svc_Deframer
-- Adding Library: Svc_DpCatalog
-- Adding Library: Svc_DpManager
-- Adding Library: Svc_DpPorts
-- Adding Library: Svc_DpWriter
-- Adding Library: Svc_FatalHandler
-- Adding Library: Svc_FileDownlinkPorts
-- Adding Library: Svc_FileDownlink
-- Adding Library: Svc_FileManager
-- Adding Library: Svc_FileUplink
-- Adding Library: Svc_GenericHub
-- Adding Library: Svc_Framer
-- Adding Library: Svc_FramingProtocol
-- Adding Library: Svc_Health
-- Adding Library: Svc_PassiveRateGroup
-- Adding Library: Svc_PolyDb
-- Adding Library: Svc_PrmDb
-- Adding Library: Svc_RateGroupDriver
-- Adding Library: Svc_SeqDispatcher
-- Adding Library: Svc_StaticMemory
-- Adding Library: Svc_TlmChan
-- Adding Library: Svc_TlmPacketizer
-- Adding Library: Svc_SystemResources
-- Adding Library: Svc_Ports_VersionPorts
-- Adding Library: Svc_PassiveConsoleTextLogger
-- Adding Library: Svc_ActiveTextLogger
-- Adding Library: Svc_PosixTime
-- Adding Library: Svc_LinuxTimer
-- Adding Library: Svc_Version
-- Adding Library: Os_Models
-- Adding Library: Os_File_Stub
-- Adding Library: Os_Console_Stub
-- Adding Library: Os_Task_Stub
-- Adding Library: Os_Mutex_Stub
-- Adding Library: Os_Cpu_Stub
-- Adding Library: Os_Memory_Stub
-- Adding Library: Os_Queue_Stub
-- Adding Library: Os_RawTime_Stub
-- Adding Library: Os_Posix_Shared
-- Adding Library: Os_File_Posix
-- Adding Library: Os_Console_Posix
-- Adding Library: Os_Task_Posix
-- Adding Library: Os_Mutex_Posix
-- Adding Library: Os_RawTime_Posix
-- Adding Library: Os_Generic_Types
-- Adding Library: Os_Generic_PriorityQueue
-- Neither toolchain native nor platform Darwin supported for module Os_Linux
-- Adding Library: Os_Cpu_Darwin
-- Adding Library: Os_Memory_Darwin
-- Adding Library: Os
-- Adding Library: Os_Console_Common
-- Adding Library: Os_File_Common
-- Adding Library: Os_Task_Common
-- Adding Library: Os_Mutex_Common
-- Adding Library: Os_Queue_Common
-- Adding Library: Os_Cpu_Common
-- Adding Library: Os_Memory_Common
-- Adding Library: Os_RawTime_Common
-- Adding Library: Drv_Ports_DataTypes
-- Adding Library: Drv_Ports
-- Adding Library: Drv_BlockDriver
-- Adding Library: Drv_ByteStreamDriverModel
-- Adding Library: Drv_LinuxGpioDriver
-- Adding Library: Drv_LinuxUartDriver
-- Adding Library: Drv_LinuxSpiDriver
-- Adding Library: Drv_LinuxI2cDriver
-- Adding Library: Drv_StreamCrossover
-- Adding Library: Drv_Ip
-- Adding Library: Drv_TcpClient
-- Adding Library: Drv_TcpServer
-- Adding Library: Drv_Udp
-- Adding Library: CFDP_Checksum
-- Adding Library: Utils
-- Adding Library: Utils_Hash
-- Adding Library: Utils_Types
-- [LIBRARY] Adding modules from F´ framework - DONE
-- Adding Library: Components_HelloWorld
-- Adding Library: HelloWorldDeployment_Top
-- Adding Deployment: HelloWorldDeployment
-- Configuring done (43.5s)
-- Generating done (3.4s)
-- Build files have been written to: ~/fprime/MyProject/build-fprime-automatic-native
Built target refresh_cache
[  3%] Built target config
[  3%] Generating ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/arrays/array_cpp.py, ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/arrays/array_hpp.py
[  3%] Generating ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/channels/ChannelBody.py, ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/channels/ChannelHeader.py
[  4%] Built target version
[  4%] Generating ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/commands/CommandBody.py, ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/commands/CommandHeader.py
[  4%] Generating ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/component/cpp.py, ~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/component/hpp.py
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
  File "~/fprime/MyProject/fprime-venv/bin/cheetah-compile", line 2, in <module>
    from Cheetah.CheetahWrapper import _cheetah_compile
  File "~/fprime/MyProject/fprime-venv/bin/cheetah-compile", line 2, in <module>
    from Cheetah.CheetahWrapper import _cheetah_compile
  File "~/fprime/MyProject/fprime-venv/bin/cheetah-compile", line 2, in <module>
    from Cheetah.CheetahWrapper import _cheetah_compile
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/CheetahWrapper.py", line 17, in <module>
    from Cheetah.Template import Template
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/CheetahWrapper.py", line 17, in <module>
    from Cheetah.Template import Template
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/Template.py", line 24, in <module>
    import cgi  # Used by .webInput() if the template is a CGI script.
    ^^^^^^^^^^
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/CheetahWrapper.py", line 17, in <module>
    from Cheetah.Template import Template
ModuleNotFoundError: No module named 'cgi'
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/Template.py", line 24, in <module>
    import cgi  # Used by .webInput() if the template is a CGI script.
    ^^^^^^^^^^
ModuleNotFoundError: No module named 'cgi'
  File "~/fprime/MyProject/fprime-venv/bin/cheetah-compile", line 2, in <module>
    from Cheetah.CheetahWrapper import _cheetah_compile
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/Template.py", line 24, in <module>
    import cgi  # Used by .webInput() if the template is a CGI script.
    ^^^^^^^^^^
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/CheetahWrapper.py", line 17, in <module>
    from Cheetah.Template import Template
  File "~/fprime/MyProject/fprime-venv/lib/python3.13/site-packages/Cheetah/Template.py", line 24, in <module>
    import cgi  # Used by .webInput() if the template is a CGI script.
    ^^^^^^^^^^
ModuleNotFoundError: No module named 'cgi'
ModuleNotFoundError: No module named 'cgi'
make[3]: *** [~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/arrays/array_cpp.py] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/component/cpp.py] Error 1
make[3]: *** [~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/commands/CommandBody.py] Error 1
make[3]: *** [~/fprime/MyProject/fprime/Autocoders/Python/src/fprime_ac/generators/templates/channels/ChannelBody.py] Error 1
make[2]: *** [F-Prime/Autocoders/Python/src/fprime_ac/generators/templates/CMakeFiles/fprime_codegen.dir/all] Error 2
[  4%] Built target Fw_Cfg
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [HelloWorldDeployment/CMakeFiles/HelloWorldDeployment.dir/rule] Error 2
make: *** [HelloWorldDeployment] Error 2
[ERROR] CMake erred with return code 2

Expected Behavior

Successful compilation of the HelloWorld Tutorial.

Manual workaround is:
pip install legacy-cgi
followed by (now successful)
fprime-util build -j4

More permanent fix would be to either update requirements.txt or replace cgi (maybe using suggestions from here?)

@ntrawny ntrawny added the bug label Jan 2, 2025
@r-wells
Copy link

r-wells commented Jan 4, 2025

Thanks for finding + posting the workaround - saved me a lot of time

@LeStarch
Copy link
Collaborator

LeStarch commented Jan 7, 2025

@thomas-bc didn't we fix this with switching from cheetah to C3?

LeStarch added a commit to LeStarch/fprime that referenced this issue Jan 7, 2025
LeStarch added a commit that referenced this issue Jan 7, 2025
* Fixing missing python packages. Fixes: #3101, #3102

* Limiting legacy-cgi to python 3.13+

* Updating workflows for python 3.13

* Downgrading to last 3.8 setuptools package

* Reverting to 3.12 for macOs run
@thomas-bc
Copy link
Collaborator

Fixed with the above PR

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

No branches or pull requests

4 participants