Kephas.Scripting.Python 11.1.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
.NET 6.0 .NET Standard 2.1
dotnet add package Kephas.Scripting.Python --version 11.1.0
NuGet\Install-Package Kephas.Scripting.Python -Version 11.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kephas.Scripting.Python" Version="11.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kephas.Scripting.Python --version 11.1.0
#r "nuget: Kephas.Scripting.Python, 11.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Kephas.Scripting.Python as a Cake Addin
#addin nuget:?package=Kephas.Scripting.Python&version=11.1.0

// Install Kephas.Scripting.Python as a Cake Tool
#tool nuget:?package=Kephas.Scripting.Python&version=11.1.0

Python Scripting

Introduction

The Python scripting area in Kephas handles Python dynamic code execution using IronPython.

Check the following packages for more information:

Usage

  • String based script execution
// normally you would get the processor injected into the service constructor.
var processor = injector.Resolve<IScriptProcessor>();
var result = await processor.ExecuteAsync(new PythonStringScript("name[..4] + str(age)"), new Expando { ["name"] = "Johnny", ["age"] = 42 })).PreserveThreadContext();
Assert.Equals("John42", result);
  • File based script execution

The file scripts assume that the language can be inferred from the file extension. For Python, it means that the file needs to and with a *.py extension. If this is not the case, make sure you specify the language explicitly when creating a FileScript.

// normally you would get the processor injected into the service constructor.
var processor = injector.Resolve<IScriptProcessor>();

// Python scripts ending with *.py
var result = await processor.ExecuteAsync(new FileScript("myscript.py"), new { name = "Johnny", age = 42 })).PreserveThreadContext();
Assert.Equals("John42", result);

// Python scripts not ending with *.py
var result = await processor.ExecuteAsync(new FileScript("myscript.txt", PythonLanguageService.Language), new { name = "Johnny", age = 42 })).PreserveThreadContext();
Assert.Equals("John42", result);

The PythonLanguageService

This service is the ILanguageService implementation for the Python language. It uses the PythonSettings to configure the way it controls the execution. These are the options:

  • SearchPaths (string[]): enumerates the paths where the Python modules should be searched.
  • PreloadGlobalModules (boolean): Indicates whether the modules found in the search paths should be preloaded for the executing scripts. This way, the scripts would be simpler to write, but the resource consumption could be greater.

Note: The search paths are locations handled by the ILocationsManager service. When adding tenant support, each tenant will get its own copy.

Configuration file example:

