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

Version 1.14.2 from PYPI has worse 'import' lines #2014

Closed
Alexey-T opened this issue Apr 3, 2022 · 4 comments
Closed

Version 1.14.2 from PYPI has worse 'import' lines #2014

Alexey-T opened this issue Apr 3, 2022 · 4 comments

Comments

@Alexey-T
Copy link

Alexey-T commented Apr 3, 2022

I used version 1.0.0 which had simple imports:

import ...
import ....

Now I got version 1.4.2 from PYPI and see it has changed imports like this:

_main = __import__("cssbeautifier", globals(), locals(), ["_main"])._main

This now does not work if I put the module to CudaText plugin:

Traceback (most recent call last):
......
  File "/home/user/.config/cudatext/py/cuda_fmt_css_format/cssbeautifier/__init__.py", line 30, in default_options
    _main = __import__("cssbeautifier", globals(), locals(), ["_main"])._main
ModuleNotFoundError: No module named 'cssbeautifier'
ERROR: Exception in CudaText for format: ModuleNotFoundError: No module named 'cssbeautifier'

Maybe you can change 'import' lines to usual ones? like this

from . import .....
from . import ...

Plugin code -- https://github.com/CudaText-addons/cuda_fmt_css_format

@bitwiseman
Copy link
Member

bitwiseman commented Apr 5, 2022

I assume you mean v1.14.2. v1.4.2 is a long time ago.

Sorry for the inconvenience. PR #1830 (which fixed #1808) is where the change to the complex import statements was introduced. It seemed to be required, but I'm not a Python expert. If there is a better way to do this, I'm happy to look at PRs.

You're trying to use this inside https://github.com/CudaText-addons/cuda_fmt_css_format ?
Are you doing pip install cssbeautifier and then using the installed package?
Or are you trying to do something else, like copying the code into that directory?

@Alexey-T Alexey-T changed the title Version 1.4.2 from PYPI has worse 'import' lines Version 1.14.2 from PYPI has worse 'import' lines Apr 5, 2022
@Alexey-T
Copy link
Author

Alexey-T commented Apr 5, 2022

I am trying to copy module folder to plugin directory. "complex imports" don't work there.

@Alexey-T
Copy link
Author

Alexey-T commented Apr 5, 2022

I am suggesting to try it on your end: change imports to relative imports.

from .nnnn import mmmmm
from . import nnn

this way is will work.

@bitwiseman
Copy link
Member

@Alexey-T
Note: cssbeautifier depends on jsbeautifier, so you might need to copy the contents of the python directory. That might fix the problem you're seeing.

This is change that will benefit you by simplifying updating your local copy of the project. As I said, you're welcome to try fixing this and I'll be happy to look a PR. I'm sorry I can't do more, but I personally don't time to work this problem.

@Alexey-T Alexey-T closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants