Kephas.Scripting.Python 11.1.0-dev.4

Prefix Reserved
This is a prerelease version of Kephas.Scripting.Python.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Kephas.Scripting.Python --version 11.1.0-dev.4
                    
NuGet\Install-Package Kephas.Scripting.Python -Version 11.1.0-dev.4
                    
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-dev.4" />
                    
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-dev.4" />
                    
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-dev.4
                    
#r "nuget: Kephas.Scripting.Python, 11.1.0-dev.4"
                    
#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.
#addin nuget:?package=Kephas.Scripting.Python&version=11.1.0-dev.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Kephas.Scripting.Python&version=11.1.0-dev.4&prerelease
                    
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 800 4/13/2022
11.1.0-dev.4 188 4/6/2022
11.1.0-dev.3 183 3/30/2022
11.1.0-dev.2 186 3/23/2022
11.1.0-dev.1 181 3/23/2022
11.0.0 544 3/11/2022
11.0.0-dev.7 193 3/7/2022
11.0.0-dev.6 183 2/28/2022
11.0.0-dev.5 183 2/26/2022
11.0.0-dev.4 183 2/24/2022
11.0.0-dev.3 181 2/23/2022
11.0.0-dev.2 189 2/18/2022
11.0.0-dev.1 186 2/7/2022
10.3.0 557 1/18/2022
10.2.0 927 12/3/2021
10.1.0 4,989 11/23/2021
10.1.0-dev.7 245 11/17/2021
10.1.0-dev.6 218 11/16/2021
10.1.0-dev.5 234 11/10/2021
10.1.0-dev.4 217 11/8/2021
10.1.0-dev.3 212 11/8/2021
10.1.0-dev.2 221 11/4/2021
10.1.0-dev.1 218 11/3/2021
10.0.1 492 10/16/2021
10.0.0 454 10/13/2021
10.0.0-dev.4 217 10/13/2021
10.0.0-dev.3 239 10/11/2021
10.0.0-dev.2 274 10/8/2021
9.3.4 505 8/25/2021
9.3.3 453 8/25/2021
9.3.2 445 8/24/2021
9.3.1 438 8/12/2021
9.3.0 461 8/12/2021
9.2.0 484 6/17/2021
9.1.0 468 6/17/2021
9.1.0-dev.8 247 5/26/2021
9.1.0-dev.7 248 5/17/2021
9.1.0-dev.6 252 4/28/2021
9.1.0-dev.5 265 4/23/2021
9.1.0-dev.4 250 4/21/2021
9.1.0-dev.3 261 4/17/2021
9.1.0-dev.2 238 4/12/2021
9.1.0-dev.1 254 4/9/2021
9.0.5 450 3/31/2021
9.0.4 488 3/23/2021
9.0.3 505 3/20/2021
9.0.1 457 3/18/2021
9.0.0 457 3/17/2021
9.0.0-dev.4 257 3/4/2021
9.0.0-dev.3 264 3/1/2021
9.0.0-dev.2 291 2/22/2021
8.4.0 558 11/11/2020
8.3.0 554 10/28/2020
8.2.0 608 10/16/2020
8.1.0 659 9/23/2020
8.0.0 574 7/1/2020
8.0.0-dev.44 382 6/25/2020
8.0.0-dev.43 353 6/23/2020
8.0.0-dev.42 391 6/22/2020
8.0.0-dev.41 381 6/18/2020
8.0.0-dev.40 348 6/18/2020
8.0.0-dev.39 362 6/15/2020
8.0.0-dev.38 475 6/14/2020
8.0.0-dev.37 340 6/13/2020
8.0.0-dev.36 387 6/13/2020
8.0.0-dev.35 317 6/12/2020
8.0.0-dev.34 362 6/12/2020
8.0.0-dev.33 410 6/10/2020
8.0.0-dev.32 337 6/1/2020
8.0.0-dev.31 373 6/1/2020
8.0.0-dev.30 429 5/30/2020
8.0.0-dev.28 383 5/28/2020
8.0.0-dev.27 346 5/15/2020
8.0.0-dev.26 334 5/14/2020
8.0.0-dev.25 362 5/14/2020
8.0.0-dev.24 342 5/13/2020
8.0.0-dev.23 349 5/13/2020
8.0.0-dev.22 342 5/13/2020
8.0.0-dev.21 344 5/12/2020
8.0.0-dev.20 356 5/12/2020
8.0.0-dev.19 354 5/7/2020
8.0.0-dev.18 356 5/7/2020
8.0.0-dev.17 350 5/6/2020
8.0.0-dev.16 345 5/6/2020
8.0.0-dev.15 358 5/5/2020
8.0.0-dev.14 335 5/5/2020
8.0.0-dev.13 363 5/4/2020
7.6.0-dev.13 374 5/1/2020
7.6.0-dev.12 387 4/30/2020
7.6.0-dev.11 353 4/28/2020
7.6.0-dev.10 343 4/27/2020
7.6.0-dev.9 354 4/24/2020
7.6.0-dev.8 356 4/22/2020
7.6.0-dev.7 335 4/15/2020
7.6.0-dev.6 335 4/15/2020
7.6.0-dev.5 342 4/15/2020
7.6.0-dev.4 469 4/11/2020
7.6.0-dev.3 326 4/10/2020
7.6.0-dev.2 333 4/10/2020
7.6.0-dev.1 426 4/8/2020
7.5.2 665 3/20/2020
7.5.1 612 3/12/2020
7.5.0 619 3/10/2020
7.5.0-dev.18 372 3/5/2020
7.5.0-dev.17 366 3/5/2020
7.5.0-dev.16 389 3/4/2020
7.5.0-dev.15 341 3/3/2020
7.5.0-dev.14 351 3/3/2020
7.5.0-dev.13 330 2/29/2020
7.5.0-dev.12 462 2/29/2020
7.5.0-dev.10 443 2/25/2020
7.5.0-dev.9 369 2/20/2020
7.5.0-dev.8 399 2/18/2020
7.5.0-dev.7 332 2/18/2020
7.5.0-dev.6 357 2/14/2020
7.5.0-dev.5 389 2/12/2020
7.5.0-dev.4 341 2/11/2020
7.5.0-dev.3 315 2/11/2020
7.5.0-dev.2 470 2/8/2020
7.5.0-dev.1 363 2/7/2020
7.4.2 579 2/5/2020
7.4.1 641 2/3/2020
7.4.0 685 1/31/2020
7.4.0-dev.4 416 1/31/2020
7.4.0-dev.3 388 1/29/2020
7.4.0-dev.2 352 1/28/2020
7.3.1 652 1/21/2020
7.3.1-preview.7 339 1/21/2020
7.3.1-preview.1 377 1/20/2020
7.3.0 585 1/19/2020
7.2.6 639 1/18/2020
7.2.5 642 12/19/2019
7.2.4 604 12/19/2019
7.2.3 630 12/16/2019
7.2.2 615 12/9/2019
7.2.1 635 12/4/2019
7.2.0 616 11/26/2019
7.2.0-preview.10 340 11/20/2019
7.2.0-preview.9 345 11/19/2019
7.2.0-preview.8 342 11/18/2019
7.2.0-preview.6 367 11/14/2019
7.2.0-preview.5 347 11/14/2019
7.2.0-preview.4 345 11/14/2019
7.2.0-preview.2 354 11/11/2019
7.2.0-preview.1 343 11/9/2019
7.1.0 638 11/6/2019
7.1.0-preview.8 365 11/5/2019
7.1.0-preview.7 346 11/4/2019
7.1.0-preview.6 362 11/1/2019
7.1.0-preview.5 367 10/31/2019
7.1.0-preview.4 380 10/30/2019
7.1.0-preview.3 348 10/26/2019
7.1.0-preview.2 367 10/25/2019
7.1.0-preview.1 347 10/24/2019
7.0.0 670 10/16/2019
7.0.0-rc.41 361 10/15/2019
7.0.0-rc.40 373 10/15/2019
7.0.0-rc.39 370 10/12/2019
7.0.0-rc.38 360 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.