{
    "searchPaths": [ "../config/.pylib" ],
    "preloadGlobalModules": true
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
11.1.0 217 4/13/2022
11.1.0-dev.4 75 4/6/2022
11.1.0-dev.3 63 3/30/2022
11.1.0-dev.2 70 3/23/2022
11.1.0-dev.1 64 3/23/2022
11.0.0 179 3/11/2022
11.0.0-dev.7 72 3/7/2022
11.0.0-dev.6 62 2/28/2022
11.0.0-dev.5 58 2/26/2022
11.0.0-dev.4 66 2/24/2022
11.0.0-dev.3 66 2/23/2022
11.0.0-dev.2 63 2/18/2022
11.0.0-dev.1 70 2/7/2022
10.3.0 187 1/18/2022
10.2.0 682 12/3/2021
10.1.0 4,746 11/23/2021
10.1.0-dev.7 130 11/17/2021
10.1.0-dev.6 102 11/16/2021
10.1.0-dev.5 105 11/10/2021
10.1.0-dev.4 103 11/8/2021
10.1.0-dev.3 86 11/8/2021
10.1.0-dev.2 102 11/4/2021
10.1.0-dev.1 104 11/3/2021
10.0.1 249 10/16/2021
10.0.0 218 10/13/2021
10.0.0-dev.4 97 10/13/2021
10.0.0-dev.3 112 10/11/2021
10.0.0-dev.2 161 10/8/2021
9.3.4 239 8/25/2021
9.3.3 207 8/25/2021
9.3.2 204 8/24/2021
9.3.1 207 8/12/2021
9.3.0 219 8/12/2021
9.2.0 241 6/17/2021
9.1.0 249 6/17/2021
9.1.0-dev.8 124 5/26/2021
9.1.0-dev.7 132 5/17/2021
9.1.0-dev.6 119 4/28/2021
9.1.0-dev.5 135 4/23/2021
9.1.0-dev.4 124 4/21/2021
9.1.0-dev.3 129 4/17/2021
9.1.0-dev.2 118 4/12/2021
9.1.0-dev.1 129 4/9/2021
9.0.5 221 3/31/2021
9.0.4 255 3/23/2021
9.0.3 251 3/20/2021
9.0.1 223 3/18/2021
9.0.0 231 3/17/2021
9.0.0-dev.4 124 3/4/2021
9.0.0-dev.3 124 3/1/2021
9.0.0-dev.2 155 2/22/2021
8.4.0 310 11/11/2020
8.3.0 297 10/28/2020
8.2.0 329 10/16/2020
8.1.0 366 9/23/2020
8.0.0 323 7/1/2020
8.0.0-dev.44 226 6/25/2020
8.0.0-dev.43 217 6/23/2020
8.0.0-dev.42 245 6/22/2020
8.0.0-dev.41 240 6/18/2020
8.0.0-dev.40 207 6/18/2020
8.0.0-dev.39 225 6/15/2020
8.0.0-dev.38 334 6/14/2020
8.0.0-dev.37 194 6/13/2020
8.0.0-dev.36 242 6/13/2020
8.0.0-dev.35 184 6/12/2020
8.0.0-dev.34 224 6/12/2020
8.0.0-dev.33 275 6/10/2020
8.0.0-dev.32 201 6/1/2020
8.0.0-dev.31 236 6/1/2020
8.0.0-dev.30 295 5/30/2020
8.0.0-dev.28 238 5/28/2020
8.0.0-dev.27 207 5/15/2020
8.0.0-dev.26 198 5/14/2020
8.0.0-dev.25 217 5/14/2020
8.0.0-dev.24 205 5/13/2020
8.0.0-dev.23 210 5/13/2020
8.0.0-dev.22 208 5/13/2020
8.0.0-dev.21 209 5/12/2020
8.0.0-dev.20 216 5/12/2020
8.0.0-dev.19 214 5/7/2020
8.0.0-dev.18 211 5/7/2020
8.0.0-dev.17 208 5/6/2020
8.0.0-dev.16 206 5/6/2020
8.0.0-dev.15 208 5/5/2020
8.0.0-dev.14 198 5/5/2020
8.0.0-dev.13 227 5/4/2020
7.6.0-dev.13 234 5/1/2020
7.6.0-dev.12 241 4/30/2020
7.6.0-dev.11 212 4/28/2020
7.6.0-dev.10 204 4/27/2020
7.6.0-dev.9 211 4/24/2020
7.6.0-dev.8 209 4/22/2020
7.6.0-dev.7 196 4/15/2020
7.6.0-dev.6 199 4/15/2020
7.6.0-dev.5 190 4/15/2020
7.6.0-dev.4 328 4/11/2020
7.6.0-dev.3 204 4/10/2020
7.6.0-dev.2 196 4/10/2020
7.6.0-dev.1 295 4/8/2020
7.5.2 392 3/20/2020
7.5.1 352 3/12/2020
7.5.0 358 3/10/2020
7.5.0-dev.18 235 3/5/2020
7.5.0-dev.17 239 3/5/2020
7.5.0-dev.16 257 3/4/2020
7.5.0-dev.15 208 3/3/2020
7.5.0-dev.14 219 3/3/2020
7.5.0-dev.13 196 2/29/2020
7.5.0-dev.12 322 2/29/2020
7.5.0-dev.10 310 2/25/2020
7.5.0-dev.9 241 2/20/2020
7.5.0-dev.8 271 2/18/2020
7.5.0-dev.7 206 2/18/2020
7.5.0-dev.6 228 2/14/2020
7.5.0-dev.5 253 2/12/2020
7.5.0-dev.4 214 2/11/2020
7.5.0-dev.3 190 2/11/2020
7.5.0-dev.2 337 2/8/2020
7.5.0-dev.1 225 2/7/2020
7.4.2 330 2/5/2020
7.4.1 410 2/3/2020
7.4.0 430 1/31/2020
7.4.0-dev.4 275 1/31/2020
7.4.0-dev.3 256 1/29/2020
7.4.0-dev.2 206 1/28/2020
7.3.1 426 1/21/2020
7.3.1-preview.7 206 1/21/2020
7.3.1-preview.1 244 1/20/2020
7.3.0 340 1/19/2020
7.2.6 407 1/18/2020
7.2.5 397 12/19/2019
7.2.4 355 12/19/2019
7.2.3 388 12/16/2019
7.2.2 383 12/9/2019
7.2.1 386 12/4/2019
7.2.0 376 11/26/2019
7.2.0-preview.10 215 11/20/2019
7.2.0-preview.9 210 11/19/2019
7.2.0-preview.8 208 11/18/2019
7.2.0-preview.6 218 11/14/2019
7.2.0-preview.5 214 11/14/2019
7.2.0-preview.4 218 11/14/2019
7.2.0-preview.2 218 11/11/2019
7.2.0-preview.1 214 11/9/2019
7.1.0 375 11/6/2019
7.1.0-preview.8 229 11/5/2019
7.1.0-preview.7 217 11/4/2019
7.1.0-preview.6 225 11/1/2019
7.1.0-preview.5 235 10/31/2019
7.1.0-preview.4 244 10/30/2019
7.1.0-preview.3 221 10/26/2019
7.1.0-preview.2 227 10/25/2019
7.1.0-preview.1 218 10/24/2019
7.0.0 393 10/16/2019
7.0.0-rc.41 223 10/15/2019
7.0.0-rc.40 240 10/15/2019
7.0.0-rc.39 225 10/12/2019
7.0.0-rc.38 226 10/11/2019

Please check https://github.com/kephas-software/kephas/releases for the change log.
           Also check the documentation and the samples from https://github.com/kephas-software/kephas/wiki and https://github.com/kephas-software/kephas/tree/master/Samples.