Kephas.Scripting.Python 11.1.0

Prefix Reserved
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.
<PackageVersion Include="Kephas.Scripting.Python" Version="11.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Kephas.Scripting.Python" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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 and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kephas.Scripting.Python@11.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kephas.Scripting.Python&version=11.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Kephas.Scripting.Python&version=11.1.0
                    
Install as a Cake Tool

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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 913 4/13/2022
11.1.0-dev.4 243 4/6/2022
11.1.0-dev.3 246 3/30/2022
11.1.0-dev.2 232 3/23/2022
11.1.0-dev.1 244 3/23/2022
11.0.0 634 3/11/2022
11.0.0-dev.7 239 3/7/2022
11.0.0-dev.6 250 2/28/2022
11.0.0-dev.5 251 2/26/2022
11.0.0-dev.4 243 2/24/2022
11.0.0-dev.3 227 2/23/2022
11.0.0-dev.2 235 2/18/2022
11.0.0-dev.1 259 2/7/2022
10.3.0 619 1/18/2022
10.2.0 994 12/3/2021
10.1.0 5,048 11/23/2021
10.1.0-dev.7 297 11/17/2021
10.1.0-dev.6 268 11/16/2021
10.1.0-dev.5 296 11/10/2021
10.1.0-dev.4 280 11/8/2021
10.1.0-dev.3 281 11/8/2021
10.1.0-dev.2 270 11/4/2021
10.1.0-dev.1 271 11/3/2021
10.0.1 560 10/16/2021
10.0.0 526 10/13/2021
10.0.0-dev.4 272 10/13/2021
10.0.0-dev.3 309 10/11/2021
10.0.0-dev.2 326 10/8/2021
9.3.4 586 8/25/2021
9.3.3 538 8/25/2021
9.3.2 525 8/24/2021
9.3.1 497 8/12/2021
9.3.0 554 8/12/2021
9.2.0 555 6/17/2021
9.1.0 528 6/17/2021
9.1.0-dev.8 295 5/26/2021
9.1.0-dev.7 313 5/17/2021
9.1.0-dev.6 317 4/28/2021
9.1.0-dev.5 333 4/23/2021
9.1.0-dev.4 299 4/21/2021
9.1.0-dev.3 326 4/17/2021
9.1.0-dev.2 291 4/12/2021
9.1.0-dev.1 307 4/9/2021
9.0.5 526 3/31/2021
9.0.4 575 3/23/2021
9.0.3 563 3/20/2021
9.0.1 558 3/18/2021
9.0.0 544 3/17/2021
9.0.0-dev.4 323 3/4/2021
9.0.0-dev.3 318 3/1/2021
9.0.0-dev.2 365 2/22/2021
8.4.0 657 11/11/2020
8.3.0 643 10/28/2020
8.2.0 700 10/16/2020
8.1.0 737 9/23/2020
8.0.0 649 7/1/2020
8.0.0-dev.44 454 6/25/2020
8.0.0-dev.43 412 6/23/2020
8.0.0-dev.42 473 6/22/2020
8.0.0-dev.41 454 6/18/2020
8.0.0-dev.40 403 6/18/2020
8.0.0-dev.39 417 6/15/2020
8.0.0-dev.38 530 6/14/2020
8.0.0-dev.37 401 6/13/2020
8.0.0-dev.36 442 6/13/2020
8.0.0-dev.35 375 6/12/2020
8.0.0-dev.34 436 6/12/2020
8.0.0-dev.33 467 6/10/2020
8.0.0-dev.32 389 6/1/2020
8.0.0-dev.31 426 6/1/2020
8.0.0-dev.30 486 5/30/2020
8.0.0-dev.28 436 5/28/2020
8.0.0-dev.27 401 5/15/2020
8.0.0-dev.26 402 5/14/2020
8.0.0-dev.25 421 5/14/2020
8.0.0-dev.24 423 5/13/2020
8.0.0-dev.23 418 5/13/2020
8.0.0-dev.22 394 5/13/2020
8.0.0-dev.21 402 5/12/2020
8.0.0-dev.20 412 5/12/2020
8.0.0-dev.19 409 5/7/2020
8.0.0-dev.18 409 5/7/2020
8.0.0-dev.17 424 5/6/2020
8.0.0-dev.16 399 5/6/2020
8.0.0-dev.15 413 5/5/2020
8.0.0-dev.14 389 5/5/2020
8.0.0-dev.13 419 5/4/2020
7.6.0-dev.13 428 5/1/2020
7.6.0-dev.12 444 4/30/2020
7.6.0-dev.11 430 4/28/2020
7.6.0-dev.10 393 4/27/2020
7.6.0-dev.9 408 4/24/2020
7.6.0-dev.8 414 4/22/2020
7.6.0-dev.7 390 4/15/2020
7.6.0-dev.6 407 4/15/2020
7.6.0-dev.5 399 4/15/2020
7.6.0-dev.4 523 4/11/2020
7.6.0-dev.3 383 4/10/2020
7.6.0-dev.2 386 4/10/2020
7.6.0-dev.1 485 4/8/2020
7.5.2 759 3/20/2020
7.5.1 687 3/12/2020
7.5.0 711 3/10/2020
7.5.0-dev.18 429 3/5/2020
7.5.0-dev.17 436 3/5/2020
7.5.0-dev.16 444 3/4/2020
7.5.0-dev.15 397 3/3/2020
7.5.0-dev.14 423 3/3/2020
7.5.0-dev.13 396 2/29/2020
7.5.0-dev.12 532 2/29/2020
7.5.0-dev.10 500 2/25/2020
7.5.0-dev.9 421 2/20/2020
7.5.0-dev.8 453 2/18/2020
7.5.0-dev.7 387 2/18/2020
7.5.0-dev.6 423 2/14/2020
7.5.0-dev.5 442 2/12/2020
7.5.0-dev.4 397 2/11/2020
7.5.0-dev.3 373 2/11/2020
7.5.0-dev.2 553 2/8/2020
7.5.0-dev.1 419 2/7/2020
7.4.2 689 2/5/2020
7.4.1 730 2/3/2020
7.4.0 783 1/31/2020
7.4.0-dev.4 486 1/31/2020
7.4.0-dev.3 457 1/29/2020
7.4.0-dev.2 408 1/28/2020
7.3.1 728 1/21/2020
7.3.1-preview.7 395 1/21/2020
7.3.1-preview.1 453 1/20/2020
7.3.0 653 1/19/2020
7.2.6 733 1/18/2020
7.2.5 738 12/19/2019
7.2.4 669 12/19/2019
7.2.3 739 12/16/2019
7.2.2 697 12/9/2019
7.2.1 709 12/4/2019
7.2.0 682 11/26/2019
7.2.0-preview.10 413 11/20/2019
7.2.0-preview.9 402 11/19/2019
7.2.0-preview.8 413 11/18/2019
7.2.0-preview.6 443 11/14/2019
7.2.0-preview.5 402 11/14/2019
7.2.0-preview.4 418 11/14/2019
7.2.0-preview.2 410 11/11/2019
7.2.0-preview.1 398 11/9/2019
7.1.0 710 11/6/2019
7.1.0-preview.8 421 11/5/2019
7.1.0-preview.7 423 11/4/2019
7.1.0-preview.6 419 11/1/2019
7.1.0-preview.5 422 10/31/2019
7.1.0-preview.4 454 10/30/2019
7.1.0-preview.3 432 10/26/2019
7.1.0-preview.2 438 10/25/2019
7.1.0-preview.1 419 10/24/2019
7.0.0 734 10/16/2019
7.0.0-rc.41 428 10/15/2019
7.0.0-rc.40 428 10/15/2019
7.0.0-rc.39 427 10/12/2019
7.0.0-rc.38 412 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.