Addon manager: install dependencies (#5376)

Addon Manager: Dependency Installation

The Addon Manager can now attempt to use pip directly to install
required packages as specified in either metadata.txt or
requirements.txt files provided by AddOns. The packages are installed
into FreeCAD.getUserAppDataDir()/AdditionalPythonPackages directory.
Only simplified requirements.txt data is supported: any version
information is stripped out, and only packages are supported (that is,
no pip arguments, included files, etc.). Further, packages are checked
against a list of allowed packages prior to being suggested for
installation. Addon authors should submit a PR to the FreeCAD repo
adding their requirements to the allowed list, for packages that are not
already on the list (this is a malware-prevention mechanism).
This commit is contained in:
Chris Hennes
2022-01-21 10:19:21 -06:00
committed by GitHub
parent fb84f715fa
commit d1a94de371
10 changed files with 431 additions and 128 deletions

View File

@@ -162,9 +162,15 @@ def InitApplications():
# also add these directories to the sys.path to
# not change the old behaviour. once we have moved to
# proper python modules this can eventuelly be removed.
# proper python modules this can eventually be removed.
sys.path = [ModDir] + libpaths + [ExtDir] + sys.path
# The AddonManager may install additional Python packages in
# this path:
additional_packages_path = os.path.join(FreeCAD.getUserAppDataDir(),"AdditionalPythonPackages")
if os.path.isdir(additional_packages_path):
sys.path.append(additional_packages_path)
def RunInitPy(Dir):
InstallFile = os.path.join(Dir,"Init.py")
if (os.path.exists(InstallFile)):