是什麼促使你提出這個願望清單請求?I need to install Python packages in a custom directory on my machine (e.g., C:\lib_jmp_python) using the standard Windows PYTHONUSERBASE environment variable. Currently, if I run jmputils.jpip('install', 'package_name'), my system variable is completely ignored. The jmputils.py script hardcodes the installation paths by forcing its own site.USER_BASE and overwriting the subprocess environment. This makes it impossible to route packages to a custom local folder using standard Python OS variables; everything is forced into the default JMP AppData/ProgramData directories.
您希望看到哪些改進?I would like jmputils.py to respect the system's PYTHONUSERBASE variable if it is defined by the user, and only fall back to the default JMP paths if it is not set. Specifically, in the jpip() function, a simple conditional check could be added:
if 'PYTHONUSERBASE' in os.environ:
site.USER_BASE = os.environ['PYTHONUSERBASE']
elif site.USER_BASE is None:
site.getuserbase()
The exact same logic should be applied to the create_jpip() function when generating the jpip.bat script, replacing the currently hardcoded set PYTHONUSERBASE=%APPDATA%\JMP\JMP\Python with a dynamic check.
為什麼這個想法如此重要?對於需要嚴格控制 Python 環境的使用者和 IT 管理員來說,這極具價值。它允許使用者將可能體積龐大的 Python 套件路由到特定磁碟機或自訂目錄,而不會破壞 JMP 的隔離環境。最終,它使 JMP 的 Python 整合與標準的 Python 行為保持一致,從而減少開發人員在高效管理軟體包時遇到的困難和困惑。
@guillaumebugnon - 感謝您提交願望。
@guillamebugnon - 我想轉達一位開發者關於這個願望以及即將發布的 JMP 20 版本的一些資訊:
JMP 20 版本中的 Python 現在以隔離模式運行,以確保在各種使用者環境下行為一致。這意味著嵌入式 Python 現在會忽略所有 PYTHON* 環境變數。
JMP 20 EA 1 及更高版本支援 Python venv 虛擬環境。在 JMP -> 首選項 -> Python 中,有一個面板提供建立和選擇虛擬環境的選項,這些虛擬環境可以作為「預設」站台套件環境的替代方案。 venv 必須由 JMP 建立。虛擬環境必須指向 JMP 提供的 Python 共用程式庫,而不是外部 Python 安裝的共用程式庫。建立的虛擬環境可以放置在檔案系統或共用磁碟機中的任何位置。虛擬環境的選擇是一個目錄選擇對話框,同樣,它可以位於檔案系統中的任何位置。
創建完成後,虛擬環境 (venv) 可以像任何 Python 虛擬環境一樣從終端使用。這包括從命令列啟動虛擬環境,以及直接在虛擬環境中使用 pip,而不是在 JMP 中使用 jpip。 JMP 建立虛擬環境後,外部腳本可以填入虛擬環境或使用環境。但是,只有在 JMP 正在運行的情況下才能導入 jmp包。
我建議您下載最新的 JMP EA 版本並試用一下。