Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange import failure on RHEL 7 #887

Closed
capn-freako opened this issue Nov 5, 2021 · 8 comments · Fixed by #888
Closed

Strange import failure on RHEL 7 #887

capn-freako opened this issue Nov 5, 2021 · 8 comments · Fixed by #888

Comments

@capn-freako
Copy link

capn-freako commented Nov 5, 2021

Since updating my enable installation to 5.2.1, via building from source, I'm getting the following strange import error, only on RHEL 7. I don't get this error when running under MacOS.

    import enable.savage.svg.css
  File "foo/lib/python3.8/site-packages/enable/savage/svg/css/__init__.py", line 10, in <module>
    from .transform import transformList
  File "foo/lib/python3.8/site-packages/enable/savage/svg/css/transform.py", line 18, in <module>
    from enable.savage.svg.pathdata import number, maybeComma
  File "foo/lib/python3.8/site-packages/enable/savage/svg/pathdata.py", line 117, in <module>
    lineTo = Group(Command("L") + Arguments(coordinatePairSequence))
  File "foo/lib/python3.8/site-packages/enable/savage/svg/pathdata.py", line 29, in Command
    return CaselessPreservingLiteral(char)
  File "foo/lib/python3.8/site-packages/enable/savage/svg/pathdata.py", line 43, in __init__
    self.name = "'%s'" % matchString
AttributeError: can't set attribute
@rahulporuri
Copy link
Contributor

thanks for the report @capn-freako .

ref

class CaselessPreservingLiteral(CaselessLiteral):
""" Like CaselessLiteral, but returns the match as found
instead of as defined.
"""
def __init__(self, matchString):
super().__init__(matchString.upper())
self.name = "'%s'" % matchString

CaselessPreservingLiteral inherits from pyparsing.CaselessLiteral and the name attribute seems to belong to the pyparsing class. Can you report what versions of pyparsing you are using on RHEL7 and MacOS?

@capn-freako
Copy link
Author

capn-freako commented Nov 8, 2021 via email

@rahulporuri
Copy link
Contributor

RHEL: 3.0.4

Can I ask whether this behaviour persists if you downgrade pyparsing to a version < 3 on RHEL?

@rahulporuri
Copy link
Contributor

RHEL: 3.0.4

I don't see anything in version 3 of pyparsing which might be causing this issue - https://pyparsing-docs.readthedocs.io/en/latest/whats_new_in_3_0_0.html.

@capn-freako
Copy link
Author

capn-freako commented Nov 8, 2021 via email

@rahulporuri
Copy link
Contributor

In the meantime, is it possible that name became a read-only property of pyparsing with the release of version 3?

Spot on.

https://github.com/pyparsing/pyparsing/blob/0352555d968f9952800f0728383de8e1f9526e1e/pyparsing/core.py#L1802-L1805

CaselessLiteral inherits from Token which inherits from ParserElement. name is a property on ParserElement. Looks like the right way to set/update name on a CaselessLiteral is now using the ParserElement.set_name method.

rahulporuri pushed a commit that referenced this issue Nov 8, 2021
fixes #887 

This PR fixes an issue because of an upstream change with
the pyparsing CaselessLiteral class, where the name attribute became
a read-only property in version >= 3. We now use the new public
set_name method instead of directly setting the attribute.
@rahulporuri
Copy link
Contributor

@capn-freako #888 should fix the issue. Will you be able to test the fix?

rahulporuri pushed a commit that referenced this issue Nov 9, 2021
* FIX : Fix issue with pyparsing version >= 3

fixes #887 

This PR fixes an issue because of an upstream change with
the pyparsing CaselessLiteral class, where the name attribute became
a read-only property in version >= 3. We now use the new public
set_name method instead of directly setting the attribute.

* FIX : Handle pyparsing versions 2 and 3 accordingly

the new set_name API is only available on pyparsing version >= 3 so we
use packaging to handle the behavior according to the version

this commit makes packaging a dependency of the svg backend

and this commit adds a regression test

	modified:   enable/__init__.py
	modified:   enable/savage/svg/pathdata.py
	modified:   enable/savage/svg/tests/test_pathdata.py

* REF : Go with a simpler solution of checking for the method name

instead of manually parsing and checking the pyparsing version and
calling the relevant method depending on the version, we simply check
for the existence of the set_name method now and use it if it exists. If
it doesnt, we fall back to the old setName method

The dependence of packaging has now been removed because we dont need to
parse the version anymore

	modified:   enable/__init__.py
	modified:   enable/savage/svg/pathdata.py
rahulporuri pushed a commit that referenced this issue Nov 9, 2021
* FIX : Fix issue with pyparsing version >= 3

fixes #887 

This PR fixes an issue because of an upstream change with
the pyparsing CaselessLiteral class, where the name attribute became
a read-only property in version >= 3. We now use the new public
set_name method instead of directly setting the attribute.

* FIX : Handle pyparsing versions 2 and 3 accordingly

the new set_name API is only available on pyparsing version >= 3 so we
use packaging to handle the behavior according to the version

this commit makes packaging a dependency of the svg backend

and this commit adds a regression test

	modified:   enable/__init__.py
	modified:   enable/savage/svg/pathdata.py
	modified:   enable/savage/svg/tests/test_pathdata.py

* REF : Go with a simpler solution of checking for the method name

instead of manually parsing and checking the pyparsing version and
calling the relevant method depending on the version, we simply check
for the existence of the set_name method now and use it if it exists. If
it doesnt, we fall back to the old setName method

The dependence of packaging has now been removed because we dont need to
parse the version anymore

	modified:   enable/__init__.py
	modified:   enable/savage/svg/pathdata.py
rahulporuri pushed a commit that referenced this issue Nov 9, 2021
* Fix svg backend issue with pyparsing version >= 3 (#888)

* FIX : Fix issue with pyparsing version >= 3

fixes #887 

This PR fixes an issue because of an upstream change with
the pyparsing CaselessLiteral class, where the name attribute became
a read-only property in version >= 3. We now use the new public
set_name method instead of directly setting the attribute.

* FIX : Handle pyparsing versions 2 and 3 accordingly

the new set_name API is only available on pyparsing version >= 3 so we
use packaging to handle the behavior according to the version

this commit makes packaging a dependency of the svg backend

and this commit adds a regression test

	modified:   enable/__init__.py
	modified:   enable/savage/svg/pathdata.py
	modified:   enable/savage/svg/tests/test_pathdata.py

* REF : Go with a simpler solution of checking for the method name

instead of manually parsing and checking the pyparsing version and
calling the relevant method depending on the version, we simply check
for the existence of the set_name method now and use it if it exists. If
it doesnt, we fall back to the old setName method

The dependence of packaging has now been removed because we dont need to
parse the version anymore

	modified:   enable/__init__.py
	modified:   enable/savage/svg/pathdata.py

* Test on ubuntu-18.04, not 16.04 (#889)

* FIX : Test on ubuntu-18.04, not 16.04

ubuntu-16.04 is no longer available on GitHub Actions CI

* FIX : Use ubuntu-latest instead of ubuntu-18.04

* FIX : Use ubuntu-18.04 with the right package repository

	modified:   .github/workflows/test-with-edm.yml
	modified:   ci/edmtool.py

* FIX : Install libsdl2-dev using the ubuntu package manager

	modified:   .github/workflows/test-with-edm.yml

* FIX : Use libsdl1.2, not libsdl2

	modified:   .github/workflows/test-with-edm.yml
@capn-freako
Copy link
Author

Hi @rahulporuri ,

Sorry for the delay.
Yes, your commit has fixed the problem.

Thanks!
-db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants