Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a330330

Browse files
authored
Add __version__ (#312)
* Add Version to CLR module Ideally we would implement `__version__` as a property, but this requires `ModuleFunctionAttribute` to work. Since version is being implemented as a function, using `Version()` instead since __version__ is expected to be a property. * Implement __version__ on clr module
1 parent 2b80bec commit a330330

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/runtime/pythonengine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static void Initialize()
165165
Runtime.PyDict_SetItemString(clr_dict, "_extras", module);
166166
foreach (PyObject key in locals.Keys())
167167
{
168-
if (!key.ToString().StartsWith("_"))
168+
if (!key.ToString().StartsWith("_") || key.ToString().Equals("__version__"))
169169
{
170170
PyObject value = locals[key];
171171
Runtime.PyDict_SetItem(clr_dict, key.Handle, value.Handle);

src/runtime/resources/clr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
"""
1+
"""
22
Code in this module gets loaded into the main clr module.
33
"""
44

5+
__version__ = "2.2.0"
6+
57

68
class clrproperty(object):
79
"""

src/tests/test_module.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def test000importClr(self):
4141
import clr
4242
self.assertTrue(self.isCLRRootModule(clr))
4343

44+
def testVersionClr(self):
45+
import clr
46+
self.assertTrue(clr.__version__ >= "2.2.0")
47+
4448
def testPreloadVar(self):
4549
import clr
4650
self.assertTrue(clr.getPreload() is False, clr.getPreload())

0 commit comments

Comments
 (0)