[Ironpython-users] Fwd: SymPy and IronPython 2.7.4

Pawel Jasinski pawel.jasinski at gmail.com
Wed Apr 9 14:00:17 CEST 2014


---------- Forwarded message ----------
From: Pawel Jasinski <pawel.jasinski at gmail.com>
Date: Wed, Apr 9, 2014 at 1:00 PM
Subject: Re: [Ironpython-users] SymPy and IronPython 2.7.4
To: Andrew Ayre <andy at britishideas.com>


What I did about unicode, is change directly in core/compatibility.py

$ diff -u compatibility.py~ compatibility.py
--- compatibility.py~   2014-02-22 20:13:32.000000000 +0100
+++ compatibility.py    2014-04-07 20:01:04.145668200 +0200
@@ -107,7 +107,8 @@
     unicode = unicode
     unichr = unichr
     def u(x):
-        return codecs.unicode_escape_decode(x)[0]
+        # return codecs.unicode_escape_decode(x)[0]
+        return x
     def u_decode(x):
         return x.decode('utf-8')


I owe you a short explanation.
IronPython is ahead of cpython in terms of unicode. All characters are
unicode character and not a byte characters.
This causes all sort of compatibility issues when cpython modules are
moved to ironpython.
But this days packages are written from day one as 2.x/3.x compatible
and contain compatibility.py or equivalent.
Most of the stuff for 2 vs. 3 can stay as it is, except the characters
conversions.
Usually the first guess is to replace things which fail, with 3.x version.
This is not perfect, but in most cases I had to deal with, is
sufficient to get going.

--pawel

