evil-mad / axidraw

Software for the AxiDraw drawing machine
GNU General Public License v2.0
435 stars 131 forks source link

pip install of the CLI tools ignores flags provided to pip #119

Closed josyoun closed 2 years ago

josyoun commented 2 years ago

It looks like the install script (setup.py) strips and ignores the --user flag from pip. This is important for Gentoo installs as to not corrupt the system Python. Basically, I get the following:

$ pip install --user https://cdn.evilmadscientist.com/dl/ad/public/AxiDraw_API.zip
Collecting https://cdn.evilmadscientist.com/dl/ad/public/AxiDraw_API.zip
  Using cached https://cdn.evilmadscientist.com/dl/ad/public/AxiDraw_API.zip (316 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-wgfoujw5/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-wgfoujw5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-3q03l2yx
       cwd: /tmp/pip-req-build-wgfoujw5/
  Complete output (19 lines):
  WARNING: Skipping axidrawinternal as it is not installed.
  ERROR: (Gentoo) Please run pip with the --user option to avoid breaking python-exec
  Traceback (most recent call last):
    File "/tmp/pip-req-build-wgfoujw5/setup.py", line 46, in replacement_setup
      subprocess.check_call([sys.executable, '-m', 'pip', 'install', wheel_file])
    File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/usr/bin/python3.9', '-m', 'pip', 'install', 'prebuilt_dependencies/axidrawinternal-3.1.0-py2.py3-none-any.whl']' returned non-zero exit status 1.

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-req-build-wgfoujw5/setup.py", line 58, in <module>
      replacement_setup(
    File "/tmp/pip-req-build-wgfoujw5/setup.py", line 51, in replacement_setup
      raise RuntimeError("Could not install one or more prebuilt dependencies.", err.with_traceback(err.__traceback__))
  RuntimeError: ('Could not install one or more prebuilt dependencies.', CalledProcessError(1, ['/usr/bin/python3.9', '-m', 'pip', 'install', 'prebuilt_dependencies/axidrawinternal-3.1.0-py2.py3-none-any.whl']))
  WARNING: It looks like you might be attempting to install this in a non-pip way. This is discouraged. Use `pip install .` (or `pip install -r requirements.txt` if you are a developer with access to the relevant private repositories).
  ----------------------------------------
WARNING: Discarding https://cdn.evilmadscientist.com/dl/ad/public/AxiDraw_API.zip. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

That said, if I download the scripts by hand (AxiDraw_API_310r1) and modify setup.py to change:

                subprocess.check_call([sys.executable, '-m', 'pip', 'install', wheel_file])

to

                subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--user', wheel_file])

Everything works fine. Basically, I believe this call needs to include any command line flags provided to pip, such as --user, for some systems like Gentoo to install properly.

oskay commented 2 years ago

We don't want to implement that directly as stated here ( subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--user', wheel_file])) because we don't want that to be the default. However, I'm glad that you note the workaround, and we'll look into passing through additional flags.

josyoun commented 2 years ago

Yes, I completely agree this flag should not be hard coded. Mostly, I wanted to document the issue and potential work around for others. I think feature request for passing through the flags is the right option. Thanks for having a look!

oskay commented 2 years ago

This is implemented in development builds and should be available by default in near-future releases.

oskay commented 2 years ago

The --user flag should be passed through as of the 3.3.0 release.