CrossNox / m2r2

Markdown to reStructuredText converter
https://crossnox.github.io/m2r2
MIT License
107 stars 26 forks source link

Don't try to import m2r2 during setup (fixes DistributionNotFound error) #22

Open kalvdans opened 3 years ago

kalvdans commented 3 years ago

Don't try to import m2r2 during setup, since it expects m2r2 to be installed already.

Fixes the following error during pip install https://github.com/CrossNox/m2r2/archive/v0.2.7.zip:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-ga0ueyp7/setup.py", line 14, in <module>
        from m2r2 import parse_from_file
      File "/tmp/pip-req-build-ga0ueyp7/m2r2.py", line 19, in <module>
        __version__ = get_distribution("m2r2").version
      File "/home/chn/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 480, in get_distribution
        dist = get_provider(dist)
      File "/home/chn/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 356, in get_provider
        return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
      File "/home/chn/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 899, in require
        needed = self.resolve(parse_requirements(requirements))
      File "/home/chn/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 785, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'm2r2' distribution was not found and is required by the application
CrossNox commented 3 years ago

Hi @kalvdans, sorry for leaving this open for so long. I have not been able to replicate any errors installing with pip install https://github.com/CrossNox/m2r2/archive/v0.2.7.zip, using python3.7 and python3.8 virtualenvs on fedora 34.

If this error persists and you can provide extra info on how to replicate, feel free to reopen. I'm closing this to focus on other PRs.

kalvdans commented 3 years ago

Sorry to not give enough information. I could reproduce today on Ubuntu 20.04.2:

$ python3 --version
Python 3.8.5
$ python3 -m venv env
$ env/bin/pip install https://github.com/CrossNox/m2r2/archive/v0.2.7.zip
Collecting https://github.com/CrossNox/m2r2/archive/v0.2.7.zip
  Using cached https://github.com/CrossNox/m2r2/archive/v0.2.7.zip
Collecting docutils
  Downloading docutils-0.17.1-py2.py3-none-any.whl (575 kB)
     |████████████████████████████████| 575 kB 25.3 MB/s 
Collecting mistune
  Using cached mistune-0.8.4-py2.py3-none-any.whl (16 kB)
Building wheels for collected packages: m2r2
  Building wheel for m2r2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /tmp/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-c8css0js/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-c8css0js/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-f283kn6q                         
       cwd: /tmp/pip-req-build-c8css0js/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for m2r2
  Running setup.py clean for m2r2
Failed to build m2r2
Installing collected packages: docutils, mistune, m2r2
    Running setup.py install for m2r2 ... error
    ERROR: Command errored out with exit status 1:
     command: /tmp/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-c8css0js/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-c8css0js/setup.py'"'"';f=getattnize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-he3kvll8/install-recor--single-version-externally-managed --compile --install-headers /tmp/env/include/site/python3.8/m2r2
         cwd: /tmp/pip-req-build-c8css0js/
    Complete output (15 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-c8css0js/setup.py", line 14, in <module>
        from m2r2 import parse_from_file
      File "/tmp/pip-req-build-c8css0js/m2r2.py", line 19, in <module>
        __version__ = get_distribution("m2r2").version
      File "/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 481, in get_distribution
        dist = get_provider(dist)
      File "/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 357, in get_provider
        return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
      File "/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 900, in require
        needed = self.resolve(parse_requirements(requirements))
      File "/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 786, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'm2r2' distribution was not found and is required by the application
    ----------------------------------------
ERROR: Command errored out with exit status 1: /tmp/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-c8css0js/setup.py'"'"'; __file__='"'"'/tmp/pip-req-buils0js/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/cord-he3kvll8/install-record.txt --single-version-externally-managed --compile --install-headers /tmp/env/include/site/python3.8/m2r2 Check the logs for full command output.
CrossNox commented 3 years ago

Can you try with pip install git+https://github.com/CrossNox/m2r2.git@v0.2.7, please?

Also, what are the outputs of pip --version and pip show setuptools?

kalvdans commented 3 years ago
chn@brahe:~/tmp$ python3 --version
Python 3.8.5
chn@brahe:~/tmp$ python3 -m venv env
chn@brahe:~/tmp$ env/bin/pip --version
pip 20.0.2 from /home/chn/tmp/env/lib/python3.8/site-packages/pip (python 3.8)
chn@brahe:~/tmp$ env/bin/pip show setuptools
Name: setuptools
Version: 44.0.0
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: distutils-sig@python.org
License: UNKNOWN
Location: /home/chn/tmp/env/lib/python3.8/site-packages
Requires: 
Required-by: 
chn@brahe:~/tmp$ env/bin/pip install git+https://github.com/CrossNox/m2r2.git@v0.2.7
Collecting git+https://github.com/CrossNox/m2r2.git@v0.2.7
  Cloning https://github.com/CrossNox/m2r2.git (to revision v0.2.7) to /tmp/pip-req-build-1w0hyxzf
  Running command git clone -q https://github.com/CrossNox/m2r2.git /tmp/pip-req-build-1w0hyxzf
  Running command git checkout -q 97c766d7ec3bb1966787e3093b4ec122857b4064
Collecting docutils
  Downloading docutils-0.17.1-py2.py3-none-any.whl (575 kB)
     |████████████████████████████████| 575 kB 1.1 MB/s 
Collecting mistune
  Downloading mistune-0.8.4-py2.py3-none-any.whl (16 kB)
Building wheels for collected packages: m2r2
  Building wheel for m2r2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/chn/tmp/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-1w0hyxzf/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-1w0hyxzf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-blv5uz_e                                                                                         
       cwd: /tmp/pip-req-build-1w0hyxzf/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for m2r2
  Running setup.py clean for m2r2
Failed to build m2r2
Installing collected packages: docutils, mistune, m2r2
    Running setup.py install for m2r2 ... error
    ERROR: Command errored out with exit status 1:
     command: /home/chn/tmp/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-1w0hyxzf/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-1w0hyxzf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xjxs4wx_/install-record.txt --single-version-externally-managed --compile --install-headers /home/chn/tmp/env/include/site/python3.8/m2r2
         cwd: /tmp/pip-req-build-1w0hyxzf/
    Complete output (15 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-1w0hyxzf/setup.py", line 14, in <module>
        from m2r2 import parse_from_file
      File "/tmp/pip-req-build-1w0hyxzf/m2r2.py", line 19, in <module>
        __version__ = get_distribution("m2r2").version
      File "/home/chn/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 481, in get_distribution
        dist = get_provider(dist)
      File "/home/chn/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 357, in get_provider
        return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
      File "/home/chn/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 900, in require
        needed = self.resolve(parse_requirements(requirements))
      File "/home/chn/tmp/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 786, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'm2r2' distribution was not found and is required by the application
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/chn/tmp/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-1w0hyxzf/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-1w0hyxzf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xjxs4wx_/install-record.txt --single-version-externally-managed --compile --install-headers /home/chn/tmp/env/include/site/python3.8/m2r2 Check the logs for full command output.
CrossNox commented 3 years ago

I've been able to replicate it by creating a new virtualenv, which has by default setuptools==46.1.3. then I downgrade to 44.0.0 and then, this same error pops for me too. Funny part is that upgrading to 46.1.3 or above does not make the error go away.