digidotcom / python-streamexpect

Python library providing cross-platform text matching for generic streams and sockets
Mozilla Public License 2.0
41 stars 8 forks source link

Cannot install due to AttributeError: module 'pypandoc' has no attribute 'convert' #7

Closed jquast closed 8 months ago

jquast commented 8 months ago

Just leaving this here for anyone else, I know that @nastevens isn't employed by digidotcom anymore and the remaining digidotcom have not taken action for two years, so I hope this will help others.

Problem

Because the pypi release has not been cut for 8 years, this program may no longer be installed, with either of the two errors,

Solutions

Why

@JessicaTegner writes in https://github.com/man-group/pytest-plugins/issues/87#issuecomment-1123830409:

In the recent release of PyPandoc (version 1.8), the convert function was removed after a year of being deprecated.

The solution here, is to either switch to pypandoc.convert_file or pypandoc.convert_text, depending

python-streamexpect program doesn't use PyPandoc directly, but through setuptools. PyPandoc made an incompatible API change. This was fixed in https://github.com/digidotcom/python-streamexpect/pull/6 by @almetge by changing long_description_markdown_filename='README.md' to long_description_content_type='text/markdown', but this software has not been re-released to pypi.

Details

Using the latest version of Python, pip, and setuptools:

$ python -V; pip -V; pip freeze
Python 3.12.1
pip 24.0 from /Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/pip (python 3.12)
setuptools==69.1.0

Installing streamexpect results in error:

  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [38 lines of output]
      long_description_markdown_filename: dist = <setuptools.dist.Distribution object at 0x101d76f90>; attr = 'long_description_markdown_filename'; value = 'README.md'
      Traceback (most recent call last):
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 480, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 20, in <module>
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
                                       ^^^^^^^^^^^^
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 303, in __init__
          _Distribution.__init__(self, dist_attrs)
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
          self.finalize_options()
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 654, in finalize_options
          ep(self)
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 674, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/normal/lib/python3.12/site-packages/setuptools_markdown.py", line 38, in long_description_markdown_filename
          frame = _get_code_object()
                  ^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-build-env-2zq3ea0p/normal/lib/python3.12/site-packages/setuptools_markdown.py", line 58, in _get_code_object
          code = frame.f_back.f_code
                 ^^^^^^^^^^^^^^^^^^^
      AttributeError: 'NoneType' object has no attribute 'f_code'

If you install the 'wheel' package, it instead results in error:

$ pip install wheel
Collecting wheel
  Using cached wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB)
Using cached wheel-0.42.0-py3-none-any.whl (65 kB)
Installing collected packages: wheel
Successfully installed wheel-0.42.0
$ pip install streamexpect
Collecting streamexpect
  Using cached streamexpect-0.2.1.tar.gz (13 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [37 lines of output]
      /Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/setuptools/__init__.py:80: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
      /private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-install-dqeaq8x1/streamexpect_b58f212c03f24251b5e515b64a78cb72/.eggs/pypandoc-1.13-py3.12.egg/pypandoc/pandoc_download.py:61: SyntaxWarning: invalid escape sequence '\.'
        regex = re.compile(r"/jgm/pandoc/releases/download/.*(?:"+processor_architecture+"|x86|mac).*\.(?:msi|deb|pkg)")
      long_description_markdown_filename: dist = <setuptools.dist.Distribution object at 0x103b7a3c0>; attr = 'long_description_markdown_filename'; value = 'README.md'
      markdown_filename = '/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-install-dqeaq8x1/streamexpect_b58f212c03f24251b5e515b64a78cb72/README.md'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-install-dqeaq8x1/streamexpect_b58f212c03f24251b5e515b64a78cb72/setup.py", line 20, in <module>
          setup(
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
                                       ^^^^^^^^^^^^
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/setuptools/dist.py", line 303, in __init__
          _Distribution.__init__(self, dist_attrs)
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
          self.finalize_options()
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/setuptools/dist.py", line 654, in finalize_options
          ep(self)
        File "/Users/jq/.virtualenvs/apple1serui-zxme/lib/python3.12/site-packages/setuptools/dist.py", line 674, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/private/var/folders/0x/y8s2qlk558596kyqdhv3nwv40000gn/T/pip-install-dqeaq8x1/streamexpect_b58f212c03f24251b5e515b64a78cb72/.eggs/setuptools_markdown-0.4.1-py3.12.egg/setuptools_markdown.py", line 43, in long_description_markdown_filename
          output = pypandoc.convert(markdown_filename, 'rst', format='md')
                   ^^^^^^^^^^^^^^^^
      AttributeError: module 'pypandoc' has no attribute 'convert'
JessicaTegner commented 8 months ago

Minor suggestion. We should always aim to be on the latest versions when posible. So if nothing is blocking further upgrades to pypandoc, I would suggest uninstalling pypandoc and then installing the latest version

pip uninstall pypandoc
pip install -U pypandoc
jquast commented 8 months ago

@JessicaTegner I'm not sure you read this issue correctly :(

Installing the latest version of pypandoc prevents installation of this package, python-streamexpect and possibly several hundred other packages that may have been released to pypi that used long_description_markdown_filename argument in setup.py https://github.com/search?q=long_description_markdown_filename+path%3A**%2Fsetup.py&type=code

By removing the API function "convert" in the 1.8 release https://github.com/JessicaTegner/pypandoc/pull/257 this setup.py option continues to depend on this missing function https://github.com/msabramo/setuptools-markdown/blob/34ed6276e0c8bcefcd967bd8db138546a270bdf4/setuptools_markdown.py#L43

Please downgrade PyPandoc if you wish to install python-streamexpect or any other package that has this error. Using the latest version of PyPandoc is precisely the problem, as the public API function "convert" was removed

JessicaTegner commented 8 months ago

Ohh sorry aount that. I read your original instructions as pypandoc >1.7. Please disregard my comment :)

nastevens commented 8 months ago

@jquast Just FYI the Digi employee "that doesn't give a shit" reached out immediately after you opened this issue to see about getting access to the PyPI project so he could do a release. Asking for a release politely would have gotten you the same result, I'm sure. Please try to remember that there are actual people behind the software projects that you use, and thanks @mikewadsten for your professionalism.

jquast commented 8 months ago

I'm sorry for the harsh language, but somebody already politely requested this two years ago, and that didn't appear to work ... https://github.com/digidotcom/python-streamexpect/pull/6#issuecomment-1275968188

nastevens commented 8 months ago

Let me be more clear: anyone who makes posts that violate the GitHub Community Guidelines is not welcome. There was no need to attack Digi employees or to resort to vulgarity in your request.

jquast commented 8 months ago

harsh language got Digi to finally take action, but I do apologize a second time.

mikewadsten commented 8 months ago

I have taken an action item to find some time to get a new version of streamexpect built and pushed to PyPI. @jquast Thank you for alerting us to this installation issue. (Not the first time a third party package change has caused install breakages in the universe, sure won't be the last).

mikewadsten commented 8 months ago

I have created a new 0.3.0 release, and published that to PyPI.