pygments / pygments.rb

💎 Ruby wrapper for Pygments syntax highlighter
MIT License
572 stars 141 forks source link

Virtual environment Pythons are ignored on Windows #256

Closed george-palmsens closed 11 months ago

george-palmsens commented 11 months ago
    # Detect a suitable Python binary to use.
    def find_python_binary
      if Gem.win_platform?
        return %w[py -3] if which('py')

        return [%w[python3 python].find { |py| !which(py).nil? }]
      end

      # On non-Windows platforms, we simply rely on shebang
      []
    end

This code prefers the outcome of py -3, which bypasses any active virtual environment. This is very inconvenient when using custom lexers, since you have to install them into a system python.