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 974 4/13/2022
11.1.0-dev.4 281 4/6/2022
11.1.0-dev.3 276 3/30/2022
11.1.0-dev.2 261 3/23/2022
11.1.0-dev.1 269 3/23/2022
11.0.0 661 3/11/2022
11.0.0-dev.7 266 3/7/2022
11.0.0-dev.6 289 2/28/2022
11.0.0-dev.5 284 2/26/2022
11.0.0-dev.4 283 2/24/2022
11.0.0-dev.3 259 2/23/2022
11.0.0-dev.2 265 2/18/2022
11.0.0-dev.1 291 2/7/2022
10.3.0 648 1/18/2022
10.2.0 1,034 12/3/2021
10.1.0 5,080 11/23/2021
10.1.0-dev.7 329 11/17/2021
10.1.0-dev.6 301 11/16/2021
10.1.0-dev.5 332 11/10/2021
10.1.0-dev.4 315 11/8/2021
10.1.0-dev.3 317 11/8/2021
10.1.0-dev.2 305 11/4/2021
10.1.0-dev.1 310 11/3/2021
10.0.1 593 10/16/2021
10.0.0 558 10/13/2021
10.0.0-dev.4 302 10/13/2021
10.0.0-dev.3 339 10/11/2021
10.0.0-dev.2 362 10/8/2021
9.3.4 620 8/25/2021
9.3.3 572 8/25/2021
9.3.2 557 8/24/2021
9.3.1 532 8/12/2021
9.3.0 593 8/12/2021
9.2.0 586 6/17/2021
9.1.0 567 6/17/2021
9.1.0-dev.8 323 5/26/2021
9.1.0-dev.7 351 5/17/2021
9.1.0-dev.6 345 4/28/2021
9.1.0-dev.5 359 4/23/2021
9.1.0-dev.4 330 4/21/2021
9.1.0-dev.3 356 4/17/2021
9.1.0-dev.2 323 4/12/2021
9.1.0-dev.1 337 4/9/2021
9.0.5 560 3/31/2021
9.0.4 606 3/23/2021
9.0.3 601 3/20/2021
9.0.1 597 3/18/2021
9.0.0 581 3/17/2021
9.0.0-dev.4 353 3/4/2021
9.0.0-dev.3 355 3/1/2021
9.0.0-dev.2 403 2/22/2021
8.4.0 702 11/11/2020
8.3.0 688 10/28/2020
8.2.0 740 10/16/2020
8.1.0 779 9/23/2020
8.0.0 689 7/1/2020
8.0.0-dev.44 494 6/25/2020
8.0.0-dev.43 452 6/23/2020
8.0.0-dev.42 519 6/22/2020
8.0.0-dev.41 491 6/18/2020
8.0.0-dev.40 440 6/18/2020
8.0.0-dev.39 455 6/15/2020
8.0.0-dev.38 569 6/14/2020
8.0.0-dev.37 438 6/13/2020
8.0.0-dev.36 483 6/13/2020
8.0.0-dev.35 414 6/12/2020
8.0.0-dev.34 481 6/12/2020
8.0.0-dev.33 509 6/10/2020
8.0.0-dev.32 432 6/1/2020
8.0.0-dev.31 461 6/1/2020
8.0.0-dev.30 524 5/30/2020
8.0.0-dev.28 474 5/28/2020
8.0.0-dev.27 443 5/15/2020
8.0.0-dev.26 439 5/14/2020
8.0.0-dev.25 463 5/14/2020
8.0.0-dev.24 465 5/13/2020
8.0.0-dev.23 458 5/13/2020
8.0.0-dev.22 439 5/13/2020
8.0.0-dev.21 440 5/12/2020
8.0.0-dev.20 444 5/12/2020
8.0.0-dev.19 451 5/7/2020
8.0.0-dev.18 454 5/7/2020
8.0.0-dev.17 464 5/6/2020
8.0.0-dev.16 439 5/6/2020
8.0.0-dev.15 448 5/5/2020
8.0.0-dev.14 429 5/5/2020
8.0.0-dev.13 465 5/4/2020
7.6.0-dev.13 473 5/1/2020
7.6.0-dev.12 483 4/30/2020
7.6.0-dev.11 471 4/28/2020
7.6.0-dev.10 432 4/27/2020
7.6.0-dev.9 447 4/24/2020
7.6.0-dev.8 451 4/22/2020
7.6.0-dev.7 426 4/15/2020
7.6.0-dev.6 442 4/15/2020
7.6.0-dev.5 437 4/15/2020
7.6.0-dev.4 563 4/11/2020
7.6.0-dev.3 418 4/10/2020
7.6.0-dev.2 424 4/10/2020
7.6.0-dev.1 525 4/8/2020
7.5.2 798 3/20/2020
7.5.1 726 3/12/2020
7.5.0 751 3/10/2020
7.5.0-dev.18 467 3/5/2020
7.5.0-dev.17 474 3/5/2020
7.5.0-dev.16 483 3/4/2020
7.5.0-dev.15 436 3/3/2020
7.5.0-dev.14 464 3/3/2020
7.5.0-dev.13 439 2/29/2020
7.5.0-dev.12 576 2/29/2020
7.5.0-dev.10 537 2/25/2020
7.5.0-dev.9 458 2/20/2020
7.5.0-dev.8 490 2/18/2020
7.5.0-dev.7 424 2/18/2020
7.5.0-dev.6 463 2/14/2020
7.5.0-dev.5 481 2/12/2020
7.5.0-dev.4 436 2/11/2020
7.5.0-dev.3 409 2/11/2020
7.5.0-dev.2 594 2/8/2020
7.5.0-dev.1 461 2/7/2020
7.4.2 736 2/5/2020
7.4.1 761 2/3/2020
7.4.0 827 1/31/2020
7.4.0-dev.4 522 1/31/2020
7.4.0-dev.3 500 1/29/2020
7.4.0-dev.2 445 1/28/2020
7.3.1 770 1/21/2020
7.3.1-preview.7 432 1/21/2020
7.3.1-preview.1 493 1/20/2020
7.3.0 688 1/19/2020
7.2.6 769 1/18/2020
7.2.5 778 12/19/2019
7.2.4 707 12/19/2019
7.2.3 785 12/16/2019
7.2.2 744 12/9/2019
7.2.1 752 12/4/2019
7.2.0 725 11/26/2019
7.2.0-preview.10 451 11/20/2019
7.2.0-preview.9 441 11/19/2019
7.2.0-preview.8 452 11/18/2019
7.2.0-preview.6 489 11/14/2019
7.2.0-preview.5 442 11/14/2019
7.2.0-preview.4 458 11/14/2019
7.2.0-preview.2 448 11/11/2019
7.2.0-preview.1 440 11/9/2019
7.1.0 755 11/6/2019
7.1.0-preview.8 458 11/5/2019
7.1.0-preview.7 462 11/4/2019
7.1.0-preview.6 456 11/1/2019
7.1.0-preview.5 459 10/31/2019
7.1.0-preview.4 496 10/30/2019
7.1.0-preview.3 471 10/26/2019
7.1.0-preview.2 473 10/25/2019
7.1.0-preview.1 455 10/24/2019
7.0.0 773 10/16/2019
7.0.0-rc.41 463 10/15/2019
7.0.0-rc.40 466 10/15/2019
7.0.0-rc.39 467 10/12/2019
7.0.0-rc.38 453 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.