On Wed, Apr 9, 2014 at 11:38 AM, Andrew Ayre <andy at britishideas.com> wrote:
> Hi Pawel,
>
> Sorry to bombard you with emails. This is interesting:
>
> The following works:
>
>  - start my application
>  - run the unicode_escape_decode workaround
>  - import sympy
>
> The following does not work:
>
>   - start my application
>   - import sympy => fails becaue of unicode_escape_decode
>   - run the unicode_escape_decode workaround
>   - import sympy => fails, can't find mpmath
>
> So perhaps the unicode_escape_decode issue and the import issue are
> connected in some way?
>
> Andy
>
> On 4/9/2014 10:32 AM, Andrew Ayre wrote:
>> Hi Pawel,
>>
>> Thanks! In my case I want to bundle it with my application so that my
>> users don't have to install it.
>>
>>  - I have turned on frames in the engine options in C#.
>>
>>  - I have put sympy into the global site-packages.
>>
>>  - I have added the global site-packages to sys.path in C#.
>>
>> Now when I start my application I can run the unicode workaround and
>> then import sympy!
>>
>> Did you also have to use the unicode_escape_decode workaround? Have you
>> any insight into what the problem is there?
>>
>> Andy
>>
>> On 4/9/2014 10:23 AM, Pawel Jasinski wrote:
>>> you can consider installing the package with:
>>>
>>> ipy.exe -X:Frames setup.py install --user
>>>
>>> which in my case put the package in:
>>> c:/Users/rejap/AppData/Roaming/Python/IronPython27/site-packages/sympy
>>> This personal site-packages is in  your sys.path by default.
>>>
>>> --pawel
>>>
>>> On Wed, Apr 9, 2014 at 11:19 AM, Andrew Ayre <andy at britishideas.com> wrote:
>>>> Hi Pawel,
>>>>
>>>> Sorry, please ignore that - I accidentally added the wrong path to sys.path.
>>>>
>>>> Thanks, Andy
>>>>
>>>> On 4/9/2014 10:16 AM, Andrew Ayre wrote:
>>>>> Hi Pawel,
>>>>>
>>>>> OK, I ran the unicode_escape_decode workaround, then I modified
>>>>> __init__.py as shown. However it seems I am back to the original
>>>>> problem. For example:
>>>>>
>>>>>>>> sys.path.append('../../PythonLib/site-packages/sympy/mpmath')
>>>>>
>>>>>>>> import sympy
>>>>>
>>>>> Traceback (most recent call last):
>>>>>   File "<string>", line 1, in <module>
>>>>>   File
>>>>> "C:\Users\Andy\Documents\ADScript\PythonLib\site-packages\sympy\__init__.py",
>>>>> line 32, in <module>
>>>>>   File
>>>>> "C:\Users\Andy\Documents\ADScript\PythonLib\site-packages\sympy\core\__init__.py",
>>>>> line 8, in <module>
>>>>>   File
>>>>> "C:\Users\Andy\Documents\ADScript\PythonLib\site-packages\sympy\core\expr.py",
>>>>> line 7, in <module>
>>>>>   File
>>>>> "C:\Users\Andy\Documents\ADScript\PythonLib\site-packages\sympy\core\evalf.py",
>>>>> line 9, in <module>
>>>>> AttributeError: 'module' object has no attribute 'mpmath'
>>>>>
>>>>> I've manually added the location of mpmath as Jeff suggested. This
>>>>> worked when I tried it before but now it doesn't.
>>>>>
>>>>> Actually the path to mpmath appears twice is sys.path so I assume sympy
>>>>> already added it and there was no need for me to add it.
>>>>>
>>>>>>>> sys.path
>>>>>
>>>>> ['.', 'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\Lib',
>>>>> 'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\DLLs',
>>>>> 'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\PythonLib',
>>>>> '../../PythonLib', '../../PythonLib/site-packages', '../../PythonLib',
>>>>> '../../PythonLib/sympy/mpmath',
>>>>> '../../PythonLib/site-packages/sympy/mpmath']
>>>>>
>>>>> Thanks, Andy
>>>>>
>>>>> On 4/9/2014 10:02 AM, Pawel Jasinski wrote:
>>>>>> Here is the workaround which let me install the package:
>>>>>>
>>>>>> *** sympy/__init__.py.orig      2014-04-09 10:59:53.361779800 +0200
>>>>>> --- sympy/__init__.py   2014-04-09 11:00:02.906734200 +0200
>>>>>> ***************
>>>>>> *** 30,35 ****
>>>>>> --- 30,36 ----
>>>>>>   SYMPY_DEBUG = __sympy_debug()
>>>>>>
>>>>>>   from .core import *
>>>>>> + del sets
>>>>>>   from .logic import *
>>>>>>   from .assumptions import *
>>>>>>   from .polys import *
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Apr 9, 2014 at 10:07 AM, Andrew Ayre <andy at britishideas.com> wrote:
>>>>>>> OK. Is there a workaround I can use?
>>>>>>>
>>>>>>> Andy
>>>>>>>
>>>>>>> On 4/8/2014 8:04 PM, Pawel Jasinski wrote:
>>>>>>>> It looks like the import bug, but is different.
>>>>>>>> This time imported is confusing already imported:  sympy.core.sets
>>>>>>>> with sympy.sets. Is is looking for  sympy.sets.fancysets in sympty.core.sets
>>>>>>>>
>>>>>>>> On Tue, Apr 8, 2014 at 11:51 AM, Andrew Ayre <andy at britishideas.com> wrote:
>>>>>>>>> On 4/8/2014 10:28 AM, Jeff Hardy wrote:
>>>>>>>>>> On Tue, Apr 8, 2014 at 9:08 AM, Andrew Ayre <andy at britishideas.com> wrote:
>>>>>>>>>>> Thanks. Making progress... Now it can't find sympy.sets.fancysets. I've
>>>>>>>>>>> added the folder where the module is defined to sys.path:
>>>>>>>>>>>
>>>>>>>>>>> =============================================
>>>>>>>>>>>>>> sys.path.append('../../PythonLib/sympy/sets')
>>>>>>>>>>>
>>>>>>>>>>>>>> sys.path
>>>>>>>>>>>
>>>>>>>>>>> ['.', 'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\Lib',
>>>>>>>>>>> 'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\DLLs',
>>>>>>>>>>> 'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\PythonLib',
>>>>>>>>>>> '../../PythonLib', '../../PythonLib', '../../PythonLib/sympy/mpmath',
>>>>>>>>>>> '../../PythonLib/sympy/sets']
>>>>>>>>>>>
>>>>>>>>>>>>> >from sympy.sets.fancysets import Naturals0
>>>>>>>>>>>
>>>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>>>   File "<string>", line 1, in <module>
>>>>>>>>>>>   File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\__init__.py",
>>>>>>>>>>> line 34, in <module>
>>>>>>>>>>>   File
>>>>>>>>>>> "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\assumptions\__init__.py",
>>>>>>>>>>> line 2, in <module>
>>>>>>>>>>>   File
>>>>>>>>>>> "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\assumptions\ask.py",
>>>>>>>>>>> line 323, in <module>
>>>>>>>>>>>   File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\cache.py",
>>>>>>>>>>> line 93, in wrapper
>>>>>>>>>>>   File
>>>>>>>>>>> "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\function.py",
>>>>>>>>>>> line 185, in __new__
>>>>>>>>>>> ImportError: No module named fancysets
>>>>>>>>>>> =============================================
>>>>>>>>>>>
>>>>>>>>>>> Here is what the folder structure looks like:
>>>>>>>>>>>
>>>>>>>>>>> https://github.com/sympy/sympy/tree/master/sympy/sets
>>>>>>>>>>
>>>>>>>>>> Which version of IronPython? It sure looks like the import bug, but if
>>>>>>>>>> you're still hitting in 2.7.5b1 then we'll have to reopen it.
>>>>>>>>>
>>>>>>>>> Jeff,
>>>>>>>>>
>>>>>>>>> Here is my sanity check:
>>>>>>>>>
>>>>>>>>> =============================================
>>>>>>>>>>>> sys.version
>>>>>>>>>
>>>>>>>>> '2.7.5b1 (IronPython 2.7.5b1 (2.7.0.40) on .NET 4.0.30319.18444 (32-bit))'
>>>>>>>>> =============================================
>>>>>>>>>
>>>>>>>>> I'm using the pre-compiled binary version.
>>>>>>>>>
>>>>>>>>> Thanks, Andy
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Andy
>>>>>>>>> PGP Key ID: 0xDC1B5864
>>>>>>>>> _______________________________________________
>>>>>>>>> Ironpython-users mailing list
>>>>>>>>> Ironpython-users at python.org
>>>>>>>>> https://mail.python.org/mailman/listinfo/ironpython-users
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Andy
>>>>>>> PGP Key ID: 0xDC1B5864
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> --
>>>> Andy
>>>> PGP Key ID: 0xDC1B5864
>>>
>>>
>>>
>>
>
> --
> Andy
> PGP Key ID: 0xDC1B5864


More information about the Ironpython-users mailing list