Setup.py: error: unrecognized arguments: egg_info --egg-base /tmp/pip-pip-egg-info-nx929i7g

On Ubuntu 20.04.3 LTS, I try to create a virtualenv for ariadne, but failed. For more details, see the following steps and errors:

$ git clone https://github.com/hongyi-zhao/ariadne.git
$ cd ariadne

$ virtualenv venv
created virtual environment CPython3.8.10.final.0-64 in 244ms
  creator CPython3Posix(dest=/home/werner/Public/repo/github.com/hongyi-zhao/ariadne.git/venv, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/werner/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

$ venv/bin/pip install -U pip
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pip
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/6a/df/a6ef77a6574781a668791419ffe366c8acd1c3cf4709d210cb53cd5ce1c2/pip-22.0.3-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
Successfully installed pip-22.0.3

$ venv/bin/pip install -e .
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Obtaining file:///home/werner/Public/repo/github.com/hongyi-zhao/ariadne.git
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 2
  ╰─> [2 lines of output]
      usage: setup.py [-h] [-z] [-b] [-f]
      setup.py: error: unrecognized arguments: egg_info --egg-base /tmp/pip-pip-egg-info-nx929i7g
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Any hints for fixing this problem will be highly appreciated.

Regards,
HZ

First, make sure you activate your environment with source venv/bin/activate (assuming the structure is the same as with the stdlib venv, then update pip and try your install command again. If it still doesn’t work, as you can see from the error messages,

and

The issue is likely not with pip, but with the configuration (perhaps in the setup.py, setup.cfg or pyproject.toml) of the package you’re trying to install.

The project has a handcrafted setup.py, not the one pip install expects and it doesn’t accept arguments pip thinks it should.

To make a package pip install'able, please follow the packaging guide.

1 Like

@frostming Is there a quick fix for this problem?

HZ

You need to pickup a build backend and then follow their instructions. For example in your setup.py you seem to already have some code for setuptools, so you can decide to uncomment that bit.

However the customised install that modifies the user home directories is not something any backend supports (to be my best knowledge). So I would implement that as a second installation step asking the user to run a CLI command you provide in your package (e.g. ariadne install).

To add such command you can use a console_scripts entry-point.

As recommended by Frostming, please have a look on the Packaging tutorial, the structure of the package is fairly unconventional and it might not play well with the other Python tools, such as pip.

Thank you all for your help. Finally, the following steps solve this problem using this setup.py:

$ git clone https://github.com/hongyi-zhao/ariadne.git
$ cd ariadne
$ virtualenv venv 
$ venv/bin/pip install -U pip
$ venv/bin/pip install -e .

Regards,
HZ