kliment / Printrun

Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software
GNU General Public License v3.0
2.38k stars 996 forks source link

[Ubuntu 20.04] Unable to "Build from Source": dbus-python is DEPRECATED #1089

Open eduncan911 opened 4 years ago

eduncan911 commented 4 years ago

EDIT: It seems to be specifying dbus-python, which is deprecated and it's old setup.py method won't be supported in the [very] near future.

It has been replaced by pydbus, which should be used in its stead.


Using master branch at the time of writing this issue.

$ which python
/home/eric/.virtualenvs/printrun/bin/python
$ python -V
Python 3.8.2
$ pip -V
pip 20.2 from /home/eric/.virtualenvs/printrun/lib/python3.8/site-packages/pip (python 3.8)
$ pip install https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04/wxPython-4.1.0-cp38-cp38-linux_x86_64.whl

Then when trying to install the deps (snipped most of the successful ones):

$ pip install -r requirements.txt 
Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' don't match your environment
Ignoring pyreadline: markers 'sys_platform == "win32"' don't match your environment
Requirement already satisfied: pyserial>=3.0 in /home/eric/.virtualenvs/printrun/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (3.4)
...
Building wheels for collected packages: dbus-python
  Building wheel for dbus-python (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/eric/.virtualenvs/printrun/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cfyo98k_/dbus-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cfyo98k_/dbus-python/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-twnmvyv3
       cwd: /tmp/pip-install-cfyo98k_/dbus-python/
  Complete output (144 lines):
  running bdist_wheel
  running build
  creating /tmp/pip-install-cfyo98k_/dbus-python/build
  creating /tmp/pip-install-cfyo98k_/dbus-python/build/temp.linux-x86_64-3.8
  checking whether make supports nested variables... yes
  checking whether to enable maintainer-specific portions of Makefiles... no
  checking for gcc... gcc
...
  checking for pkg-config... /usr/bin/pkg-config
  checking pkg-config is at least version 0.9.0... yes
  checking for DBUS... no
  configure: error: Package requirements (dbus-1 >= 1.8) were not met:

  No package 'dbus-1' found

  Consider adjusting the PKG_CONFIG_PATH environment variable if you
  installed software in a non-standard prefix.

  Alternatively, you may set the environment variables DBUS_CFLAGS
  and DBUS_LIBS to avoid the need to call pkg-config.
  See the pkg-config man page for more details.
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-cfyo98k_/dbus-python/setup.py", line 85, in <module>
      setup(
    File "/home/eric/.virtualenvs/printrun/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/home/eric/.virtualenvs/printrun/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-cfyo98k_/dbus-python/setup.py", line 56, in run
      subprocess.check_call([
    File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/tmp/pip-install-cfyo98k_/dbus-python/configure', '--disable-maintainer-mode', 'PYTHON=/home/eric/.virtualenvs/printrun/bin/python3', '--prefix=/tmp/pip-install-cfyo98k_/dbus-python/build/temp.linux-x86_64-3.8/prefix']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for dbus-python
  Running setup.py clean for dbus-python
Failed to build dbus-python
DEPRECATION: Could not build wheels for dbus-python which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.

Attached is the entire output.

pip-install-error.txt


This would be a lot easier if there was an AppImage or Dockerfile. ;)

eduncan911 commented 4 years ago

I should also note that the error and attached error log was from me trying to remove the requirements.txt version of dbus-python, to see if it would make a difference.

It didn't. Exact same error, and messages, using version >= 1.2.0 in the requirements.txt.

hroncok commented 4 years ago

A possible replacement is to fix the wheel build issue reported above.

Which is:

  checking for DBUS... no
  configure: error: Package requirements (dbus-1 >= 1.8) were not met:

  No package 'dbus-1' found

Try installing (via apt) libdbus-1-dev. Does it help?

eduncan911 commented 4 years ago

Installing dev packages on a secure machine is not a solution.

Though yes, I admit that may help.

At this point, I'm building a Docker image to debug this safely.

hroncok commented 4 years ago

I don't know what a secure machine means, but I'd say installing dev packages maintained by your distro maintainers is a magnitude safer than installing random packages from PyPI.

eduncan911 commented 4 years ago

At first glance, you would think. However, the attack vector is insignificant compared to system-wide packages.

Python wheels are isolated to the user space it runs under (if not installed with sudo) - in this case, a limited user with no sudo rights. And, only accessible under the virtualenv it is being run under (other tooling and scripts run by the user won't have access to those wheels - unless they do a user/system scan for packages in virtualenvs and I've never seen such a thing in the 100s and 100s of CVEs I've mitigated in Python and Ruby).

Whereas dev packages are available system wide for exploits by any script, anywhere, including browsers and all user spaces - even no login users.

We should be looking into removing that wheel and using another as a resolution at this point.

On Mon, Aug 3, 2020, 7:59 AM Miro Hrončok notifications@github.com wrote:

I don't know what a secure machine means, but I'd say installing dev packages maintained by your distro maintainers is a magnitude safer than installing random packages from PyPI.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kliment/Printrun/issues/1089#issuecomment-667982841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZUFAHGUD2LB2LZ2I3EXTR62RBZANCNFSM4PS2YBFQ .

eduncan911 commented 4 years ago

pydbus is the preferred lib to use in place of the deprecated dbus-python.

And, it does not require any system-wide dev packages installed. :)

https://stackoverflow.com/questions/59434149/using-dbus-to-poweroff-raspberry-pi-inside-docker-container-and-python

volconst commented 4 years ago

@eduncan911 You can try something like this:

apt download libdbus-1-dev
dpkg -x libdbus-1*.deb dbus-deb
# show values for DBUS_CFLAGS  DBUS_LIBS
PKG_CONFIG_PATH=dbus-deb/usr/lib/x86_64-linux-gnu/pkgconfig pkg-config  --cflags --libs dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1
export DBUS_CFLAGS=-I dbus-deb/... -I ...
export DBUS_LIBS=-ldbus-deb/usr/lib/x86_64-linux-gnu/libdbus-1.so
pip install -r requirements.txt

Another workaround is to download python3-dbus and set PYTHONPATH These paths are taken from Ubuntu 19, may be different in your env

Another workaround is to comment/delete the dbus line from requirements.txt. The code catches import exceptions, kind of graceful degrade. You have to manually ensure that the machine does not fall asleep.

Duke-Cardlert commented 3 years ago

I got similar errors to what was posted above, at the "install -r requirements" step. Afterward I did apt-get update and upgrade. I retried the previous step and received the following error message:

"wxPython-4.1.0-cp27-cp27mu-linux_x86_64.whl is not a supported wheel on this platform"

my computer is running Debian 10

volconst commented 3 years ago

@Duke-Cardlert , you should use python3: pip install -r requirements.txt should be pip3 install -r requirements.txt

Duke-Cardlert commented 3 years ago

thank you for the reply. I was able to find success by skipping this "wxPython wheel" step as shown in the installation guide. If I find that I need to reinstall, I will do it this way.

all the best!

On Sat, Nov 7, 2020 at 8:34 AM volconst notifications@github.com wrote:

@Duke-Cardlert https://github.com/Duke-Cardlert , you should use python3: pip install -r requirements.txt should be pip3 install -r requirements.txt

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kliment/Printrun/issues/1089#issuecomment-723466363, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGO32JV6PE7QC76UF3FDATSOVZKJANCNFSM4PS2YBFQ .