├── src
├── Manager
│ ├── Defs
│ │ ├── Opts
│ │ │ ├── Pip
│ │ │ │ ├── PyPackage.Manager.Defs.Opts.Pip.List.pas
│ │ │ │ ├── PyPackage.Manager.Defs.Opts.Pip.Uninstall.pas
│ │ │ │ └── PyPackage.Manager.Defs.Opts.Pip.Install.pas
│ │ │ ├── PyPackage.Manager.Defs.Opts.pas
│ │ │ └── Conda
│ │ │ │ ├── PyPackage.Manager.Defs.Opts.Conda.List.pas
│ │ │ │ ├── PyPackage.Manager.Defs.Opts.Conda.Uninstall.pas
│ │ │ │ ├── PyPackage.Manager.Defs.Opts.Conda.Create.pas
│ │ │ │ └── PyPackage.Manager.Defs.Opts.Conda.Install.pas
│ │ ├── PyPackage.Manager.Defs.pas
│ │ ├── PyPackage.Manager.Defs.Pip.pas
│ │ └── PyPackage.Manager.Defs.Conda.pas
│ ├── Cmd
│ │ ├── PyPackage.Manager.Cmd.pas
│ │ ├── PyPackage.Manager.Cmd.Intf.pas
│ │ ├── Pip
│ │ │ ├── PyPackage.Manager.Cmd.Pip.Uninstall.pas
│ │ │ ├── PyPackage.Manager.Cmd.Pip.pas
│ │ │ ├── PyPackage.Manager.Cmd.Pip.List.pas
│ │ │ └── PyPackage.Manager.Cmd.Pip.Install.pas
│ │ └── Conda
│ │ │ ├── PyPackage.Manager.Cmd.Conda.List.pas
│ │ │ ├── PyPackage.Manager.Cmd.Conda.pas
│ │ │ ├── PyPackage.Manager.Cmd.Conda.Uninstall.pas
│ │ │ └── PyPackage.Manager.Cmd.Conda.Install.pas
│ ├── PyPackage.Manager.Managers.pas
│ ├── PyPackage.Manager.pas
│ ├── PyPackage.Manager.ManagerKind.pas
│ ├── PyPackage.Manager.Intf.pas
│ ├── PyPackage.Manager.Conda.pas
│ └── PyPackage.Manager.Pip.pas
├── PyCore.pas
├── Model
│ └── PyPackage.Model.pas
├── PyPackage.Editors.pas
├── PyExceptions.pas
├── PyCommon.pas
├── PyModule.pas
└── PyUtils.pas
├── packages
├── P4DLightweightWrappersComponentSuite.prjmgc
├── dclP4DPyPackage.dpk
├── P4DLightweightWrappersComponentSuite.groupproj
├── P4DPyPackage.dpk
└── dclP4DPyPackage.dproj
├── boss.json
├── README.md
├── LICENSE
└── .gitignore
/src/Manager/Defs/Opts/Pip/PyPackage.Manager.Defs.Opts.Pip.List.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Embarcadero/Lightweight-Python-Wrappers/HEAD/src/Manager/Defs/Opts/Pip/PyPackage.Manager.Defs.Opts.Pip.List.pas
--------------------------------------------------------------------------------
/src/Manager/Defs/Opts/PyPackage.Manager.Defs.Opts.pas:
--------------------------------------------------------------------------------
1 | unit PyPackage.Manager.Defs.Opts;
2 |
3 | interface
4 |
5 | uses
6 | System.Classes;
7 |
8 | type
9 | TPyPackageManagerDefsOpts = class(TPersistent)
10 | end;
11 |
12 | implementation
13 |
14 | end.
15 |
--------------------------------------------------------------------------------
/packages/P4DLightweightWrappersComponentSuite.prjmgc:
--------------------------------------------------------------------------------
1 | [Settings]
2 | AutoLibSuffix=0
3 | ClearChildAppSettings=0
4 | ClearChildPackageSettings=0
5 | ClearChildVersionInfo=0
6 | NormalizeDproj=1
7 | SplitDproj=0
8 | EnableMissingPlatforms=1
9 | RemoveUnusedPlatforms=1
10 | RefreshFormType=0
11 | RemoveExcludedPackages=1
12 | RemoveDeployment=1
13 | RemoveUWP=1
14 |
15 |
--------------------------------------------------------------------------------
/boss.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Lightweight-Python-Wrappers",
3 | "description": "Lightweight Wrappers based on Python4Delphi to make it easy to import Python modules into Delphi components.",
4 | "version": "1.0.0",
5 | "homepage": "https://github.com/Embarcadero/Lightweight-Python-Wrappers",
6 | "mainsrc": "./src",
7 | "projects": [
8 | "./packages/P4DPyPackage.dproj",
9 | "./packages/dclP4DPyPackage.dproj"
10 | ],
11 | "dependencies": {
12 | "https://github.com/embarcadero/pythonenviroments": "^v0.0.1-alpha"
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Manager/Cmd/PyPackage.Manager.Cmd.pas:
--------------------------------------------------------------------------------
1 | unit PyPackage.Manager.Cmd;
2 |
3 | interface
4 |
5 | uses
6 | PyPackage.Manager.Defs;
7 |
8 | type
9 | TPyPackageManagerCmd = class(TInterfacedObject)
10 | protected
11 | Defs: TPyPackageManagerDefs;
12 | public
13 | constructor Create(const ADefs: TPyPackageManagerDefs);
14 | end;
15 |
16 | implementation
17 |
18 | { TPyPackageManagerCmd }
19 |
20 | constructor TPyPackageManagerCmd.Create(const ADefs: TPyPackageManagerDefs);
21 | begin
22 | Defs := ADefs;
23 | end;
24 |
25 | end.
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Lightweight-Python-Wrappers
2 | Lightweight Wrappers based on [Python4Delphi](https://github.com/Embarcadero/Python4Delphi) to make it easy to import Python modules into Delphi components.
3 |
4 | This is the foundation of the [Delphi Data Sciences Libraries](https://github.com/Embarcadero/P4D-Data-Sciences) and works with the [Python Enviroments](https://github.com/Embarcadero/PythonEnviroments/).
5 |
6 | This is an early access preview, but you are encouraged to try it out, file bug reports, and add features. [Read more](https://blogs.embarcadero.com/?p=145025) and catch the live stream.
7 |
--------------------------------------------------------------------------------
/packages/dclP4DPyPackage.dpk:
--------------------------------------------------------------------------------
1 | package dclP4DPyPackage;
2 |
3 | {$R *.res}
4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
5 | {$ALIGN 8}
6 | {$ASSERTIONS ON}
7 | {$BOOLEVAL OFF}
8 | {$DEBUGINFO OFF}
9 | {$EXTENDEDSYNTAX ON}
10 | {$IMPORTEDDATA ON}
11 | {$IOCHECKS ON}
12 | {$LOCALSYMBOLS OFF}
13 | {$LONGSTRINGS ON}
14 | {$OPENSTRINGS ON}
15 | {$OPTIMIZATION ON}
16 | {$OVERFLOWCHECKS OFF}
17 | {$RANGECHECKS OFF}
18 | {$REFERENCEINFO OFF}
19 | {$SAFEDIVIDE OFF}
20 | {$STACKFRAMES OFF}
21 | {$TYPEDADDRESS OFF}
22 | {$VARSTRINGCHECKS ON}
23 | {$WRITEABLECONST OFF}
24 | {$MINENUMSIZE 1}
25 | {$IMAGEBASE $400000}
26 | {$DEFINE RELEASE}
27 | {$ENDIF IMPLICITBUILDING}
28 | {$DESCRIPTION 'P4D AI&ML extension for Python packages'}
29 | {$LIBSUFFIX AUTO}
30 | {$DESIGNONLY}
31 | {$IMPLICITBUILD ON}
32 |
33 | requires
34 | rtl,
35 | designide,
36 | p4dpypackage;
37 |
38 | contains
39 | PyPackage.Editors in '..\src\PyPackage.Editors.pas';
40 |
41 | end.
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Embarcadero Technologies
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/P4DLightweightWrappersComponentSuite.groupproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {912F8EE9-E25B-41C8-83B3-569531100FDE}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Default.Personality.12
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Uncomment these types if you want even more clean repository. But be careful.
2 | # It can make harm to an existing project source. Read explanations below.
3 | #
4 | # Resource files are binaries containing manifest, project icon and version info.
5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files.
6 | #*.res
7 | #
8 | # Type library file (binary). In old Delphi versions it should be stored.
9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored.
10 | #*.tlb
11 | #
12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7.
13 | # Uncomment this if you are not using diagrams or use newer Delphi version.
14 | #*.ddp
15 | #
16 | # Visual LiveBindings file. Added in Delphi XE2.
17 | # Uncomment this if you are not using LiveBindings Designer.
18 | #*.vlb
19 | #
20 | # Deployment Manager configuration file for your project. Added in Delphi XE2.
21 | # Uncomment this if it is not mobile development and you do not use remote debug feature.
22 | #*.deployproj
23 | #
24 | # C++ object files produced when C/C++ Output file generation is configured.
25 | # Uncomment this if you are not using external objects (zlib library for example).
26 | #*.obj
27 | #
28 |
29 | # Delphi compiler-generated binaries (safe to delete)
30 | *.exe
31 | *.dll
32 | *.bpl
33 | *.bpi
34 | *.dcp
35 | *.so
36 | *.apk
37 | *.drc
38 | *.map
39 | *.dres
40 | *.rsm
41 | *.tds
42 | *.dcu
43 | *.lib
44 | *.a
45 | *.o
46 | *.ocx
47 | *.res
48 |
49 | # Delphi autogenerated files (duplicated info)
50 | *.cfg
51 | *.hpp
52 | *Resource.rc
53 |
54 | # Delphi local files (user-specific info)
55 | *.local
56 | *.identcache
57 | *.projdata
58 | *.tvsconfig
59 | *.dsk
60 | *AndroidManifest.template.xml
61 |
62 | # Delphi history and backups
63 | __history/
64 | __recovery/
65 | *.~*
66 |
67 | # Castalia statistics file (since XE7 Castalia is distributed with Delphi)
68 | *.stat
69 |
70 | # Boss dependency manager vendor folder https://github.com/HashLoad/boss
71 | modules/
72 |
73 | #Resources dir
74 | resources/
75 |
76 | #Library dir
77 | lib/
--------------------------------------------------------------------------------
/src/PyCore.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyCore' Copyright (c) 2021 *)
4 | (* *)
5 | (* Lucas Moura Belo - lmbelo *)
6 | (* lucas.belo@live.com *)
7 | (* Brazil *)
8 | (* *)
9 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
10 | (**************************************************************************)
11 | (* Functionality: PyCore layer *)
12 | (* *)
13 | (* *)
14 | (**************************************************************************)
15 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
16 | (* Everyone is allowed to use and change this code free for his own tasks *)
17 | (* and projects, as long as this header and its copyright text is intact. *)
18 | (* For changed versions of this code, which are public distributed the *)
19 | (* following additional conditions have to be fullfilled: *)
20 | (* 1) The header has to contain a comment on the change and the author of *)
21 | (* it. *)
22 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
23 | (* address or my then valid address, if this is possible to the *)
24 | (* author. *)
25 | (* The second condition has the target to maintain an up to date central *)
26 | (* version of the component. If this condition is not acceptable for *)
27 | (* confidential or legal reasons, everyone is free to derive a component *)
28 | (* or to generate a diff file to my or other original sources. *)
29 | (**************************************************************************)
30 | unit PyCore;
31 |
32 | interface
33 |
34 | type
35 | TPyModuleName = string;
36 | TPyPackageName = string;
37 | TPyPyPIPackageName = string;
38 | TPyExecCmdResultCode = integer;
39 |
40 | implementation
41 |
42 | end.
43 |
--------------------------------------------------------------------------------
/src/Manager/PyPackage.Manager.Managers.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Managers' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Manager layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Managers;
32 |
33 | interface
34 |
35 | uses
36 | System.Generics.Collections,
37 | PyPackage.Manager.ManagerKind,
38 | PyPackage.Manager.Intf;
39 |
40 | type
41 | TPyPackageManagers = class(TDictionary)
42 | end;
43 |
44 | implementation
45 |
46 | end.
47 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/PyPackage.Manager.Cmd.Intf.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Intf' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Intf;
32 |
33 | interface
34 |
35 | uses
36 | PyPackage.Manager.Defs.Opts;
37 |
38 | type
39 | IPyPackageManagerCmdIntf = interface
40 | ['{B6FADED7-BBA9-4E55-B1AD-A0C0CE535B96}']
41 | function BuildInstallCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
42 | function BuildUninstallCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
43 | function BuildListCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
44 | end;
45 |
46 | implementation
47 |
48 | end.
49 |
--------------------------------------------------------------------------------
/src/Manager/PyPackage.Manager.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Manager layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager;
32 |
33 | interface
34 |
35 | uses
36 | PyCore, PyPackage;
37 |
38 | type
39 | TPyPackageManager = class abstract(TInterfacedObject)
40 | private
41 | FPackageName: TPyPackageName;
42 | public
43 | constructor Create(const APackageName: TPyPackageName); virtual;
44 |
45 | property PackageName: TPyPackageName read FPackageName;
46 | end;
47 |
48 | implementation
49 |
50 | { TPyPackageManager }
51 |
52 | constructor TPyPackageManager.Create(const APackageName: TPyPackageName);
53 | begin
54 | FPackageName := APackageName;
55 | end;
56 |
57 | end.
58 |
--------------------------------------------------------------------------------
/src/Manager/PyPackage.Manager.ManagerKind.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.ManagerKind' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Manager layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.ManagerKind;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes, PyPackage.Manager.Defs;
37 |
38 | type
39 | TPyPackageManagerKind = (pip, conda);
40 |
41 | TPyPackageManagerKindHelper = record helper for TPyPackageManagerKind
42 | public
43 | function ToString(): string;
44 | end;
45 |
46 | implementation
47 |
48 | { TPyPackageManagerKindHelper }
49 |
50 | function TPyPackageManagerKindHelper.ToString: string;
51 | begin
52 | case Self of
53 | pip : Result := 'PIP';
54 | conda : Result := 'Conda';
55 | end;
56 | end;
57 |
58 | end.
59 |
--------------------------------------------------------------------------------
/src/Manager/Defs/Opts/Pip/PyPackage.Manager.Defs.Opts.Pip.Uninstall.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs.Opts.Pip.Uninstall' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs.Opts layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs.Opts.Pip.Uninstall;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes,
37 | PyPackage.Manager.Defs.Opts;
38 |
39 | type
40 | TPyPackageManagerDefsOptsPipUninstall = class(TPyPackageManagerDefsOpts)
41 | private
42 | FRequirement: string;
43 | FAskForConfirmation: boolean;
44 | published
45 | property Requirement: string read FRequirement write FRequirement;
46 | property AskForConfirmation: boolean read FAskForConfirmation write FAskForConfirmation default false;
47 | end;
48 |
49 | implementation
50 |
51 | end.
52 |
--------------------------------------------------------------------------------
/src/Manager/PyPackage.Manager.Intf.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Intf' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Manager layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Intf;
32 |
33 | interface
34 |
35 | uses
36 | PyTools.Cancelation,
37 | PyPackage.Manager.Defs,
38 | PyPackage.Manager.Cmd.Intf;
39 |
40 | type
41 | IPyPackageManager = interface
42 | ['{5ACA3C89-1BCF-442A-A77E-9A8B0DF4823A}']
43 | function GetDefs(): TPyPackageManagerDefs;
44 | function GetCmd(): IPyPackageManagerCmdIntf;
45 |
46 | property Defs: TPyPackageManagerDefs read GetDefs;
47 | property Cmd: IPyPackageManagerCmdIntf read GetCmd;
48 |
49 | procedure Install(const ACancelation: ICancelation);
50 | procedure Uninstall(const ACancelation: ICancelation);
51 |
52 | function IsInstalled(): boolean;
53 | end;
54 |
55 | implementation
56 |
57 | end.
58 |
--------------------------------------------------------------------------------
/src/Model/PyPackage.Model.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Model' Copyright (c) 2021 *)
4 | (* *)
5 | (* Lucas Moura Belo - lmbelo *)
6 | (* lucas.belo@live.com *)
7 | (* Brazil *)
8 | (* *)
9 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
10 | (**************************************************************************)
11 | (* Functionality: PyPackage layer *)
12 | (* *)
13 | (* *)
14 | (**************************************************************************)
15 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
16 | (* Everyone is allowed to use and change this code free for his own tasks *)
17 | (* and projects, as long as this header and its copyright text is intact. *)
18 | (* For changed versions of this code, which are public distributed the *)
19 | (* following additional conditions have to be fullfilled: *)
20 | (* 1) The header has to contain a comment on the change and the author of *)
21 | (* it. *)
22 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
23 | (* address or my then valid address, if this is possible to the *)
24 | (* author. *)
25 | (* The second condition has the target to maintain an up to date central *)
26 | (* version of the component. If this condition is not acceptable for *)
27 | (* confidential or legal reasons, everyone is free to derive a component *)
28 | (* or to generate a diff file to my or other original sources. *)
29 | (**************************************************************************)
30 | unit PyPackage.Model;
31 |
32 | interface
33 |
34 | uses
35 | PyCore,
36 | PyPackage.Manager.Managers;
37 |
38 | type
39 | TPyPackageModel = class
40 | private
41 | FPackageName: TPyPackageName;
42 | FPackageManagers: TPyPackageManagers;
43 | public
44 | constructor Create();
45 | destructor Destroy(); override;
46 |
47 | property PackageName: TPyPackageName read FPackageName write FPackageName;
48 | property PackageManagers: TPyPackageManagers read FPackageManagers;
49 | end;
50 |
51 | implementation
52 |
53 | { TPyPackageModel }
54 |
55 | constructor TPyPackageModel.Create;
56 | begin
57 | inherited;
58 | FPackageManagers := TPyPackageManagers.Create()
59 | end;
60 |
61 | destructor TPyPackageModel.Destroy;
62 | begin
63 | FPackageManagers.Free();
64 | inherited;
65 | end;
66 |
67 | end.
68 |
--------------------------------------------------------------------------------
/src/Manager/Defs/PyPackage.Manager.Defs.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes, PyCore;
37 |
38 | type
39 | TPyPackageManagerDefs = class(TPersistent)
40 | private
41 | FPackageName: TPyPackageName;
42 | FPackageVersion: string;
43 | public
44 | ///
45 | /// The package name on the repository
46 | ///
47 | constructor Create(const APackageName: TPyPackageName); virtual;
48 | published
49 | //Package name may differ between PIP and CONDA
50 | property PackageName: TPyPackageName read FPackageName;
51 | property PackageVersion: string read FPackageVersion write FPackageVersion;
52 | end;
53 |
54 | implementation
55 |
56 | { TPyPackageManagerDefs }
57 |
58 | constructor TPyPackageManagerDefs.Create(const APackageName: TPyPackageName);
59 | begin
60 | inherited Create();
61 | FPackageName := APackageName;
62 | end;
63 |
64 | end.
65 |
--------------------------------------------------------------------------------
/src/PyPackage.Editors.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'RegPyPackage' Copyright (c) 2021 *)
4 | (* *)
5 | (* Lucas Moura Belo - lmbelo *)
6 | (* lucas.belo@live.com *)
7 | (* Brazil *)
8 | (* *)
9 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
10 | (**************************************************************************)
11 | (* Functionality: PyPackage Components Editors *)
12 | (* *)
13 | (* *)
14 | (**************************************************************************)
15 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
16 | (* Everyone is allowed to use and change this code free for his own tasks *)
17 | (* and projects, as long as this header and its copyright text is intact. *)
18 | (* For changed versions of this code, which are public distributed the *)
19 | (* following additional conditions have to be fullfilled: *)
20 | (* 1) The header has to contain a comment on the change and the author of *)
21 | (* it. *)
22 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
23 | (* address or my then valid address, if this is possible to the *)
24 | (* author. *)
25 | (* The second condition has the target to maintain an up to date central *)
26 | (* version of the component. If this condition is not acceptable for *)
27 | (* confidential or legal reasons, everyone is free to derive a component *)
28 | (* or to generate a diff file to my or other original sources. *)
29 | (**************************************************************************)
30 | unit PyPackage.Editors;
31 |
32 | interface
33 |
34 | procedure Register();
35 |
36 | implementation
37 |
38 | uses
39 | System.SysUtils, Classes, DesignIntf, DesignEditors, PyPackage,
40 | PyPackage.Manager.Defs;
41 |
42 | type
43 | TPyPIPPackageVersionProperty = class (TStringProperty)
44 | public
45 | function GetValue: string; override;
46 | end;
47 |
48 | TPyPackageManagerDefsProperty = class (TClassProperty)
49 | public
50 | function GetValue: string; override;
51 | end;
52 |
53 | procedure Register();
54 | begin
55 | RegisterPropertyEditor(TypeInfo(string), TPyPackageManagerDefs, 'PackageVersion', TPyPIPPackageVersionProperty);
56 | RegisterPropertyEditor(TypeInfo(TPyPackageManagerDefs), TPyPackageManagerDefs, '', TPyPackageManagerDefsProperty);
57 | end;
58 |
59 | { TPyPIPPackageVersionProperty }
60 |
61 | function TPyPIPPackageVersionProperty.GetValue: string;
62 | begin
63 | Result := inherited;
64 | if Result.IsEmpty() then begin
65 | Result := 'latest';
66 | end;
67 | end;
68 |
69 | { TPyPackageManagerDefsProperty }
70 |
71 | function TPyPackageManagerDefsProperty.GetValue: string;
72 | begin
73 | Result := inherited;
74 | end;
75 |
76 | end.
77 |
--------------------------------------------------------------------------------
/src/PyExceptions.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyExceptions' Copyright (c) 2021 *)
4 | (* *)
5 | (* Lucas Moura Belo - lmbelo *)
6 | (* lucas.belo@live.com *)
7 | (* Brazil *)
8 | (* *)
9 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
10 | (**************************************************************************)
11 | (* Functionality: PyExceptions layer *)
12 | (* *)
13 | (* *)
14 | (**************************************************************************)
15 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
16 | (* Everyone is allowed to use and change this code free for his own tasks *)
17 | (* and projects, as long as this header and its copyright text is intact. *)
18 | (* For changed versions of this code, which are public distributed the *)
19 | (* following additional conditions have to be fullfilled: *)
20 | (* 1) The header has to contain a comment on the change and the author of *)
21 | (* it. *)
22 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
23 | (* address or my then valid address, if this is possible to the *)
24 | (* author. *)
25 | (* The second condition has the target to maintain an up to date central *)
26 | (* version of the component. If this condition is not acceptable for *)
27 | (* confidential or legal reasons, everyone is free to derive a component *)
28 | (* or to generate a diff file to my or other original sources. *)
29 | (**************************************************************************)
30 | unit PyExceptions;
31 |
32 | interface
33 |
34 | uses
35 | System.SysUtils,
36 | PyTools.Exception;
37 |
38 | type
39 | EPyCommonException = class(Exception);
40 |
41 | EModuleNotReady = class(EPyCommonException);
42 |
43 | EManagerUnavailable = class(EPyCommonException);
44 |
45 | EPyPackageNotInstalled = class(EPyCommonException);
46 |
47 | EPyModuleInstallError = class(EPyCommonException);
48 |
49 | EPyModuleUninstallError = class(EPyCommonException);
50 |
51 | EPyParentModuleCircularReference = class(EPyCommonException);
52 |
53 | EPyModuleNotImported = class(EPyCommonException);
54 |
55 | EPySubModuleNotFound = class(EPyCommonException);
56 |
57 | EPyVarException = class(EPyCommonException);
58 |
59 | EPyVarIsNotPython = class(EPyVarException);
60 |
61 | EPipExecCmdFailed = class(EExecCmdFailed);
62 |
63 | ECondaExecCmdFailed = class(EExecCmdFailed);
64 |
65 | resourcestring
66 | ErrPackageNotInstalled = 'Package %s not installed.';
67 | ErrModuleNotImported = 'Module not imported.';
68 | ErrSubModuleNotFound = 'Submodule not found.';
69 | ErrCircularRefNotAllowed = 'Circular reference not allowed.';
70 | ErrVarIsNotPython = 'Variant is not a Python variant.';
71 |
72 | implementation
73 |
74 | end.
75 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/Pip/PyPackage.Manager.Cmd.Pip.Uninstall.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Pip.Uninstall' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Pip.Uninstall;
32 |
33 | interface
34 |
35 | uses
36 | System.SysUtils,
37 | PyPackage.Manager.Defs.Opts.Pip.Uninstall;
38 |
39 | type
40 | TPyPackageManagerCmdPipUninstall = class
41 | private
42 | FOpts: TPyPackageManagerDefsOptsPipUninstall;
43 | public
44 | constructor Create(const ADefs: TPyPackageManagerDefsOptsPipUninstall);
45 |
46 | function MakeUninstallRequirementCmd: TArray; inline;
47 | function MakeUninstallConfirmationFlagCmd: TArray; inline;
48 | end;
49 |
50 | implementation
51 |
52 | constructor TPyPackageManagerCmdPipUninstall.Create(
53 | const ADefs: TPyPackageManagerDefsOptsPipUninstall);
54 | begin
55 | FOpts := ADefs;
56 | end;
57 |
58 | function TPyPackageManagerCmdPipUninstall.MakeUninstallRequirementCmd: TArray;
59 | begin
60 | if not FOpts.Requirement.IsEmpty() then
61 | Result := TArray.Create('-r', FOpts.Requirement);
62 | end;
63 |
64 | function TPyPackageManagerCmdPipUninstall.MakeUninstallConfirmationFlagCmd: TArray;
65 | begin
66 | if not FOpts.AskForConfirmation then
67 | Result := TArray.Create('-y');
68 | end;
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/packages/P4DPyPackage.dpk:
--------------------------------------------------------------------------------
1 | package P4DPyPackage;
2 |
3 | {$R *.res}
4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
5 | {$ALIGN 8}
6 | {$ASSERTIONS ON}
7 | {$BOOLEVAL OFF}
8 | {$DEBUGINFO OFF}
9 | {$EXTENDEDSYNTAX ON}
10 | {$IMPORTEDDATA ON}
11 | {$IOCHECKS ON}
12 | {$LOCALSYMBOLS OFF}
13 | {$LONGSTRINGS ON}
14 | {$OPENSTRINGS ON}
15 | {$OPTIMIZATION ON}
16 | {$OVERFLOWCHECKS OFF}
17 | {$RANGECHECKS OFF}
18 | {$REFERENCEINFO OFF}
19 | {$SAFEDIVIDE OFF}
20 | {$STACKFRAMES OFF}
21 | {$TYPEDADDRESS OFF}
22 | {$VARSTRINGCHECKS ON}
23 | {$WRITEABLECONST OFF}
24 | {$MINENUMSIZE 1}
25 | {$IMAGEBASE $400000}
26 | {$DEFINE RELEASE}
27 | {$ENDIF IMPLICITBUILDING}
28 | {$LIBSUFFIX AUTO}
29 | {$RUNONLY}
30 | {$IMPLICITBUILD ON}
31 |
32 | requires
33 | rtl,
34 | Python,
35 | p4denvironment;
36 |
37 | contains
38 | PyCommon in '..\src\PyCommon.pas',
39 | PyModule in '..\src\PyModule.pas',
40 | PyPackage in '..\src\PyPackage.pas',
41 | PyExceptions in '..\src\PyExceptions.pas',
42 | PyCore in '..\src\PyCore.pas',
43 | PyUtils in '..\src\PyUtils.pas',
44 | PyPackage.Manager.Pip in '..\src\Manager\PyPackage.Manager.Pip.pas',
45 | PyPackage.Manager.Conda in '..\src\Manager\PyPackage.Manager.Conda.pas',
46 | PyPackage.Manager.Defs.Conda in '..\src\Manager\Defs\PyPackage.Manager.Defs.Conda.pas',
47 | PyPackage.Manager.Defs.Pip in '..\src\Manager\Defs\PyPackage.Manager.Defs.Pip.pas',
48 | PyPackage.Manager.Defs in '..\src\Manager\Defs\PyPackage.Manager.Defs.pas',
49 | PyPackage.Manager.Cmd.Intf in '..\src\Manager\Cmd\PyPackage.Manager.Cmd.Intf.pas',
50 | PyPackage.Manager.ManagerKind in '..\src\Manager\PyPackage.Manager.ManagerKind.pas',
51 | PyPackage.Manager.Intf in '..\src\Manager\PyPackage.Manager.Intf.pas',
52 | PyPackage.Manager.Managers in '..\src\Manager\PyPackage.Manager.Managers.pas',
53 | PyPackage.Manager in '..\src\Manager\PyPackage.Manager.pas',
54 | PyPackage.Model in '..\src\Model\PyPackage.Model.pas',
55 | PyPackage.Manager.Cmd.Conda.List in '..\src\Manager\Cmd\Conda\PyPackage.Manager.Cmd.Conda.List.pas',
56 | PyPackage.Manager.Cmd.Conda.Uninstall in '..\src\Manager\Cmd\Conda\PyPackage.Manager.Cmd.Conda.Uninstall.pas',
57 | PyPackage.Manager.Cmd.Conda.Install in '..\src\Manager\Cmd\Conda\PyPackage.Manager.Cmd.Conda.Install.pas',
58 | PyPackage.Manager.Defs.Opts in '..\src\Manager\Defs\Opts\PyPackage.Manager.Defs.Opts.pas',
59 | PyPackage.Manager.Defs.Opts.Pip.Install in '..\src\Manager\Defs\Opts\Pip\PyPackage.Manager.Defs.Opts.Pip.Install.pas',
60 | PyPackage.Manager.Defs.Opts.Pip.Uninstall in '..\src\Manager\Defs\Opts\Pip\PyPackage.Manager.Defs.Opts.Pip.Uninstall.pas',
61 | PyPackage.Manager.Defs.Opts.Conda.Create in '..\src\Manager\Defs\Opts\Conda\PyPackage.Manager.Defs.Opts.Conda.Create.pas',
62 | PyPackage.Manager.Defs.Opts.Conda.Install in '..\src\Manager\Defs\Opts\Conda\PyPackage.Manager.Defs.Opts.Conda.Install.pas',
63 | PyPackage.Manager.Defs.Opts.Conda.List in '..\src\Manager\Defs\Opts\Conda\PyPackage.Manager.Defs.Opts.Conda.List.pas',
64 | PyPackage.Manager.Defs.Opts.Conda.Uninstall in '..\src\Manager\Defs\Opts\Conda\PyPackage.Manager.Defs.Opts.Conda.Uninstall.pas',
65 | PyPackage.Manager.Cmd.Pip.Install in '..\src\Manager\Cmd\Pip\PyPackage.Manager.Cmd.Pip.Install.pas',
66 | PyPackage.Manager.Cmd.Pip.Uninstall in '..\src\Manager\Cmd\Pip\PyPackage.Manager.Cmd.Pip.Uninstall.pas',
67 | PyPackage.Manager.Cmd.Pip in '..\src\Manager\Cmd\Pip\PyPackage.Manager.Cmd.Pip.pas',
68 | PyPackage.Manager.Cmd.Conda in '..\src\Manager\Cmd\Conda\PyPackage.Manager.Cmd.Conda.pas',
69 | PyPackage.Manager.Cmd in '..\src\Manager\Cmd\PyPackage.Manager.Cmd.pas',
70 | PyPackage.Manager.Cmd.Pip.List in '..\src\Manager\Cmd\Pip\PyPackage.Manager.Cmd.Pip.List.pas',
71 | PyPackage.Manager.Defs.Opts.Pip.List in '..\src\Manager\Defs\Opts\Pip\PyPackage.Manager.Defs.Opts.Pip.List.pas';
72 |
73 | end.
74 |
--------------------------------------------------------------------------------
/src/Manager/Defs/PyPackage.Manager.Defs.Pip.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs.Pip' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs.Pip;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes,
37 | PyCore,
38 | PyPackage.Manager.Defs,
39 | PyPackage.Manager.Defs.Opts.Pip.Install,
40 | PyPackage.Manager.Defs.Opts.Pip.Uninstall;
41 |
42 | type
43 | TPyPackageManagerDefsPip = class(TPyPackageManagerDefs)
44 | private
45 | FInstallOptions: TPyPackageManagerDefsOptsPipInstall;
46 | FUninstallOptions: TPyPackageManagerDefsOptsPipUninstall;
47 | procedure SetInstallOptions(const AOpts: TPyPackageManagerDefsOptsPipInstall);
48 | procedure SetUninstallOptions(const AOpts: TPyPackageManagerDefsOptsPipUninstall);
49 | public
50 | constructor Create(const APackageName: TPyPackageName); override;
51 | destructor Destroy(); override;
52 | published
53 | property InstallOptions: TPyPackageManagerDefsOptsPipInstall read FInstallOptions write SetInstallOptions;
54 | property UninstallOptions: TPyPackageManagerDefsOptsPipUninstall read FUninstallOptions write SetUninstallOptions;
55 | end;
56 |
57 | implementation
58 |
59 | { TPyPackageManagerDefsPip }
60 |
61 | constructor TPyPackageManagerDefsPip.Create(const APackageName: TPyPackageName);
62 | begin
63 | inherited;
64 | FInstallOptions := TPyPackageManagerDefsOptsPipInstall.Create();
65 | FUninstallOptions := TPyPackageManagerDefsOptsPipUninstall.Create();
66 | end;
67 |
68 | destructor TPyPackageManagerDefsPip.Destroy;
69 | begin
70 | FUninstallOptions.Free();
71 | FInstallOptions.Free();
72 | inherited;
73 | end;
74 |
75 | procedure TPyPackageManagerDefsPip.SetInstallOptions(
76 | const AOpts: TPyPackageManagerDefsOptsPipInstall);
77 | begin
78 | FInstallOptions.Assign(AOpts);
79 | end;
80 |
81 | procedure TPyPackageManagerDefsPip.SetUninstallOptions(
82 | const AOpts: TPyPackageManagerDefsOptsPipUninstall);
83 | begin
84 | FUninstallOptions.Assign(AOpts);
85 | end;
86 |
87 | end.
88 |
--------------------------------------------------------------------------------
/src/Manager/Defs/PyPackage.Manager.Defs.Conda.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs.Conda' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs.Conda;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes,
37 | PyCore,
38 | PyPackage.Manager.Defs,
39 | PyPackage.Manager.Defs.Opts.Conda.Install,
40 | PyPackage.Manager.Defs.Opts.Conda.Uninstall;
41 |
42 | type
43 | TPyPackageManagerDefsConda = class(TPyPackageManagerDefs)
44 | private
45 | FInstallOptions: TPyPackageManagerDefsOptsCondaInstall;
46 | FUninstallOptions: TPyPackageManagerDefsOptsCondaUninstall;
47 | procedure SetInstallOptions(
48 | const AOpts: TPyPackageManagerDefsOptsCondaInstall);
49 | procedure SetUninstallOptions(
50 | const AOpts: TPyPackageManagerDefsOptsCondaUninstall);
51 | public
52 | constructor Create(const APackageName: TPyPackageName); override;
53 | destructor Destroy(); override;
54 | published
55 | property InstallOptions: TPyPackageManagerDefsOptsCondaInstall read FInstallOptions write SetInstallOptions;
56 | property UninstallOptions: TPyPackageManagerDefsOptsCondaUninstall read FUninstallOptions write SetUninstallOptions;
57 | end;
58 |
59 | implementation
60 |
61 | { TPyPackageManagerDefsConda }
62 |
63 | constructor TPyPackageManagerDefsConda.Create(
64 | const APackageName: TPyPackageName);
65 | begin
66 | inherited;
67 | FInstallOptions := TPyPackageManagerDefsOptsCondaInstall.Create();
68 | FUninstallOptions := TPyPackageManagerDefsOptsCondaUninstall.Create();
69 | end;
70 |
71 | destructor TPyPackageManagerDefsConda.Destroy;
72 | begin
73 | FUninstallOptions.Free();
74 | FInstallOptions.Free();
75 | inherited;
76 | end;
77 |
78 | procedure TPyPackageManagerDefsConda.SetInstallOptions(
79 | const AOpts: TPyPackageManagerDefsOptsCondaInstall);
80 | begin
81 | FInstallOptions.Assign(AOpts);
82 | end;
83 |
84 | procedure TPyPackageManagerDefsConda.SetUninstallOptions(
85 | const AOpts: TPyPackageManagerDefsOptsCondaUninstall);
86 | begin
87 | FUninstallOptions.Assign(AOpts);
88 | end;
89 |
90 | end.
91 |
--------------------------------------------------------------------------------
/src/PyCommon.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyCommon' Copyright (c) 2021 *)
4 | (* *)
5 | (* Lucas Moura Belo - lmbelo *)
6 | (* lucas.belo@live.com *)
7 | (* Brazil *)
8 | (* *)
9 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
10 | (**************************************************************************)
11 | (* Functionality: PyCommon layer *)
12 | (* *)
13 | (* *)
14 | (**************************************************************************)
15 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
16 | (* Everyone is allowed to use and change this code free for his own tasks *)
17 | (* and projects, as long as this header and its copyright text is intact. *)
18 | (* For changed versions of this code, which are public distributed the *)
19 | (* following additional conditions have to be fullfilled: *)
20 | (* 1) The header has to contain a comment on the change and the author of *)
21 | (* it. *)
22 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
23 | (* address or my then valid address, if this is possible to the *)
24 | (* author. *)
25 | (* The second condition has the target to maintain an up to date central *)
26 | (* version of the component. If this condition is not acceptable for *)
27 | (* confidential or legal reasons, everyone is free to derive a component *)
28 | (* or to generate a diff file to my or other original sources. *)
29 | (**************************************************************************)
30 | unit PyCommon;
31 |
32 | interface
33 |
34 | uses
35 | System.Classes,
36 | PyEnvironment,
37 | PythonEngine;
38 |
39 | type
40 | //P4D AI&ML extension
41 | TPyCommon = class(TComponent)
42 | private
43 | FPythonEngine: TPythonEngine;
44 | FPyEnvironment: TPyEnvironment;
45 | protected
46 | procedure Notification(AComponent: TComponent; AOperation: TOperation); override;
47 | procedure SetPyEnvironment(const APyEnvironment: TPyEnvironment); virtual;
48 | procedure SetPythonEngine(const APythonEngine: TPythonEngine); virtual;
49 | function IsReady(): boolean; virtual;
50 | public
51 | destructor Destroy(); override;
52 |
53 | property PyEnvironment: TPyEnvironment read FPyEnvironment write SetPyEnvironment;
54 | property PythonEngine: TPythonEngine read FPythonEngine write SetPythonEngine;
55 | end;
56 |
57 | //P4D AI&ML module extension
58 | TPyCommonCustomModule = class(TPyCommon)
59 | private
60 | FPyModuleRef: PPyObject;
61 | protected
62 | //https://docs.python.org/3/c-api/import.html?highlight=importmodule#c.PyImport_ImportModule
63 | procedure ImportModule(const AModuleName: string); overload;
64 | //https://docs.python.org/3/c-api/import.html?highlight=importmodule#c.PyImport_ImportModule
65 | procedure ImportModule(const AModuleName, ASubModuleName: string); overload;
66 | protected
67 | property PyModuleRef: PPyObject read FPyModuleRef;
68 | end;
69 |
70 | implementation
71 |
72 | { TPyCommon }
73 |
74 | destructor TPyCommon.Destroy;
75 | begin
76 | SetPyEnvironment(nil);
77 | SetPythonEngine(nil);
78 | inherited;
79 | end;
80 |
81 | function TPyCommon.IsReady: boolean;
82 | begin
83 | Result := Assigned(FPythonEngine)
84 | and FPythonEngine.Initialized;
85 | end;
86 |
87 | procedure TPyCommon.Notification(AComponent: TComponent;
88 | AOperation: TOperation);
89 | begin
90 | inherited;
91 | if (AOperation = opRemove) then begin
92 | if (AComponent = FPythonEngine) then
93 | FPythonEngine := nil
94 | else if (AComponent = FPyEnvironment) then
95 | FPyEnvironment := nil;
96 | end;
97 | end;
98 |
99 | procedure TPyCommon.SetPyEnvironment(const APyEnvironment: TPyEnvironment);
100 | begin
101 | if (APyEnvironment <> FPyEnvironment) then begin
102 | if Assigned(FPyEnvironment) then begin
103 | FPyEnvironment.RemoveFreeNotification(Self);
104 | end;
105 | FPyEnvironment := APyEnvironment;
106 | if Assigned(FPyEnvironment) then begin
107 | FPyEnvironment.FreeNotification(Self);
108 | if (csDesigning in ComponentState) then
109 | if Assigned(FPyEnvironment.PythonEngine) then
110 | SetPythonEngine(FPyEnvironment.PythonEngine);
111 | end;
112 | end;
113 | end;
114 |
115 | procedure TPyCommon.SetPythonEngine(const APythonEngine: TPythonEngine);
116 | begin
117 | if (APythonEngine <> FPythonEngine) then begin
118 | if Assigned(FPythonEngine) then
119 | FPythonEngine.RemoveFreeNotification(Self);
120 | FPythonEngine := APythonEngine;
121 | if Assigned(FPythonEngine) then
122 | FPythonEngine.FreeNotification(Self);
123 | end;
124 | end;
125 |
126 | { TPyCommonCustomModule }
127 |
128 | procedure TPyCommonCustomModule.ImportModule(const AModuleName,
129 | ASubModuleName: string);
130 | begin
131 | FPyModuleRef := PythonEngine.PyImport_ImportModule(PAnsiChar(AnsiString(
132 | AModuleName
133 | + '.'
134 | + ASubModuleName)));
135 | end;
136 |
137 | procedure TPyCommonCustomModule.ImportModule(const AModuleName: string);
138 | begin
139 | FPyModuleRef := PythonEngine.PyImport_ImportModule(PAnsiChar(AnsiString(AModuleName)));
140 | end;
141 |
142 | end.
143 |
--------------------------------------------------------------------------------
/src/PyModule.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyModule' Copyright (c) 2021 *)
4 | (* *)
5 | (* Lucas Moura Belo - lmbelo *)
6 | (* lucas.belo@live.com *)
7 | (* Brazil *)
8 | (* *)
9 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
10 | (**************************************************************************)
11 | (* Functionality: PyModule layer *)
12 | (* *)
13 | (* *)
14 | (**************************************************************************)
15 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
16 | (* Everyone is allowed to use and change this code free for his own tasks *)
17 | (* and projects, as long as this header and its copyright text is intact. *)
18 | (* For changed versions of this code, which are public distributed the *)
19 | (* following additional conditions have to be fullfilled: *)
20 | (* 1) The header has to contain a comment on the change and the author of *)
21 | (* it. *)
22 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
23 | (* address or my then valid address, if this is possible to the *)
24 | (* author. *)
25 | (* The second condition has the target to maintain an up to date central *)
26 | (* version of the component. If this condition is not acceptable for *)
27 | (* confidential or legal reasons, everyone is free to derive a component *)
28 | (* or to generate a diff file to my or other original sources. *)
29 | (**************************************************************************)
30 | unit PyModule;
31 |
32 | interface
33 |
34 | uses
35 | System.Classes,
36 | System.Generics.Collections,
37 | System.SysUtils,
38 | System.Rtti,
39 | PythonEngine,
40 | PyCommon,
41 | PyCore,
42 | PyEnvironment;
43 |
44 | type
45 | TPyModuleBase = class(TPyCommonCustomModule)
46 | private
47 | FAutoImport: boolean;
48 | FBeforeImport: TNotifyEvent;
49 | FAfterImport: TNotifyEvent;
50 | protected
51 | //Get methods
52 | function GetPyModuleName(): string; virtual; abstract;
53 | function GetPyParent(): TPyModuleBase; virtual;
54 | //Internal routines
55 | procedure Loaded; override;
56 | //Desing-time actions
57 | procedure DoAutoLoad(); virtual;
58 | //Module routines
59 | function CanImport(): boolean;
60 | procedure ImportModule(); reintroduce; virtual;
61 | procedure CheckImported();
62 | public
63 | constructor Create(AOwner: TComponent); override;
64 | destructor Destroy(); override;
65 | //Module import routines
66 | function IsImported(): boolean;
67 | procedure Import();
68 | //Helper methods
69 | function AsVariant(): variant;
70 | public
71 | property PyParent: TPyModuleBase read GetPyParent;
72 | published
73 | property PyModuleName: string read GetPyModuleName;
74 | property AutoImport: boolean read FAutoImport write FAutoImport default true;
75 | //Events
76 | property BeforeImport: TNotifyEvent read FBeforeImport write FBeforeImport;
77 | property AfterImport: TNotifyEvent read FAfterImport write FAfterImport;
78 | end;
79 |
80 | TPyModule = class(TPyModuleBase)
81 | end;
82 |
83 | implementation
84 |
85 | uses
86 | PyExceptions, VarPyth;
87 |
88 | { TPyModuleBase }
89 |
90 | procedure TPyModuleBase.CheckImported;
91 | begin
92 | if not IsImported() then
93 | raise EPyModuleNotImported.Create(ErrModuleNotImported);
94 | end;
95 |
96 | constructor TPyModuleBase.Create(AOwner: TComponent);
97 | begin
98 | inherited;
99 | FAutoImport := true;
100 | end;
101 |
102 | procedure TPyModuleBase.DoAutoLoad;
103 | begin
104 | if not (csDesigning in ComponentState) and FAutoImport and CanImport() then
105 | Import();
106 | end;
107 |
108 | destructor TPyModuleBase.Destroy;
109 | begin
110 | inherited;
111 | end;
112 |
113 | function TPyModuleBase.GetPyParent: TPyModuleBase;
114 | begin
115 | Result := nil;
116 | end;
117 |
118 | function TPyModuleBase.AsVariant: variant;
119 | begin
120 | CheckImported();
121 | Result := VarPythonCreate(PyModuleRef);
122 | end;
123 |
124 | function TPyModuleBase.CanImport: boolean;
125 | begin
126 | Result := not (csDesigning in ComponentState)
127 | and Assigned(PythonEngine)
128 | and PythonEngine.Initialized
129 | and not IsImported();
130 | end;
131 |
132 | procedure TPyModuleBase.Import;
133 | begin
134 | ImportModule();
135 | end;
136 |
137 | function TPyModuleBase.IsImported: boolean;
138 | begin
139 | Result := Assigned(PyModuleRef);
140 | end;
141 |
142 | procedure TPyModuleBase.ImportModule;
143 | var
144 | LImport: string;
145 | LPyParent: TPyModuleBase;
146 | begin
147 | if Assigned(FBeforeImport) then
148 | FBeforeImport(Self);
149 |
150 | LImport := PyModuleName;
151 | LPyParent := PyParent;
152 | while Assigned(LPyParent) do begin
153 | LImport := LPyParent.PyModuleName + '.' + LImport;
154 | LPyParent := LPyParent.PyParent;
155 | end;
156 | inherited ImportModule(LImport);
157 |
158 | if Assigned(FAfterImport) then
159 | FAfterImport(Self);
160 | end;
161 |
162 | procedure TPyModuleBase.Loaded;
163 | begin
164 | inherited;
165 | if not Assigned(PyEnvironment) then
166 | DoAutoLoad();
167 | end;
168 |
169 | end.
170 |
--------------------------------------------------------------------------------
/src/Manager/PyPackage.Manager.Conda.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Conda' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Manager layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Conda;
32 |
33 | interface
34 |
35 | uses
36 | PyTools.Cancelation,
37 | PyCore,
38 | PyPackage.Manager,
39 | PyPackage.Manager.Intf,
40 | PyPackage.Manager.Defs,
41 | PyPackage.Manager.Cmd.Intf,
42 | PyPackage.Manager.Defs.Opts.Conda.List;
43 |
44 | type
45 | TPyPackageManagerConda = class(TPyPackageManager, IPyPackageManager)
46 | private
47 | FDefs: TPyPackageManagerDefs;
48 | FCmd: IPyPackageManagerCmdIntf;
49 | //Builders
50 | function BuildOptsList(): TPyPackageManagerDefsOptsCondaList;
51 | //IPyPackageManager implementation
52 | function GetDefs(): TPyPackageManagerDefs;
53 | function GetCmd(): IPyPackageManagerCmdIntf;
54 |
55 | procedure Install(const ACancelation: ICancelation);
56 | procedure Uninstall(const ACancelation: ICancelation);
57 |
58 | function IsInstalled(): boolean;
59 | public
60 | constructor Create(const APackageName: TPyPackageName); override;
61 | destructor Destroy; override;
62 | end;
63 |
64 | implementation
65 |
66 | uses
67 | System.Variants, System.SysUtils,
68 | PythonEngine, VarPyth,
69 | PyUtils,
70 | PyExceptions,
71 | PyPackage.Manager.Defs.Conda,
72 | PyPackage.Manager.Cmd.Conda;
73 |
74 | { TPyPackageManagerConda }
75 |
76 | function TPyPackageManagerConda.BuildOptsList: TPyPackageManagerDefsOptsCondaList;
77 | begin
78 | Result := TPyPackageManagerDefsOptsCondaList.Create();
79 | try
80 | Result.Name := (FDefs as TPyPackageManagerDefsConda).InstallOptions.Name;
81 | Result.Prefix := (FDefs as TPyPackageManagerDefsConda).InstallOptions.Prefix;
82 | except
83 | on E: Exception do begin
84 | Result.Free();
85 | raise;
86 | end;
87 | end;
88 | end;
89 |
90 | constructor TPyPackageManagerConda.Create(const APackageName: TPyPackageName);
91 | begin
92 | inherited;
93 | FDefs := TPyPackageManagerDefsConda.Create(APackageName);
94 | FCmd := TPyPackageManagerCmdConda.Create(FDefs);
95 | end;
96 |
97 | destructor TPyPackageManagerConda.Destroy;
98 | begin
99 | inherited;
100 | FCmd := nil;
101 | FDefs.Free();
102 | end;
103 |
104 | function TPyPackageManagerConda.GetCmd: IPyPackageManagerCmdIntf;
105 | begin
106 | Result := FCmd;
107 | end;
108 |
109 | function TPyPackageManagerConda.GetDefs: TPyPackageManagerDefs;
110 | begin
111 | Result := FDefs;
112 | end;
113 |
114 | function TPyPackageManagerConda.IsInstalled(): boolean;
115 | var
116 | LIn: TArray;
117 | LConda: variant;
118 | LResult: Integer;
119 | begin
120 | //Will be changed to run on a separeted process
121 | var LOpts := BuildOptsList();
122 | try
123 | LIn := FCmd.BuildListCmd(LOpts);
124 | LConda := Import('conda.cli');
125 | LResult := LConda.main('conda', TPyEx.List(LIn), FDefs.PackageName);
126 | finally
127 | LOpts.Free();
128 | end;
129 | Result := (LResult = 0);
130 | end;
131 |
132 | procedure TPyPackageManagerConda.Install(const ACancelation: ICancelation);
133 | var
134 | LIn: TArray;
135 | LConda: variant;
136 | LResult: Integer;
137 | begin
138 | //Will be changed to run on a separeted process
139 | LIn := FCmd.BuildInstallCmd((FDefs as TPyPackageManagerDefsConda).InstallOptions);
140 | LConda := Import('conda.cli');
141 | LResult := LConda.main('conda', TPyEx.List(LIn), FDefs.PackageName);
142 |
143 | if (LResult <> 0) then
144 | raise ECondaExecCmdFailed.Create('Conda command has failed.', LResult);
145 | end;
146 |
147 | procedure TPyPackageManagerConda.Uninstall(const ACancelation: ICancelation);
148 | var
149 | LIn: TArray;
150 | LConda: variant;
151 | LResult: Integer;
152 | begin
153 | //Will be changed to run on a separeted process
154 | LIn := FCmd.BuildUninstallCmd((FDefs as TPyPackageManagerDefsConda).UninstallOptions);
155 | LConda := Import('conda.cli');
156 | LResult := LConda.main('conda', TPyEx.List(LIn), FDefs.PackageName);
157 |
158 | if (LResult <> 0) then
159 | raise ECondaExecCmdFailed.Create('Conda command has failed.', LResult);
160 | end;
161 |
162 | end.
163 |
--------------------------------------------------------------------------------
/src/Manager/Defs/Opts/Conda/PyPackage.Manager.Defs.Opts.Conda.List.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs.Opts.Conda.List' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs.Opts layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs.Opts.Conda.List;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes,
37 | PyPackage.Manager.Defs.Opts;
38 |
39 | type
40 | TPyPackageManagerDefsOptsCondaList = class(TPyPackageManagerDefsOpts)
41 | private
42 | FRegex: string;
43 | FShowChannelUrls: boolean;
44 | FCanonical: boolean;
45 | FFullName: boolean;
46 | FExplicity: boolean;
47 | FMd5: boolean;
48 | FExport: boolean;
49 | FRevisions: boolean;
50 | FNoPip: boolean;
51 | FName: string;
52 | FPrefix: string;
53 | FJson: boolean;
54 | FVerbose: TStrings;
55 | FQuiet: boolean;
56 | procedure SetVerbose(const Value: TStrings);
57 | public
58 | constructor Create();
59 | destructor Destroy(); override;
60 | published
61 | {***** Positional Arguments *****}
62 |
63 | ///
64 | /// List only packages matching this regular expression.
65 | ///
66 | property Regex: string read FRegex write FRegex;
67 |
68 | {***** Named Arguments *****}
69 |
70 | ///
71 | /// Show channel urls. Overrides the value given by conda config --show show_channel_urls.
72 | ///
73 | property ShowChannelUrls: boolean read FShowChannelUrls write FShowChannelUrls default false;
74 | ///
75 | /// Output canonical names of packages only. Implies --no-pip.
76 | ///
77 | property Canonical: boolean read FCanonical write FCanonical default false;
78 | ///
79 | /// Only search for full names, i.e., ^$.
80 | ///
81 | property FullName: boolean read FFullName write FFullName default false;
82 | ///
83 | /// List explicitly all installed conda packaged with URL (output may be used by conda create --file).
84 | ///
85 | property Explicity: boolean read FExplicity write FExplicity default false;
86 | ///
87 | /// Add MD5 hashsum when using --explicit
88 | ///
89 | property Md5: boolean read FMd5 write FMd5 default false;
90 | ///
91 | /// Output requirement string only (output may be used by conda create --file).
92 | ///
93 | property Export: boolean read FExport write FExport default false;
94 | ///
95 | /// List the revision history and exit.
96 | ///
97 | property Revisions: boolean read FRevisions write FRevisions default false;
98 | ///
99 | /// Do not include pip-only installed packages.
100 | ///
101 | property NoPip: boolean read FNoPip write FNoPip default false;
102 |
103 | {***** Target Environment Specification *****}
104 |
105 | ///
106 | /// Name of environment.
107 | ///
108 | property Name: string read FName write FName;
109 | ///
110 | /// Full path to environment location (i.e. prefix).
111 | ///
112 | property Prefix: string read FPrefix write FPrefix;
113 |
114 | {***** Output, Prompt, and Flow Control Options *****}
115 |
116 | ///
117 | /// Report all output as json. Suitable for using conda programmati-cally.
118 | ///
119 | property Json: boolean read FJson write FJson default false;
120 | ///
121 | /// Use once for info, twice for debug, three times for trace.
122 | ///
123 | property Verbose: TStrings read FVerbose write SetVerbose;
124 | ///
125 | /// Do not display progress bar.
126 | ///
127 | property Quiet: boolean read FQuiet write FQuiet default false;
128 | end;
129 |
130 | implementation
131 |
132 | { TPyPackageManagerDefsListOptsConda }
133 |
134 | constructor TPyPackageManagerDefsOptsCondaList.Create;
135 | begin
136 | inherited;
137 | FVerbose := TStringList.Create();
138 | end;
139 |
140 | destructor TPyPackageManagerDefsOptsCondaList.Destroy;
141 | begin
142 | FVerbose.Free();
143 | inherited;
144 | end;
145 |
146 | procedure TPyPackageManagerDefsOptsCondaList.SetVerbose(const Value: TStrings);
147 | begin
148 | FVerbose := Value;
149 | end;
150 |
151 | end.
152 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/Conda/PyPackage.Manager.Cmd.Conda.List.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Conda.List' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Conda.List;
32 |
33 | interface
34 |
35 | uses
36 | System.SysUtils, System.Classes, System.Generics.Collections,
37 | PyPackage.Manager.Defs.Opts.Conda.List;
38 |
39 | type
40 | TPyPackageManagerCmdCondaList = class
41 | private
42 | FOpts: TPyPackageManagerDefsOptsCondaList;
43 | public
44 | constructor Create(const AOpts: TPyPackageManagerDefsOptsCondaList);
45 |
46 | // function MakeListRegexCmd: TArray; inline;
47 | function MakeListShowChannelUrlsCmd: TArray; inline;
48 | function MakeListCanonicalCmd: TArray; inline;
49 | function MakeListFullNameCmd: TArray; inline;
50 | function MakeListExplicityCmd: TArray; inline;
51 | function MakeListMd5Cmd: TArray; inline;
52 | function MakeListExportCmd: TArray; inline;
53 | function MakeListRevisionsCmd: TArray; inline;
54 | function MakeListNoPipCmd: TArray; inline;
55 | function MakeListNameCmd: TArray; inline;
56 | function MakeListPrefixCmd: TArray; inline;
57 | function MakeListJsonCmd: TArray; inline;
58 | function MakeListVerboseCmd: TArray; inline;
59 | function MakeListQuietCmd: TArray; inline;
60 | end;
61 |
62 | implementation
63 |
64 | constructor TPyPackageManagerCmdCondaList.Create(
65 | const AOpts: TPyPackageManagerDefsOptsCondaList);
66 | begin
67 | FOpts := AOpts;
68 | end;
69 |
70 | function TPyPackageManagerCmdCondaList.MakeListCanonicalCmd: TArray;
71 | begin
72 | if FOpts.Canonical then
73 | Result := TArray.Create('--canonical');
74 | end;
75 |
76 | function TPyPackageManagerCmdCondaList.MakeListExplicityCmd: TArray;
77 | begin
78 | if FOpts.Explicity then
79 | Result := TArray.Create('--explicit');
80 | end;
81 |
82 | function TPyPackageManagerCmdCondaList.MakeListExportCmd: TArray;
83 | begin
84 | if FOpts.Export then
85 | Result := TArray.Create('--export');
86 | end;
87 |
88 | function TPyPackageManagerCmdCondaList.MakeListFullNameCmd: TArray;
89 | begin
90 | if FOpts.FullName then
91 | Result := TArray.Create('--full-name');
92 | end;
93 |
94 | function TPyPackageManagerCmdCondaList.MakeListJsonCmd: TArray;
95 | begin
96 | if FOpts.Json then
97 | Result := TArray.Create('--json');
98 | end;
99 |
100 | function TPyPackageManagerCmdCondaList.MakeListMd5Cmd: TArray;
101 | begin
102 | if FOpts.Md5 then
103 | Result := TArray.Create('--md5');
104 | end;
105 |
106 | function TPyPackageManagerCmdCondaList.MakeListNameCmd: TArray;
107 | begin
108 | if not FOpts.Name.IsEmpty() then
109 | Result := TArray.Create('--name', FOpts.Name);
110 | end;
111 |
112 | function TPyPackageManagerCmdCondaList.MakeListNoPipCmd: TArray;
113 | begin
114 | if FOpts.NoPip then
115 | Result := TArray.Create('--no-pip');
116 | end;
117 |
118 | function TPyPackageManagerCmdCondaList.MakeListPrefixCmd: TArray;
119 | begin
120 | if not FOpts.Prefix.IsEmpty() then
121 | Result := TArray.Create('--prefix', FOpts.Prefix);
122 | end;
123 |
124 | function TPyPackageManagerCmdCondaList.MakeListQuietCmd: TArray;
125 | begin
126 | if FOpts.Quiet then
127 | Result := TArray.Create('--quiet');
128 | end;
129 |
130 | //function TPyPackageManagerCmdCondaList.MakeListRegexCmd: TArray;
131 | //begin
132 | // if not FDefs.Regex.IsEmpty() then
133 | // Result := TArray.Create(FDefs.Regex);
134 | //end;
135 |
136 | function TPyPackageManagerCmdCondaList.MakeListRevisionsCmd: TArray;
137 | begin
138 | if FOpts.Revisions then
139 | Result := TArray.Create('--revisions');
140 | end;
141 |
142 | function TPyPackageManagerCmdCondaList.MakeListShowChannelUrlsCmd: TArray;
143 | begin
144 | if FOpts.ShowChannelUrls then
145 | Result := TArray.Create('--show-channel-urls');
146 | end;
147 |
148 | function TPyPackageManagerCmdCondaList.MakeListVerboseCmd: TArray;
149 | var
150 | LList: TList;
151 | LStr: string;
152 | begin
153 | LList := TList.Create();
154 | try
155 | for LStr in FOpts.Verbose do begin
156 | LList.Add(LStr);
157 | end;
158 | finally
159 | LList.Free();
160 | end;
161 | end;
162 |
163 | end.
164 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/Pip/PyPackage.Manager.Cmd.Pip.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Pip' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Pip;
32 |
33 | interface
34 |
35 | uses
36 | System.SysUtils, System.Classes, System.Generics.Collections,
37 | PyPackage.Manager.Cmd,
38 | PyPackage.Manager.Cmd.Intf,
39 | PyPackage.Manager.Defs.Opts;
40 |
41 | type
42 | TPyPackageManagerCmdPip = class(TPyPackageManagerCmd, IPyPackageManagerCmdIntf)
43 | private
44 | //Defs cmds
45 | // function MakePackageCmd: TArray; inline;
46 | public
47 | function BuildInstallCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
48 | function BuildUninstallCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
49 | function BuildListCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
50 | end;
51 |
52 | implementation
53 |
54 | uses
55 | PyPackage.Manager.Cmd.Pip.Install,
56 | PyPackage.Manager.Defs.Opts.Pip.Install,
57 | PyPackage.Manager.Cmd.Pip.Uninstall,
58 | PyPackage.Manager.Defs.Opts.Pip.Uninstall,
59 | PyPackage.Manager.Cmd.Pip.List,
60 | PyPackage.Manager.Defs.Opts.Pip.List;
61 |
62 | { TPyPackageManagerCmdPip }
63 |
64 | function TPyPackageManagerCmdPip.BuildInstallCmd(
65 | const AOpts: TPyPackageManagerDefsOpts): TArray;
66 | begin
67 | with TPyPackageManagerCmdPipInstall.Create(AOpts as TPyPackageManagerDefsOptsPipInstall) do
68 | try
69 | Result := TArray.Create('install')
70 | + MakeInstallRequirementCmd()
71 | + MakeInstallConstraintCmd()
72 | + MakeInstallNoDepsCmd()
73 | + MakeInstallPreCmd()
74 | + MakeInstallEditableCmd()
75 | + MakeInstallTargetCmd()
76 | + MakeInstallPlatformCmd()
77 | + MakeInstallPythonVersionCmd()
78 | + MakeIntallPythonImplementationCmd()
79 | + MakeInstallAbiCmd()
80 | + MakeInstallUserCmd()
81 | + MakeInstallRootCmd()
82 | + MakeInstallPrefixCmd()
83 | + MakeInstallSrcCmd()
84 | + MakeInstallUpgradeCmd()
85 | + MakeInstallUpgradeStrategyCmd()
86 | + MakeInstallForceReinstallCmd()
87 | + MakeInstallIgnoreInstalledCmd()
88 | + MakeInstallIgnoreRequiresPythonCmd()
89 | + MakeInstallNoBuildIsolationCmd()
90 | + MakeInstallUsePe517Cmd()
91 | + MakeInstallOptionCmd()
92 | + MakeInstallGlobalOptionCmd()
93 | + MakeInstallCompileCmd()
94 | + MakeInstallNoCompileCmd()
95 | + MakeInstallNoWarnScriptLocationCmd()
96 | + MakeInstallNoWarnConflictsCmd()
97 | + MakeInstallNoBinaryCmd()
98 | + MakeInstallOnlyBinaryCmd()
99 | + MakeInstallPreferBinaryCmd()
100 | + MakeInstallRequireHashesCmd()
101 | + MakeInstallProgressBarCmd()
102 | + MakeInstallNoCleanCmd()
103 | + MakeInstallIndexUrlCmd()
104 | + MakeInstallExtraIndexUrlCmd()
105 | + MakeInstallNoIndexCmd()
106 | + MakeInstallFindLinksCmd()
107 | + [Defs.PackageName + Defs.PackageVersion];
108 | finally
109 | Free();
110 | end;
111 | end;
112 |
113 | function TPyPackageManagerCmdPip.BuildListCmd(
114 | const AOpts: TPyPackageManagerDefsOpts): TArray;
115 | begin
116 | with TPyPackageManagerCmdPipList.Create(AOpts as TPyPackageManagerDefsOptsPipList) do
117 | try
118 | Result := TArray.Create('list')
119 | + MakeListOudatedCmd()
120 | + MakeListUpToDateCmd()
121 | + MakeListEditableCmd()
122 | + MakeListLocalCmd()
123 | + MakeListUserCmd()
124 | + MakeListPathCmd()
125 | + MakeListPreCmd()
126 | + MakeListFormatCmd()
127 | + MakeListNotRequiredCmd()
128 | + MakeListExcludeEditableCmd()
129 | + MakeListIncludeEditableCmd()
130 | + MakeListExcludeCmd()
131 | + MakeListIndexUrlCmd()
132 | + MakeListExtraIndexUrlCmd()
133 | + MakeListNoIndexCmd()
134 | + MakeListFindLinkdsCmd();
135 | finally
136 | Free();
137 | end;
138 | end;
139 |
140 | function TPyPackageManagerCmdPip.BuildUninstallCmd(
141 | const AOpts: TPyPackageManagerDefsOpts): TArray;
142 | begin
143 | with TPyPackageManagerCmdPipUninstall.Create(AOpts as TPyPackageManagerDefsOptsPipUninstall) do
144 | try
145 | Result := TArray.Create('uninstall')
146 | + MakeUninstallRequirementCmd()
147 | + MakeUninstallConfirmationFlagCmd()
148 | + [Defs.PackageName];
149 | finally
150 | Free();
151 | end;
152 | end;
153 |
154 | //function TPyPackageManagerCmdPip.MakePackageCmd: TArray;
155 | //begin
156 | // var LVersion: string;
157 | // if not Defs.PackageVersion.IsEmpty() then
158 | // LVersion := Defs.PackageVersion
159 | // else
160 | // LVersion := String.Empty;
161 | //
162 | // Result := TArray.Create(Defs.PackageName + LVersion);
163 | //end;
164 |
165 | end.
166 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/Pip/PyPackage.Manager.Cmd.Pip.List.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Pip.List' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Pip.List;
32 |
33 | interface
34 |
35 | uses
36 | System.SysUtils, System.Classes, System.Generics.Collections,
37 | PyPackage.Manager.Defs.Opts.Pip.List;
38 |
39 | type
40 | TPyPackageManagerCmdPipList = class
41 | private
42 | FOpts: TPyPackageManagerDefsOptsPipList;
43 | public
44 | constructor Create(const AOpts: TPyPackageManagerDefsOptsPipList);
45 |
46 | function MakeListOudatedCmd: TArray; inline;
47 | function MakeListUpToDateCmd: TArray; inline;
48 | function MakeListEditableCmd: TArray; inline;
49 | function MakeListLocalCmd: TArray; inline;
50 | function MakeListUserCmd: TArray; inline;
51 | function MakeListPathCmd: TArray; inline;
52 | function MakeListPreCmd: TArray; inline;
53 | function MakeListFormatCmd: TArray; inline;
54 | function MakeListNotRequiredCmd: TArray; inline;
55 | function MakeListExcludeEditableCmd: TArray; inline;
56 | function MakeListIncludeEditableCmd: TArray; inline;
57 | function MakeListExcludeCmd: TArray; inline;
58 | function MakeListIndexUrlCmd: TArray; inline;
59 | function MakeListExtraIndexUrlCmd: TArray; inline;
60 | function MakeListNoIndexCmd: TArray; inline;
61 | function MakeListFindLinkdsCmd: TArray; inline;
62 | end;
63 |
64 | implementation
65 |
66 | { TPyPackageManagerCmdPipList }
67 |
68 | constructor TPyPackageManagerCmdPipList.Create(
69 | const AOpts: TPyPackageManagerDefsOptsPipList);
70 | begin
71 | FOpts := AOpts;
72 | end;
73 |
74 | function TPyPackageManagerCmdPipList.MakeListEditableCmd: TArray;
75 | begin
76 | if FOpts.Editable then
77 | Result := TArray.Create('--editable');
78 | end;
79 |
80 | function TPyPackageManagerCmdPipList.MakeListExcludeCmd: TArray;
81 | begin
82 | if not FOpts.Exclude.IsEmpty() then
83 | Result := TArray.Create('--exclude', FOpts.IndexUrl);
84 | end;
85 |
86 | function TPyPackageManagerCmdPipList.MakeListExcludeEditableCmd: TArray;
87 | begin
88 | if FOpts.ExcludeEditable then
89 | Result := TArray.Create('--exclude-editable');
90 | end;
91 |
92 | function TPyPackageManagerCmdPipList.MakeListExtraIndexUrlCmd: TArray;
93 | begin
94 | if not FOpts.ExtraIndexUrl.IsEmpty() then
95 | Result := TArray.Create('--extra-index-url', FOpts.ExtraIndexUrl);
96 | end;
97 |
98 | function TPyPackageManagerCmdPipList.MakeListFindLinkdsCmd: TArray;
99 | begin
100 | if not FOpts.FindLinks.IsEmpty() then
101 | Result := TArray.Create('--find-links', FOpts.FindLinks);
102 | end;
103 |
104 | function TPyPackageManagerCmdPipList.MakeListFormatCmd: TArray;
105 | begin
106 | if not FOpts.Format.IsEmpty() then
107 | Result := TArray.Create('--format', FOpts.Format);
108 | end;
109 |
110 | function TPyPackageManagerCmdPipList.MakeListIncludeEditableCmd: TArray;
111 | begin
112 | if FOpts.IncludeEditable then
113 | Result := TArray.Create('--include-editable');
114 | end;
115 |
116 | function TPyPackageManagerCmdPipList.MakeListIndexUrlCmd: TArray;
117 | begin
118 | if not FOpts.IndexUrl.IsEmpty() then
119 | Result := TArray.Create('--index-url', FOpts.IndexUrl);
120 | end;
121 |
122 | function TPyPackageManagerCmdPipList.MakeListLocalCmd: TArray;
123 | begin
124 | if FOpts.Local then
125 | Result := TArray.Create('--local');
126 | end;
127 |
128 | function TPyPackageManagerCmdPipList.MakeListNoIndexCmd: TArray;
129 | begin
130 | if FOpts.NoIndex then
131 | Result := TArray.Create('--no-index');
132 | end;
133 |
134 | function TPyPackageManagerCmdPipList.MakeListNotRequiredCmd: TArray;
135 | begin
136 | if FOpts.NotRequired then
137 | Result := TArray.Create('--not-required');
138 | end;
139 |
140 | function TPyPackageManagerCmdPipList.MakeListOudatedCmd: TArray;
141 | begin
142 | if FOpts.Outdated then
143 | Result := TArray.Create('--outdated');
144 | end;
145 |
146 | function TPyPackageManagerCmdPipList.MakeListPathCmd: TArray;
147 | var
148 | LList: TList;
149 | LStr: string;
150 | begin
151 | LList := TList.Create();
152 | try
153 | for LStr in FOpts.Path do begin
154 | LList.Add('--path=' + LStr);
155 | end;
156 | Result := LList.ToArray();
157 | finally
158 | LList.Free();
159 | end;
160 | end;
161 |
162 | function TPyPackageManagerCmdPipList.MakeListPreCmd: TArray;
163 | begin
164 | if FOpts.Pre then
165 | Result := TArray.Create('--pre');
166 | end;
167 |
168 | function TPyPackageManagerCmdPipList.MakeListUpToDateCmd: TArray;
169 | begin
170 | if FOpts.UpToDate then
171 | Result := TArray.Create('--uptodate');
172 | end;
173 |
174 | function TPyPackageManagerCmdPipList.MakeListUserCmd: TArray;
175 | begin
176 | if FOpts.User then
177 | Result := TArray.Create('--user');
178 | end;
179 |
180 | end.
181 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/Conda/PyPackage.Manager.Cmd.Conda.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Conda' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Conda;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes, System.SysUtils, System.Generics.Collections,
37 | PyPackage.Manager.Cmd,
38 | PyPackage.Manager.Cmd.Intf,
39 | PyPackage.Manager.Defs.Opts;
40 |
41 | type
42 | TPyPackageManagerCmdConda = class(TPyPackageManagerCmd, IPyPackageManagerCmdIntf)
43 | private
44 | // function MakePackageCmd: TArray; inline;
45 | public
46 | function BuildInstallCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
47 | function BuildUninstallCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
48 | function BuildListCmd(const AOpts: TPyPackageManagerDefsOpts): TArray;
49 | end;
50 |
51 | implementation
52 |
53 | uses
54 | PyPackage.Manager.Cmd.Conda.Install,
55 | PyPackage.Manager.Defs.Opts.Conda.Install,
56 | PyPackage.Manager.Cmd.Conda.Uninstall,
57 | PyPackage.Manager.Defs.Opts.Conda.Uninstall,
58 | PyPackage.Manager.Cmd.Conda.List,
59 | PyPackage.Manager.Defs.Opts.Conda.List;
60 |
61 | { TPyPackageManagerCmdConda }
62 |
63 | //function TPyPackageManagerCmdConda.MakePackageCmd: TArray;
64 | //begin
65 | // var LVersion: string;
66 | // if not Defs.PackageVersion.IsEmpty() then
67 | // LVersion := Defs.PackageVersion
68 | // else
69 | // LVersion := String.Empty;
70 | //
71 | // Result := TArray.Create(Defs.PackageName + LVersion);
72 | //end;
73 |
74 | function TPyPackageManagerCmdConda.BuildInstallCmd(
75 | const AOpts: TPyPackageManagerDefsOpts): TArray;
76 | begin
77 | with TPyPackageManagerCmdCondaInstall.Create(AOpts as TPyPackageManagerDefsOptsCondaInstall) do
78 | try
79 | Result := TArray.Create('install')
80 | + MakeInstallRevisionCmd()
81 | + MakeInstallFileCmd()
82 | + MakeInstallNameCmd()
83 | + MakeInstallPrefixCmd()
84 | + MakeInstallChannelCmd()
85 | + MakeInstallUseLocalCmd()
86 | + MakeInstallOverrideChannelsCmd()
87 | + MakeInstallRepoDataCmd()
88 | + MakeInstallStrictChannelPriorityCmd()
89 | + MakeInstallNoChannelPriorityCmd()
90 | + MakeInstallNoDepsCmd()
91 | + MakeInstallOnlyDepsCmd()
92 | + MakeInstallNoPinCmd()
93 | + MakeInstallExperimentalSolverCmd()
94 | + MakeInstallForceReinstallCmd()
95 | + MakeInstallNoUpdateDepsCmd()
96 | + MakeInstallUpdateDepsCmd()
97 | + MakeInstallSatisfiedSkipSolveCmd()
98 | + MakeInstallUpdateAllCmd()
99 | + MakeInstallUpdateSpecsCmd()
100 | + MakeInstallCopyCmd()
101 | + MakeInstallMkDirCmd()
102 | + MakeInstallClobberCmd()
103 | + MakeInstallUseIndexCacheCmd()
104 | + MakeInstallInsecureCmd()
105 | + MakeInstallOfflineCmd()
106 | + MakeInstallDryRunCmd()
107 | + MakeInstallJsonCmd()
108 | + MakeInstallQuietCmd()
109 | + MakeInstallVerboseCmd()
110 | + MakeInstallDoNotAskForConfirmationCmd()
111 | + MakeInstallDownloadOnlyCmd()
112 | + MakeInstallShowChannelUrlsCmd()
113 | finally
114 | Free();
115 | end;
116 | end;
117 |
118 | function TPyPackageManagerCmdConda.BuildUninstallCmd(
119 | const AOpts: TPyPackageManagerDefsOpts): TArray;
120 | begin
121 | with TPyPackageManagerCmdCondaUninstall.Create(AOpts as TPyPackageManagerDefsOptsCondaUninstall) do
122 | try
123 | Result := TArray.Create('remove')
124 | + MakeUninstallNameCmd()
125 | + MakeUninstallPrefixCmd()
126 | + MakeUninstallChannelCmd()
127 | + MakeUninstallUseLocalCmd()
128 | + MakeUninstallOverrideChannelsCmd()
129 | + MakeUninstallRepodataCmd()
130 | + MakeUninstallAllCmd()
131 | + MakeUninstallFeaturesCmd()
132 | + MakeUninstallForceCmd()
133 | + MakeUninstallNoPinCmd()
134 | + MakeUninstallExperimentalSolverCmd()
135 | + MakeUninstallUseIndexCacheCmd()
136 | + MakeUninstallInsecureCmd()
137 | + MakeUninstallOfflineCmd()
138 | + MakeUninstallDryRunCmd()
139 | + MakeUninstallJsonCmd()
140 | + MakeUninstallQuietCmd()
141 | + MakeUninstallVerboseCmd()
142 | + MakeUninstallYesCmd()
143 | finally
144 | Free();
145 | end;
146 | end;
147 |
148 | function TPyPackageManagerCmdConda.BuildListCmd(
149 | const AOpts: TPyPackageManagerDefsOpts): TArray;
150 | begin
151 | with TPyPackageManagerCmdCondaList.Create(AOpts as TPyPackageManagerDefsOptsCondaList) do
152 | try
153 | Result := TArray.Create('list')
154 | + MakeListShowChannelUrlsCmd()
155 | + MakeListCanonicalCmd()
156 | + MakeListFullNameCmd()
157 | + MakeListExplicityCmd()
158 | + MakeListMd5Cmd()
159 | + MakeListExportCmd()
160 | + MakeListRevisionsCmd()
161 | + MakeListNoPipCmd()
162 | + MakeListNameCmd()
163 | + MakeListPrefixCmd()
164 | + MakeListJsonCmd()
165 | + MakeListVerboseCmd()
166 | + MakeListQuietCmd();
167 | finally
168 | Free();
169 | end;
170 | end;
171 |
172 | end.
173 |
--------------------------------------------------------------------------------
/packages/dclP4DPyPackage.dproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | True
4 | Package
5 | Release
6 | None
7 | dclP4DPyPackage.dpk
8 | Win32
9 | {C4C32D67-6742-44C6-A714-965E23585BA2}
10 | dclP4DPyPackage
11 | 20.1
12 | 1
13 |
14 |
15 | true
16 |
17 |
18 | true
19 | Base
20 | true
21 |
22 |
23 | true
24 | Base
25 | true
26 |
27 |
28 | true
29 | Cfg_1
30 | true
31 | true
32 |
33 |
34 | true
35 | Base
36 | true
37 |
38 |
39 | true
40 | Cfg_2
41 | true
42 | true
43 |
44 |
45 | dclP4DPyPackage
46 | ..\lib\$(Platform)\$(Config)
47 | P4D AI&ML extension for Python packages
48 | 00400000
49 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)
50 | true
51 | $(Auto)
52 | true
53 | true
54 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=
55 | 1033
56 |
57 |
58 | Debug
59 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)
60 | rtl;P4DPyPackage;$(DCC_UsePackage)
61 | true
62 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)
63 | 1033
64 |
65 |
66 | 0
67 | RELEASE;$(DCC_Define)
68 | false
69 | 0
70 |
71 |
72 | true
73 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)
74 |
75 |
76 | DEBUG;$(DCC_Define)
77 | true
78 | true
79 | false
80 | true
81 |
82 |
83 | true
84 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)
85 |
86 |
87 |
88 | MainSource
89 |
90 |
91 |
92 |
93 |
94 |
95 | Base
96 |
97 |
98 | Cfg_1
99 | Base
100 |
101 |
102 | Cfg_2
103 | Base
104 |
105 |
106 |
107 | Delphi.Personality.12
108 | Package
109 |
110 |
111 |
112 | dclP4DPyPackage.dpk
113 |
114 |
115 |
116 |
117 | False
118 | False
119 | False
120 | False
121 | False
122 | True
123 | False
124 | False
125 | False
126 | False
127 |
128 |
129 | 12
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/src/Manager/Defs/Opts/Pip/PyPackage.Manager.Defs.Opts.Pip.Install.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs.Opts.Pip.Install' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs.Opts layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs.Opts.Pip.Install;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes,
37 | PyPackage.Manager.Defs.Opts;
38 |
39 | type
40 | TPyPackageManagerDefsOptsPipInstall = class(TPyPackageManagerDefsOpts)
41 | private
42 | FRequirement: string;
43 | FConstraint: string;
44 | FNoDeps: boolean;
45 | FPre: boolean;
46 | FEditable: string;
47 | FTarget: string;
48 | FPlatform: string;
49 | FPythonVersion: string;
50 | FPythonImplementation: string;
51 | FAbi: string;
52 | FUser: boolean;
53 | FRoot: string;
54 | FPrefix: string;
55 | FSource: string;
56 | FUpgrade: boolean;
57 | FUpgradeStrategy: string;
58 | FForceReinstall: boolean;
59 | FIgnoreInstalled: boolean;
60 | FIgnoreRequiresPython: boolean;
61 | FNoBuildIsolation: boolean;
62 | FUsePep517: boolean;
63 | FInstallOption: TStrings;
64 | FGlobalOption: TStrings;
65 | FCompile: boolean;
66 | FNoWarnScriptLocation: boolean;
67 | FNoWarnConflicts: boolean;
68 | FNoBinary: boolean;
69 | FNoCompile: boolean;
70 | FOnlyBinary: boolean;
71 | FPreferBinary: boolean;
72 | FRequireHashes: boolean;
73 | FProgressBar: boolean;
74 | FNoClean: boolean;
75 | FIndexUrl: string;
76 | FExtraIndexUrl: string;
77 | FNoIndex: boolean;
78 | FFindLinks: string;
79 | procedure SetGlobalOption(const Value: TStrings);
80 | procedure SetInstallOption(const Value: TStrings);
81 | public
82 | constructor Create();
83 | destructor Destroy(); override;
84 | published
85 | property Requirement: string read FRequirement write FRequirement;
86 | property Constraint: string read FConstraint write FConstraint;
87 | property NoDeps: boolean read FNoDeps write FNoDeps default false;
88 | property Pre: boolean read FPre write FPre default false;
89 | property Editable: string read FEditable write FEditable;
90 | property Target: string read FTarget write FTarget;
91 | property Platform: string read FPlatform write FPlatform;
92 | property PythonVersion: string read FPythonVersion write FPythonVersion;
93 | property PythonImplementation: string read FPythonImplementation write FPythonImplementation;
94 | property Abi: string read FAbi write FAbi;
95 | property User: boolean read FUser write FUser default false;
96 | property Root: string read FRoot write FRoot;
97 | property Prefix: string read FPrefix write FPrefix;
98 | property Source: string read FSource write FSource;
99 | property Upgrade: boolean read FUpgrade write FUpgrade default false;
100 | property UpgradeStrategy: string read FUpgradeStrategy write FUpgradeStrategy;
101 | property ForceReinstall: boolean read FForceReinstall write FForceReinstall default false;
102 | property IgnoreInstalled: boolean read FIgnoreInstalled write FIgnoreInstalled default false;
103 | property IgnoreRequiresPython: boolean read FIgnoreRequiresPython write FIgnoreRequiresPython default false;
104 | property NoBuildIsolation: boolean read FNoBuildIsolation write FNoBuildIsolation default false;
105 | property UsePep517: boolean read FUsePep517 write FUsePep517 default false;
106 | property InstallOption: TStrings read FInstallOption write SetInstallOption;
107 | property GlobalOption: TStrings read FGlobalOption write SetGlobalOption;
108 | property Compile: boolean read FCompile write FCompile default false;
109 | property NoCompile: boolean read FNoCompile write FNoCompile default false;
110 | property NoWarnScriptLocation: boolean read FNoWarnScriptLocation write FNoWarnScriptLocation default false;
111 | property NoWarnConflicts: boolean read FNoWarnConflicts write FNoWarnConflicts default false;
112 | property NoBinary: boolean read FNoBinary write FNoBinary default false;
113 | property OnlyBinary: boolean read FOnlyBinary write FOnlyBinary default false;
114 | property PreferBinary: boolean read FPreferBinary write FPreferBinary default false;
115 | property RequireHashes: boolean read FRequireHashes write FRequireHashes default false;
116 | property ProgressBar: boolean read FProgressBar write FProgressBar default false;
117 | property NoClean: boolean read FNoClean write FNoClean default false;
118 | property IndexUrl: string read FIndexUrl write FIndexUrl;
119 | property ExtraIndexUrl: string read FExtraIndexUrl write FExtraIndexUrl;
120 | property NoIndex: boolean read FNoIndex write FNoIndex default false;
121 | property FindLinks: string read FFindLinks write FFindLinks;
122 | end;
123 |
124 | implementation
125 |
126 | { TPyPackageManagerDefsInstallOptsPip }
127 |
128 | constructor TPyPackageManagerDefsOptsPipInstall.Create;
129 | begin
130 | FInstallOption := TStringList.Create();
131 | FGlobalOption := TStringList.Create();
132 | end;
133 |
134 | destructor TPyPackageManagerDefsOptsPipInstall.Destroy;
135 | begin
136 | FGlobalOption.Free();
137 | FInstallOption.Free();
138 | inherited;
139 | end;
140 |
141 | procedure TPyPackageManagerDefsOptsPipInstall.SetGlobalOption(
142 | const Value: TStrings);
143 | begin
144 | FGlobalOption.Assign(Value);
145 | end;
146 |
147 | procedure TPyPackageManagerDefsOptsPipInstall.SetInstallOption(
148 | const Value: TStrings);
149 | begin
150 | FInstallOption.Assign(Value);
151 | end;
152 |
153 | end.
154 |
--------------------------------------------------------------------------------
/src/Manager/PyPackage.Manager.Pip.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Pip' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Manager layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Pip;
32 |
33 | interface
34 |
35 | uses
36 | PyTools.ExecCmd,
37 | PyTools.ExecCmd.Args,
38 | PyTools.Cancelation,
39 | PyCore,
40 | PyPackage,
41 | PyPackage.Manager,
42 | PyPackage.Manager.Intf,
43 | PyPackage.Manager.Defs,
44 | PyPackage.Manager.Cmd.Intf,
45 | PyPackage.Manager.Defs.Opts.Pip.List;
46 |
47 | type
48 | TPyPackageManagerPip = class(TPyPackageManager, IPyPackageManager)
49 | private
50 | FDefs: TPyPackageManagerDefs;
51 | FCmd: IPyPackageManagerCmdIntf;
52 | //Builders
53 | function BuildOptsList(): TPyPackageManagerDefsOptsPipList;
54 | //IPyPackageManager implementation
55 | function GetDefs(): TPyPackageManagerDefs;
56 | function GetCmd(): IPyPackageManagerCmdIntf;
57 | function IsInstalled(): boolean;
58 | procedure Install(const ACancelation: ICancelation);
59 | procedure Uninstall(const ACancelation: ICancelation);
60 | public
61 | constructor Create(const APackageName: TPyPackageName); override;
62 | destructor Destroy; override;
63 | end;
64 |
65 | implementation
66 |
67 | uses
68 | System.Variants, System.SysUtils, System.IOUtils, System.Generics.Collections,
69 | PythonEngine,
70 | PyUtils,
71 | PyExceptions,
72 | PyPackage.Manager.Defs.Pip,
73 | PyPackage.Manager.Cmd.Pip, System.SyncObjs;
74 |
75 | { TPyPackageManagerPip }
76 |
77 | constructor TPyPackageManagerPip.Create(const APackageName: TPyPackageName);
78 | begin
79 | inherited;
80 | FDefs := TPyPackageManagerDefsPip.Create(APackageName);
81 | FCmd := TPyPackageManagerCmdPip.Create(FDefs);
82 | end;
83 |
84 | destructor TPyPackageManagerPip.Destroy;
85 | begin
86 | FCmd := nil;
87 | FDefs.Free();
88 | inherited;
89 | end;
90 |
91 | function TPyPackageManagerPip.GetCmd: IPyPackageManagerCmdIntf;
92 | begin
93 | Result := FCmd;
94 | end;
95 |
96 | function TPyPackageManagerPip.GetDefs: TPyPackageManagerDefs;
97 | begin
98 | Result := FDefs;
99 | end;
100 |
101 | function TPyPackageManagerPip.BuildOptsList: TPyPackageManagerDefsOptsPipList;
102 | begin
103 | Result := TPyPackageManagerDefsOptsPipList.Create();
104 | try
105 | Result.User := (FDefs as TPyPackageManagerDefsPip).InstallOptions.User;
106 | except
107 | on E: Exception do begin
108 | Result.Free();
109 | raise;
110 | end;
111 | end;
112 | end;
113 |
114 | function TPyPackageManagerPip.IsInstalled(): boolean;
115 | var
116 | LOpts: TPyPackageManagerDefsOptsPipList;
117 | LExec: IExecCmd;
118 | begin
119 | LOpts := BuildOptsList();
120 | try
121 | LExec := TExecCmdService
122 | .Cmd(GetPythonEngine().ProgramName,
123 | TExecCmdArgs.BuildArgv(
124 | GetPythonEngine().ProgramName,
125 | ['-m', 'pip'] + FCmd.BuildListCmd(LOpts)),
126 | TExecCmdArgs.BuildEnvp(
127 | GetPythonEngine().PythonHome,
128 | GetPythonEngine().ProgramName,
129 | TPath.Combine(GetPythonEngine().DllPath, GetPythonEngine().DllName)))
130 | .Run([TRedirect.stdout, TRedirect.stderr]);
131 |
132 | if (LExec.Wait() <> EXIT_SUCCESS) then
133 | raise EPipExecCmdFailed.Create(
134 | Format('Pip comamnd has failed. %s', [LExec.StdErr.ReadAll().Trim()]), LExec.ExitCode);
135 |
136 | Result := LExec.StdOut.ReadAll().Contains(FDefs.PackageName);
137 | finally
138 | LOpts.Free();
139 | end;
140 | end;
141 |
142 | procedure TPyPackageManagerPip.Install(const ACancelation: ICancelation);
143 | var
144 | LIn: TArray;
145 | LExec: IExecCmd;
146 | begin
147 | LIn := ['-m', 'pip']
148 | + FCmd.BuildInstallCmd((FDefs as TPyPackageManagerDefsPip).InstallOptions);
149 |
150 | LExec := TExecCmdService
151 | .Cmd(GetPythonEngine().ProgramName,
152 | TExecCmdArgs.BuildArgv(
153 | GetPythonEngine().ProgramName,
154 | LIn),
155 | TExecCmdArgs.BuildEnvp(
156 | GetPythonEngine().PythonHome,
157 | GetPythonEngine().ProgramName,
158 | TPath.Combine(GetPythonEngine().DllPath, GetPythonEngine().DllName)))
159 | .Run([TRedirect.stderr]);
160 |
161 | TSpinWait.SpinUntil(function(): boolean begin
162 | Result := not LExec.IsAlive or ACancelation.IsCancelled;
163 | end);
164 |
165 | ACancelation.CheckCancelled();
166 |
167 | if (LExec.Wait() <> EXIT_SUCCESS) then
168 | raise EPipExecCmdFailed.Create(
169 | Format('Pip command has failed. %s', [LExec.StdErr.ReadAll().Trim()]), LExec.ExitCode);
170 | end;
171 |
172 | procedure TPyPackageManagerPip.Uninstall(const ACancelation: ICancelation);
173 | var
174 | LIn: TArray;
175 | LExec: IExecCmd;
176 | begin
177 | LIn := ['-m', 'pip']
178 | + FCmd.BuildInstallCmd((FDefs as TPyPackageManagerDefsPip).UninstallOptions);
179 |
180 | LExec := TExecCmdService
181 | .Cmd(GetPythonEngine().ProgramName,
182 | TExecCmdArgs.BuildArgv(
183 | GetPythonEngine().ProgramName,
184 | LIn),
185 | TExecCmdArgs.BuildEnvp(
186 | GetPythonEngine().PythonHome,
187 | GetPythonEngine().ProgramName,
188 | TPath.Combine(GetPythonEngine().DllPath, GetPythonEngine().DllName)))
189 | .Run([TRedirect.stderr]);
190 |
191 | TSpinWait.SpinUntil(function(): boolean begin
192 | Result := not LExec.IsAlive or ACancelation.IsCancelled;
193 | end);
194 |
195 | ACancelation.CheckCancelled();
196 |
197 | if (LExec.Wait() <> EXIT_SUCCESS) then
198 | raise EPipExecCmdFailed.Create(
199 | Format('Pip command has failed. %s', [LExec.StdErr.ReadAll().Trim()]), LExec.ExitCode);
200 | end;
201 |
202 | end.
203 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/Conda/PyPackage.Manager.Cmd.Conda.Uninstall.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Conda.Uninstall' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Conda.Uninstall;
32 |
33 | interface
34 |
35 | uses
36 | System.SysUtils, System.Classes, System.Generics.Collections,
37 | PyPackage.Manager.Defs.Opts.Conda.Uninstall;
38 |
39 | type
40 | TPyPackageManagerCmdCondaUninstall = class
41 | private
42 | FOpts: TPyPackageManagerDefsOptsCondaUninstall;
43 | public
44 | constructor Create(const ADefs: TPyPackageManagerDefsOptsCondaUninstall);
45 |
46 | function MakeUninstallNameCmd: TArray; inline;
47 | function MakeUninstallPrefixCmd: TArray; inline;
48 | function MakeUninstallChannelCmd: TArray; inline;
49 | function MakeUninstallUseLocalCmd: TArray; inline;
50 | function MakeUninstallOverrideChannelsCmd: TArray; inline;
51 | function MakeUninstallRepodataCmd: TArray; inline;
52 | function MakeUninstallAllCmd: TArray; inline;
53 | function MakeUninstallFeaturesCmd: TArray; inline;
54 | function MakeUninstallForceCmd: TArray; inline;
55 | function MakeUninstallNoPinCmd: TArray; inline;
56 | function MakeUninstallExperimentalSolverCmd: TArray; inline;
57 | function MakeUninstallUseIndexCacheCmd: TArray; inline;
58 | function MakeUninstallInsecureCmd: TArray; inline;
59 | function MakeUninstallOfflineCmd: TArray; inline;
60 | function MakeUninstallDryRunCmd: TArray; inline;
61 | function MakeUninstallJsonCmd: TArray; inline;
62 | function MakeUninstallQuietCmd: TArray; inline;
63 | function MakeUninstallVerboseCmd: TArray; inline;
64 | function MakeUninstallYesCmd: TArray; inline;
65 | end;
66 |
67 | implementation
68 |
69 | constructor TPyPackageManagerCmdCondaUninstall.Create(
70 | const ADefs: TPyPackageManagerDefsOptsCondaUninstall);
71 | begin
72 | FOpts := ADefs;
73 | end;
74 |
75 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallAllCmd: TArray;
76 | begin
77 | if FOpts.All then
78 | Result := TArray.Create('--all');
79 | end;
80 |
81 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallChannelCmd: TArray;
82 | begin
83 | if not FOpts.Channel.IsEmpty() then
84 | Result := TArray.Create('--channel', FOpts.Channel);
85 | end;
86 |
87 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallDryRunCmd: TArray;
88 | begin
89 | if FOpts.DryRun then
90 | Result := TArray.Create('--dry-run');
91 | end;
92 |
93 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallExperimentalSolverCmd: TArray;
94 | begin
95 | if FOpts.ExperimentalSolver then
96 | Result := TArray.Create('--experimental-solver');
97 | end;
98 |
99 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallFeaturesCmd: TArray;
100 | begin
101 | if FOpts.Features then
102 | Result := TArray.Create('--features');
103 | end;
104 |
105 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallForceCmd: TArray;
106 | begin
107 | if FOpts.Force then
108 | Result := TArray.Create('--force');
109 | end;
110 |
111 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallInsecureCmd: TArray;
112 | begin
113 | if FOpts.Insecure then
114 | Result := TArray.Create('--insecure');
115 | end;
116 |
117 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallJsonCmd: TArray;
118 | begin
119 | if FOpts.Json then
120 | Result := TArray.Create('--json');
121 | end;
122 |
123 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallNameCmd: TArray;
124 | begin
125 | if not FOpts.Name.IsEmpty() then
126 | Result := TArray.Create('--name', FOpts.Name);
127 | end;
128 |
129 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallNoPinCmd: TArray;
130 | begin
131 | if FOpts.NoPin then
132 | Result := TArray.Create('--no-pin');
133 | end;
134 |
135 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallOfflineCmd: TArray;
136 | begin
137 | if FOpts.Offline then
138 | Result := TArray.Create('--offline');
139 | end;
140 |
141 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallOverrideChannelsCmd: TArray;
142 | begin
143 | if FOpts.OverrideChannels then
144 | Result := TArray.Create('--override-channels');
145 | end;
146 |
147 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallPrefixCmd: TArray;
148 | begin
149 | if not FOpts.Prefix.IsEmpty() then
150 | Result := TArray.Create('--prefix', FOpts.Prefix);
151 | end;
152 |
153 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallQuietCmd: TArray;
154 | begin
155 | if FOpts.Quiet then
156 | Result := TArray.Create('--quiet');
157 | end;
158 |
159 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallRepodataCmd: TArray;
160 | var
161 | LList: TList;
162 | LStr: string;
163 | begin
164 | LList := TList.Create();
165 | try
166 | for LStr in FOpts.RepoData do begin
167 | LList.Add('--repodata-fn=' + LStr);
168 | end;
169 | Result := LList.ToArray();
170 | finally
171 | LList.Free();
172 | end;
173 | end;
174 |
175 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallUseIndexCacheCmd: TArray;
176 | begin
177 | if FOpts.UseIndexCache then
178 | Result := TArray.Create('--use-index-cache');
179 | end;
180 |
181 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallUseLocalCmd: TArray;
182 | begin
183 | if FOpts.UseLocal then
184 | Result := TArray.Create('--use-local');
185 | end;
186 |
187 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallVerboseCmd: TArray;
188 | var
189 | LList: TList;
190 | LStr: string;
191 | begin
192 | LList := TList.Create();
193 | try
194 | for LStr in FOpts.Verbose do begin
195 | LList.Add(LStr);
196 | end;
197 | finally
198 | LList.Free();
199 | end;
200 | end;
201 |
202 | function TPyPackageManagerCmdCondaUninstall.MakeUninstallYesCmd: TArray;
203 | begin
204 | if FOpts.DoNotAskForConfirmation then
205 | Result := TArray.Create('--yes');
206 | end;
207 |
208 | end.
209 |
--------------------------------------------------------------------------------
/src/Manager/Defs/Opts/Conda/PyPackage.Manager.Defs.Opts.Conda.Uninstall.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs.Opts.Conda.Uninstall' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs.Opts layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs.Opts.Conda.Uninstall;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes,
37 | PyPackage.Manager.Defs.Opts;
38 |
39 | type
40 | TPyPackageManagerDefsOptsCondaUninstall = class(TPyPackageManagerDefsOpts)
41 | private
42 | FName: string;
43 | FPrefix: string;
44 | FChannel: string;
45 | FUseLocal: boolean;
46 | FOverrideChannels: boolean;
47 | FRepoData: TStrings;
48 | FAll: boolean;
49 | FFeatures: boolean;
50 | FForce: boolean;
51 | FNoPin: boolean;
52 | FExperimentalSolver: boolean;
53 | FUseIndexCache: boolean;
54 | FInsecure: boolean;
55 | FOffline: boolean;
56 | FDryRun: boolean;
57 | FJson: boolean;
58 | FQuiet: boolean;
59 | FVerbose: TStrings;
60 | FDoNotAskForConfirmation: boolean;
61 | procedure SetVerbose(const Value: TStrings);
62 | public
63 | constructor Create();
64 | destructor Destroy(); override;
65 | published
66 | {***** Target Environment Specification *****}
67 |
68 | ///
69 | /// Name of environment.
70 | ///
71 | property Name: string read FName write FName;
72 | ///
73 | /// Full path to environment location (i.e. prefix).
74 | ///
75 | property Prefix: string read FPrefix write FPrefix;
76 |
77 | {***** Channel Customization *****}
78 |
79 | ///
80 | /// Additional channel to search for packages. These are URLs searched in the order
81 | /// they are given (including local directories using the 'file://' syntax or
82 | /// simply a path like '/home/conda/mychan' or '../mychan'). Then, the defaults or channels
83 | /// from .condarc are searched (unless --override-channels is given). You can use 'defaults'
84 | /// to get the default packages for conda. You can also use any name and the .condarc
85 | /// channel_alias value will be prepended. The default channel_alias is https://conda.anaconda.org/.
86 | ///
87 | property Channel: string read FChannel write FChannel;
88 | ///
89 | /// Use locally built packages. Identical to '-c local'.
90 | ///
91 | property UseLocal: boolean read FUseLocal write FUseLocal default false;
92 | ///
93 | /// Do not search default or .condarc channels. Requires --channel.
94 | ///
95 | property OverrideChannels: boolean read FOverrideChannels write FOverrideChannels default false;
96 | ///
97 | /// Specify name of repodata on remote server. Conda will try whatever you specify,
98 | /// but will ultimately fall back to repodata.json if your specs are not satisfiable with what you specify here.
99 | /// This is used to employ repodata that is reduced in time scope. You may pass this flag more than once.
100 | /// Leftmost entries are tried first, and the fallback to repodata.json is added for you automatically.
101 | ///
102 | property RepoData: TStrings read FRepoData write FRepoData;
103 |
104 | {***** Solver Mode Modifiers *****}
105 |
106 | ///
107 | /// Remove all packages, i.e., the entire environment.
108 | ///
109 | property All: boolean read FAll write FAll default false;
110 | ///
111 | /// Remove features (instead of packages).
112 | ///
113 | property Features: boolean read FFeatures write FFeatures default false;
114 | ///
115 | /// Forces removal of a package without removing packages that depend on it. Using this option will usually leave your environment in a broken and inconsistent state.
116 | ///
117 | property Force: boolean read FForce write FForce default false;
118 | ///
119 | /// Ignore pinned file.
120 | ///
121 | property NoPin: boolean read FNoPin write FNoPin default false;
122 | ///
123 | /// Possible choices: classic, libmamba, libmamba-draft EXPERIMENTAL. Choose which solver backend to use.
124 | ///
125 | property ExperimentalSolver: boolean read FExperimentalSolver write FExperimentalSolver default false;
126 |
127 | {***** Networking Options *****}
128 |
129 | ///
130 | /// Use cache of channel index files, even if it has expired.
131 | ///
132 | property UseIndexCache: boolean read FUseIndexCache write FUseIndexCache default false;
133 | ///
134 | /// Allow conda to perform "insecure" SSL connections and transfers. Equivalent to setting 'ssl_verify' to 'false'.
135 | ///
136 | property Insecure: boolean read FInsecure write FInsecure default false;
137 | ///
138 | /// Offline mode. Don't connect to the Internet.
139 | ///
140 | property Offline: boolean read FOffline write FOffline default false;
141 |
142 | {***** Output, Prompt, and Flow Control Options *****}
143 |
144 | ///
145 | /// Only display what would have been done.
146 | ///
147 | property DryRun: boolean read FDryRun write FDryRun default false;
148 | ///
149 | /// Report all output as json. Suitable for using conda programmatically.
150 | ///
151 | property Json: boolean read FJson write FJson default false;
152 | ///
153 | /// Do not display progress bar.
154 | ///
155 | property Quiet: boolean read FQuiet write FQuiet default false;
156 | ///
157 | /// Can be used multiple times. Once for INFO, twice for DEBUG, three times for TRACE.
158 | ///
159 | property Verbose: TStrings read FVerbose write SetVerbose;
160 | ///
161 | /// Do not ask for confirmation.
162 | ///
163 | property DoNotAskForConfirmation: boolean read FDoNotAskForConfirmation write FDoNotAskForConfirmation default false;
164 | end;
165 |
166 | implementation
167 |
168 | { TPyPackageManagerDefsUninstallOptsConda }
169 |
170 | constructor TPyPackageManagerDefsOptsCondaUninstall.Create;
171 | begin
172 | FRepoData := TStringList.Create();
173 | FVerbose := TStringList.Create();
174 | end;
175 |
176 | destructor TPyPackageManagerDefsOptsCondaUninstall.Destroy;
177 | begin
178 | FVerbose.Free();
179 | FRepoData.Free();
180 | inherited;
181 | end;
182 |
183 | procedure TPyPackageManagerDefsOptsCondaUninstall.SetVerbose(
184 | const Value: TStrings);
185 | begin
186 | FVerbose.Assign(Value);
187 | end;
188 |
189 | end.
190 |
--------------------------------------------------------------------------------
/src/Manager/Defs/Opts/Conda/PyPackage.Manager.Defs.Opts.Conda.Create.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Defs.Opts.Conda.Create' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Defs.Opts layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Defs.Opts.Conda.Create;
32 |
33 | interface
34 |
35 | uses
36 | System.Classes,
37 | PyPackage.Manager.Defs.Opts;
38 |
39 | type
40 | TPyPackageManagerDefsCreateOptsConda = class(TPyPackageManagerDefsOpts)
41 | private
42 | FClone: string;
43 | FFiles: TStrings;
44 | FName: string;
45 | FPrefix: string;
46 | FChannel: string;
47 | FUseLocal: boolean;
48 | FOverrideChannels: boolean;
49 | FRepoData: string;
50 | FStrictChannelPriority: boolean;
51 | FNoChannelPriority: boolean;
52 | FNoDeps: boolean;
53 | FOnlyDeps: boolean;
54 | FNoPin: boolean;
55 | FNoDefaultPackages: boolean;
56 | FExperimentalSolver: string;
57 | FCopy: boolean;
58 | FUseIndexCache: boolean;
59 | FInsecure: boolean;
60 | FOffline: boolean;
61 | FDryRun: boolean;
62 | FJson: boolean;
63 | FQuiet: boolean;
64 | FVerbose: TStrings;
65 | FDoNotAskForConfirmation: boolean;
66 | FDownloadOnly: boolean;
67 | FShowChannelUrls: boolean;
68 | procedure SetFiles(const Value: TStrings);
69 | procedure SetVerbose(const Value: TStrings);
70 | public
71 | constructor Create();
72 | destructor Destroy(); override;
73 | published
74 | {***** Named Arguments *****}
75 |
76 | ///
77 | /// Path to (or name of) existing local environment.
78 | ///
79 | property Clone: string read FClone write FClone;
80 | ///
81 | /// Read package versions from the given file. Repeated file specifications can be passed (e.g. --file=file1 --file=file2).
82 | ///
83 | property Files: TStrings read FFiles write SetFiles;
84 |
85 | {***** Target Environment Specification *****}
86 |
87 | ///
88 | /// Name of environment.
89 | ///
90 | property Name: string read FName write FName;
91 | ///
92 | /// Full path to environment location (i.e. prefix).
93 | ///
94 | property Prefix: string read FPrefix write FPrefix;
95 |
96 | {***** Channel Customization *****}
97 |
98 | ///
99 | /// Additional channel to search for packages. These are URLs searched in the order
100 | /// they are given (including local directories using the 'file://' syntax or simply
101 | /// a path like '/home/conda/mychan' or '../mychan'). Then, the defaults or channels
102 | /// from .condarc are searched (unless --override-channels is given). You can use 'defaults'
103 | /// to get the default packages for conda. You can also use any name and the .condarc channel_alias
104 | //// value will be prepended. The default channel_alias is https://conda.anaconda.org/.
105 | ///
106 | property Channel: string read FChannel write FChannel;
107 | ///
108 | /// Use locally built packages. Identical to '-c local'.
109 | ///
110 | property UseLocal: boolean read FUseLocal write FUseLocal default false;
111 | ///
112 | /// Do not search default or .condarc channels. Requires --channel.
113 | ///
114 | property OverrideChannels: boolean read FOverrideChannels write FOverrideChannels;
115 | ///
116 | /// Specify name of repodata on remote server. Conda will try whatever you specify,
117 | /// but will ultimately fall back to repodata.json if your specs are not satisfiable
118 | /// with what you specify here. This is used to employ repodata that is reduced in time scope.
119 | /// You may pass this flag more than once. Leftmost entries are tried first, and the fallback
120 | /// to repodata.json is added for you automatically.
121 | ///
122 | property RepoData: string read FRepoData write FRepoData;
123 |
124 | {***** Solver Mode Modifiers *****}
125 |
126 | ///
127 | /// Packages in lower priority channels are not considered if a package with the same name appears in a higher priority channel.
128 | ///
129 | property StrictChannelPriority: boolean read FStrictChannelPriority write FStrictChannelPriority default false;
130 | ///
131 | /// Package version takes precedence over channel priority. Overrides the value given by conda config --show channel_priority.
132 | ///
133 | property NoChannelPriority: boolean read FNoChannelPriority write FNoChannelPriority default false;
134 | ///
135 | /// Do not install, update, remove, or change dependencies. This WILL lead to broken environments and inconsistent behavior. Use at your own risk.
136 | ///
137 | property NoDeps: boolean read FNoDeps write FNoDeps default false;
138 | ///
139 | /// Only install dependencies.
140 | ///
141 | property OnlyDeps: boolean read FOnlyDeps write FOnlyDeps default false;
142 | ///
143 | /// Ignore pinned file.
144 | ///
145 | property NoPin: boolean read FNoPin write FNoPin default false;
146 | ///
147 | /// Ignore create_default_packages in the .condarc file.
148 | ///
149 | property NoDefaultPackages: boolean read FNoDefaultPackages write FNoDefaultPackages default false;
150 | ///
151 | /// Possible choices: classic, libmamba, libmamba-draft EXPERIMENTAL. Choose which solver backend to use.
152 | ///
153 | property ExperimentalSolver: string read FExperimentalSolver write FExperimentalSolver;
154 |
155 | {***** Package Linking and Install-time Options *****}
156 |
157 | ///
158 | /// Install all packages using copies instead of hard- or soft-linking.
159 | ///
160 | property Copy: boolean read FCopy write FCopy default false;
161 |
162 | {***** Networking Options *****}
163 |
164 | ///
165 | /// Use cache of channel index files, even if it has expired.
166 | ///
167 | property UseIndexCache: boolean read FUseIndexCache write FUseIndexCache default false;
168 | ///
169 | /// Allow conda to perform "insecure" SSL connections and transfers. Equivalent to setting 'ssl_verify' to 'false'.
170 | ///
171 | property Insecure: boolean read FInsecure write FInsecure default false;
172 | ///
173 | /// Offline mode. Don't connect to the Internet.
174 | ///
175 | property Offline: boolean read FOffline write FOffline default false;
176 |
177 | {***** Output, Prompt, and Flow Control Options *****}
178 |
179 | ///
180 | /// Only display what would have been done.
181 | ///
182 | property DryRun: boolean read FDryRun write FDryRun default false;
183 | ///
184 | /// Report all output as json. Suitable for using conda programmati-cally.
185 | ///
186 | property Json: boolean read FJson write FJson default false;
187 | ///
188 | /// Do not display progress bar.
189 | ///
190 | property Quiet: boolean read FQuiet write FQuiet default false;
191 | ///
192 | /// Use once for info, twice for debug, three times for trace.
193 | ///
194 | property Verbose: TStrings read FVerbose write SetVerbose;
195 | ///
196 | /// Do not ask for confirmation.
197 | ///
198 | property DoNotAskForConfirmation: boolean read FDoNotAskForConfirmation write FDoNotAskForConfirmation default false;
199 | ///
200 | /// Solve an environment and ensure package caches are populated,
201 | /// but exit prior to unlinking and linking packages into the pre-fix.
202 | ///
203 | property DownloadOnly: boolean read FDownloadOnly write FDownloadOnly default false;
204 | ///
205 | /// Show channel urls. Overrides the value given by `conda config --show show_channel_urls`.
206 | ///
207 | property ShowChannelUrls: boolean read FShowChannelUrls write FShowChannelUrls default false;
208 | end;
209 |
210 | implementation
211 |
212 | { TPyPackageManagerDefsCreateOptsConda }
213 |
214 | constructor TPyPackageManagerDefsCreateOptsConda.Create;
215 | begin
216 | FFiles := TStringList.Create();
217 | FVerbose := TStringList.Create();
218 | end;
219 |
220 | destructor TPyPackageManagerDefsCreateOptsConda.Destroy;
221 | begin
222 | FVerbose.Free();
223 | FFiles.Free();
224 | inherited;
225 | end;
226 |
227 | procedure TPyPackageManagerDefsCreateOptsConda.SetFiles(const Value: TStrings);
228 | begin
229 | FFiles.Assign(Value);
230 | end;
231 |
232 | procedure TPyPackageManagerDefsCreateOptsConda.SetVerbose(
233 | const Value: TStrings);
234 | begin
235 | FVerbose := Value;
236 | end;
237 |
238 | end.
239 |
--------------------------------------------------------------------------------
/src/Manager/Cmd/Conda/PyPackage.Manager.Cmd.Conda.Install.pas:
--------------------------------------------------------------------------------
1 | (**************************************************************************)
2 | (* *)
3 | (* Module: Unit 'PyPackage.Manager.Cmd.Conda.Install' *)
4 | (* *)
5 | (* Copyright (c) 2021 *)
6 | (* Lucas Moura Belo - lmbelo *)
7 | (* lucas.belo@live.com *)
8 | (* Brazil *)
9 | (* *)
10 | (* Project page: https://github.com/lmbelo/P4D_AI_ML *)
11 | (**************************************************************************)
12 | (* Functionality: PyPackage Cmd layer *)
13 | (* *)
14 | (* *)
15 | (**************************************************************************)
16 | (* This source code is distributed with no WARRANTY, for no reason or use.*)
17 | (* Everyone is allowed to use and change this code free for his own tasks *)
18 | (* and projects, as long as this header and its copyright text is intact. *)
19 | (* For changed versions of this code, which are public distributed the *)
20 | (* following additional conditions have to be fullfilled: *)
21 | (* 1) The header has to contain a comment on the change and the author of *)
22 | (* it. *)
23 | (* 2) A copy of the changed source has to be sent to the above E-Mail *)
24 | (* address or my then valid address, if this is possible to the *)
25 | (* author. *)
26 | (* The second condition has the target to maintain an up to date central *)
27 | (* version of the component. If this condition is not acceptable for *)
28 | (* confidential or legal reasons, everyone is free to derive a component *)
29 | (* or to generate a diff file to my or other original sources. *)
30 | (**************************************************************************)
31 | unit PyPackage.Manager.Cmd.Conda.Install;
32 |
33 | interface
34 |
35 | uses
36 | System.SysUtils, System.Classes, System.Generics.Collections,
37 | PyPackage.Manager.Defs.Opts.Conda.Install;
38 |
39 | type
40 | TPyPackageManagerCmdCondaInstall = class
41 | private
42 | FOpts: TPyPackageManagerDefsOptsCondaInstall;
43 | public
44 | constructor Create(const ADefs: TPyPackageManagerDefsOptsCondaInstall);
45 |
46 | function MakeInstallRevisionCmd: TArray; inline;
47 | function MakeInstallFileCmd: TArray; inline;
48 | function MakeInstallNameCmd: TArray; inline;
49 | function MakeInstallPrefixCmd: TArray; inline;
50 | function MakeInstallChannelCmd: TArray; inline;
51 | function MakeInstallUseLocalCmd: TArray; inline;
52 | function MakeInstallOverrideChannelsCmd: TArray; inline;
53 | function MakeInstallRepoDataCmd: TArray; inline;
54 | function MakeInstallStrictChannelPriorityCmd: TArray; inline;
55 | function MakeInstallNoChannelPriorityCmd: TArray; inline;
56 | function MakeInstallNoDepsCmd: TArray; inline;
57 | function MakeInstallOnlyDepsCmd: TArray; inline;
58 | function MakeInstallNoPinCmd: TArray; inline;
59 | function MakeInstallExperimentalSolverCmd: TArray; inline;
60 | function MakeInstallForceReinstallCmd: TArray; inline;
61 | function MakeInstallNoUpdateDepsCmd: TArray; inline;
62 | function MakeInstallUpdateDepsCmd: TArray; inline;
63 | function MakeInstallSatisfiedSkipSolveCmd: TArray; inline;
64 | function MakeInstallUpdateAllCmd: TArray; inline;
65 | function MakeInstallUpdateSpecsCmd: TArray; inline;
66 | function MakeInstallCopyCmd: TArray; inline;
67 | function MakeInstallMkDirCmd: TArray; inline;
68 | function MakeInstallClobberCmd: TArray; inline;
69 | function MakeInstallUseIndexCacheCmd: TArray; inline;
70 | function MakeInstallInsecureCmd: TArray; inline;
71 | function MakeInstallOfflineCmd: TArray; inline;
72 | function MakeInstallDryRunCmd: TArray; inline;
73 | function MakeInstallJsonCmd: TArray; inline;
74 | function MakeInstallQuietCmd: TArray; inline;
75 | function MakeInstallVerboseCmd: TArray; inline;
76 | function MakeInstallDoNotAskForConfirmationCmd: TArray; inline;
77 | function MakeInstallDownloadOnlyCmd: TArray; inline;
78 | function MakeInstallShowChannelUrlsCmd: TArray; inline;
79 | end;
80 |
81 | implementation
82 |
83 | constructor TPyPackageManagerCmdCondaInstall.Create(
84 | const ADefs: TPyPackageManagerDefsOptsCondaInstall);
85 | begin
86 | FOpts := ADefs;
87 | end;
88 |
89 | function TPyPackageManagerCmdCondaInstall.MakeInstallChannelCmd: TArray;
90 | begin
91 | if not FOpts.Channel.IsEmpty() then
92 | Result := TArray.Create('--channel', FOpts.Channel);
93 | end;
94 |
95 | function TPyPackageManagerCmdCondaInstall.MakeInstallClobberCmd: TArray;
96 | begin
97 | if FOpts.Clobber then
98 | Result := TArray.Create('--clobber');
99 | end;
100 |
101 | function TPyPackageManagerCmdCondaInstall.MakeInstallCopyCmd: TArray;
102 | begin
103 | if FOpts.Copy then
104 | Result := TArray.Create('--copy');
105 | end;
106 |
107 | function TPyPackageManagerCmdCondaInstall.MakeInstallDoNotAskForConfirmationCmd: TArray;
108 | begin
109 | if FOpts.DoNotAskForConfirmation then
110 | Result := TArray.Create('--yes');
111 | end;
112 |
113 | function TPyPackageManagerCmdCondaInstall.MakeInstallDownloadOnlyCmd: TArray;
114 | begin
115 | if FOpts.DownloadOnly then
116 | Result := TArray.Create('--download-only');
117 | end;
118 |
119 | function TPyPackageManagerCmdCondaInstall.MakeInstallDryRunCmd: TArray;
120 | begin
121 | if FOpts.DryRun then
122 | Result := TArray.Create('--dry-run');
123 | end;
124 |
125 | function TPyPackageManagerCmdCondaInstall.MakeInstallExperimentalSolverCmd: TArray;
126 | begin
127 | if not FOpts.ExperimentalSolver.IsEmpty() then
128 | Result := TArray.Create('--experimental-solver', FOpts.ExperimentalSolver);
129 | end;
130 |
131 | function TPyPackageManagerCmdCondaInstall.MakeInstallFileCmd: TArray;
132 | var
133 | LList: TList;
134 | LStr: string;
135 | begin
136 | LList := TList.Create();
137 | try
138 | for LStr in FOpts.Files do
139 | LList.Add('--file=' + LStr);
140 | Result := LList.ToArray();
141 | finally
142 | LList.Free();
143 | end;
144 | end;
145 |
146 | function TPyPackageManagerCmdCondaInstall.MakeInstallForceReinstallCmd: TArray;
147 | begin
148 | if FOpts.ForceReinstall then
149 | Result := TArray.Create('--force-reinstall');
150 | end;
151 |
152 | function TPyPackageManagerCmdCondaInstall.MakeInstallNoUpdateDepsCmd: TArray;
153 | begin
154 | if FOpts.NoUpdateDeps then
155 | Result := TArray.Create('--no-update-deps');
156 | end;
157 |
158 | function TPyPackageManagerCmdCondaInstall.MakeInstallInsecureCmd: TArray;
159 | begin
160 | if FOpts.Insecure then
161 | Result := TArray.Create('--insecure');
162 | end;
163 |
164 | function TPyPackageManagerCmdCondaInstall.MakeInstallJsonCmd: TArray;
165 | begin
166 | if FOpts.Json then
167 | Result := TArray.Create('--json');
168 | end;
169 |
170 | function TPyPackageManagerCmdCondaInstall.MakeInstallMkDirCmd: TArray;
171 | begin
172 | if FOpts.MkDir then
173 | Result := TArray.Create('--mkdir');
174 | end;
175 |
176 | function TPyPackageManagerCmdCondaInstall.MakeInstallNameCmd: TArray;
177 | begin
178 | if not FOpts.Name.IsEmpty() then
179 | Result := TArray