Skip to content

Conversation

@mkmik
Copy link

@mkmik mkmik commented Jun 13, 2024

Under recent versions of pip, the pygments-shader package can't be installed because the setup.py loads a dependency before setup() has executed:

$ pip install -e .
....
        File "<string>", line 3, in <module>
        File "/private/tmp/pygments-shader/pygments_shader/__init__.py", line 3, in <module>
          from .lexer import *
        File "/private/tmp/pygments-shader/pygments_shader/lexer.py", line 1, in <module>
          from pygments.lexer import RegexLexer, bygroups, using, this, words
      ModuleNotFoundError: No module named 'pygments'
      [end of output]

The simple fix would be to just simplify the code and just use version='1.0.1' in the setup.py file.

However, that could potentially break users of the pygments-shader package that due to Hyrum's law could depend on the ability to refer to the pygments_shader.__version__ variable.

So instead, this PR uses SourceFileLoader to load version.py from setup.py without also importing other stuff that is not yet ready. (thanks to @Guillemdb for teaching me that trick)

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 this pull request may close these issues.

1 participant