Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

pip install adb with python-rsa and without m2crypto #112

Closed

Description

@chilicheech

How do I go about installing adb without m2crypto? I already apt-get install python-rsa but when I pip install adb it still tries to download and compile m2crypto.

Activity

  1. fahhem commented on Jun 12, 2018

    @fahhem
    Contributor

    If import rsa works, then it shouldn't attempt to install anything. It will only install m2crypto if nothing else is installed.

  2. chilicheech commented on Jun 12, 2018

    @chilicheech
    Author

    I'm able to import rsa in a python shell/console. But when I pip install adb it still tries to install m2crypto. I'll try to get you some logs.

    I did a pip download adb and that got me a wheel file that has m2crypto hardcoded as a dependency. Not sure if that matters as I'm somewhat new to python/pip.

  3. chilicheech commented on Jun 12, 2018

    @chilicheech
    Author

    Here's what happens when I try that:

    root@6a9705b6716c:/# python
    Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import rsa
    >>>
    root@6a9705b6716c:/# pip install adb
    Collecting adb
      Downloading https://files.pythonhosted.org/packages/39/c0/715acc4e0c37a6a93f73daf8536baea94ac9fb6539ef1fd9c42205e1c3fa/adb-1.3.0-py2-none-any.whl
    Collecting M2Crypto<=0.26.4,>=0.21.1 (from adb)
      Downloading https://files.pythonhosted.org/packages/dc/5b/1ff81e2dda5d2dee62d1c26f5df91b1ea3a560b6611cea67e6c55d1f2e15/M2Crypto-0.26.4.tar.gz (1.1MB)
        100% |████████████████████████████████| 1.1MB 339kB/s
    Requirement already satisfied: libusb1>=1.0.16 in /usr/lib/python2.7/dist-packages (from adb)
    Collecting typing (from M2Crypto<=0.26.4,>=0.21.1->adb)
      Downloading https://files.pythonhosted.org/packages/0d/4d/4e5985d075d241d686a1663fa1f88b61d544658d08c1375c7c6aac32afc3/typing-3.6.4-py2-none-any.whl
    Building wheels for collected packages: M2Crypto
      Running setup.py bdist_wheel for M2Crypto ... error
      Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-CZLqS9/M2Crypto/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/tmp5hvJSTpip-wheel- --python-tag cp27:
      running bdist_wheel
      running build
      running build_py
      copying M2Crypto/ftpslib.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/callback.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/RC4.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/DH.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/Rand.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/m2urllib2.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/AuthCookie.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/Err.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/BN.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/util.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/SMIME.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/RSA.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/httpslib.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/m2crypto.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/threading.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/ASN1.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/DSA.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/BIO.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/__init__.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/EC.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/EVP.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/m2xmlrpclib.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/six.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/m2.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/X509.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/Engine.py -> build/lib.linux-armv7l-2.7/M2Crypto
      copying M2Crypto/m2urllib.py -> build/lib.linux-armv7l-2.7/M2Crypto
      creating build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/Context.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/cb.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/Connection.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/__init__.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/Checker.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/ssl_dispatcher.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/SSLServer.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/timeout.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/TwistedProtocolWrapper.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/Cipher.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      copying M2Crypto/SSL/Session.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
      creating build/lib.linux-armv7l-2.7/M2Crypto/PGP
      copying M2Crypto/PGP/PublicKeyRing.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
      copying M2Crypto/PGP/RSA.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
      copying M2Crypto/PGP/constants.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
      copying M2Crypto/PGP/packet.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
      copying M2Crypto/PGP/__init__.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
      copying M2Crypto/PGP/PublicKey.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
      running build_ext
      building 'M2Crypto._m2crypto' extension
      creating build/temp.linux-armv7l-2.7
      creating build/temp.linux-armv7l-2.7/SWIG
      arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-DsmO56/python2.7-2.7.15~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -I/usr/include -I/usr/include/arm-linux-gnueabihf -I/tmp/pip-build-CZLqS9/M2Crypto/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-armv7l-2.7/SWIG/_m2crypto_wrap.o -Wno-deprecated-declarations -DTHREADING
      SWIG/_m2crypto_wrap.c:3554:10: fatal error: openssl/err.h: No such file or directory
       #include <openssl/err.h>
                ^~~~~~~~~~~~~~~
      compilation terminated.
      error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    
      ----------------------------------------
      Failed building wheel for M2Crypto
      Running setup.py clean for M2Crypto
    Failed to build M2Crypto
    Installing collected packages: typing, M2Crypto, adb
      Running setup.py install for M2Crypto ... error
        Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-CZLqS9/M2Crypto/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-fnD0u_-record/install-record.txt --single-version-externally-managed --compile:
        running install
        running build
        running build_py
        creating build
        creating build/lib.linux-armv7l-2.7
        creating build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/ftpslib.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/callback.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/RC4.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/DH.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/Rand.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/m2urllib2.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/AuthCookie.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/Err.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/BN.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/util.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/SMIME.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/RSA.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/httpslib.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/m2crypto.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/threading.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/ASN1.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/DSA.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/BIO.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/__init__.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/EC.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/EVP.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/m2xmlrpclib.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/six.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/m2.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/X509.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/Engine.py -> build/lib.linux-armv7l-2.7/M2Crypto
        copying M2Crypto/m2urllib.py -> build/lib.linux-armv7l-2.7/M2Crypto
        creating build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/Context.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/cb.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/Connection.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/__init__.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/Checker.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/ssl_dispatcher.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/SSLServer.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/timeout.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/TwistedProtocolWrapper.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/Cipher.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        copying M2Crypto/SSL/Session.py -> build/lib.linux-armv7l-2.7/M2Crypto/SSL
        creating build/lib.linux-armv7l-2.7/M2Crypto/PGP
        copying M2Crypto/PGP/PublicKeyRing.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
        copying M2Crypto/PGP/RSA.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
        copying M2Crypto/PGP/constants.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
        copying M2Crypto/PGP/packet.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
        copying M2Crypto/PGP/__init__.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
        copying M2Crypto/PGP/PublicKey.py -> build/lib.linux-armv7l-2.7/M2Crypto/PGP
        running build_ext
        building 'M2Crypto._m2crypto' extension
        creating build/temp.linux-armv7l-2.7
        creating build/temp.linux-armv7l-2.7/SWIG
        arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-DsmO56/python2.7-2.7.15~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -I/usr/include -I/usr/include/arm-linux-gnueabihf -I/tmp/pip-build-CZLqS9/M2Crypto/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-armv7l-2.7/SWIG/_m2crypto_wrap.o -Wno-deprecated-declarations -DTHREADING
        SWIG/_m2crypto_wrap.c:3554:10: fatal error: openssl/err.h: No such file or directory
         #include <openssl/err.h>
                  ^~~~~~~~~~~~~~~
        compilation terminated.
        error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    
        ----------------------------------------
    Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-CZLqS9/M2Crypto/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-fnD0u_-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-CZLqS9/M2Crypto/
    root@6a9705b6716c:/#
    
  4. chilicheech commented on Jun 12, 2018

    @chilicheech
    Author

    Here's what's in that whl file:

    ➜  /tmp curl -O 'https://files.pythonhosted.org/packages/39/c0/715acc4e0c37a6a93f73daf8536baea94ac9fb6539ef1fd9c42205e1c3fa/adb-1.3.0-py2-none-any.whl'
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 34960  100 34960    0     0  93475      0 --:--:-- --:--:-- --:--:-- 93726
    ➜  /tmp which unzip
    /usr/bin/unzip
    ➜  /tmp unzip adb-1.3.0-py2-none-any.whl
    Archive:  adb-1.3.0-py2-none-any.whl
      inflating: adb/__init__.py
      inflating: adb/adb_commands.py
      inflating: adb/adb_debug.py
      inflating: adb/adb_protocol.py
      inflating: adb/common.py
      inflating: adb/common_cli.py
      inflating: adb/fastboot.py
      inflating: adb/fastboot_debug.py
      inflating: adb/filesync_protocol.py
      inflating: adb/sign_m2crypto.py
      inflating: adb/sign_pycryptodome.py
      inflating: adb/sign_pythonrsa.py
      inflating: adb/usb_exceptions.py
      inflating: adb-1.3.0.dist-info/entry_points.txt
      inflating: adb-1.3.0.dist-info/top_level.txt
      inflating: adb-1.3.0.dist-info/WHEEL
      inflating: adb-1.3.0.dist-info/METADATA
      inflating: adb-1.3.0.dist-info/RECORD
    ➜  /tmp ls
    adb                          adb-1.3.0.dist-info          com.apple.launchd.XLGsHUpnuB opensc-tokend.log
    adb-1.3.0-py2-none-any.whl   com.apple.launchd.S08hNFTKiK cvcd                         powerlog
    ➜  /tmp cat adb-1.3.0.dist-info/METADATA
    Metadata-Version: 2.1
    Name: adb
    Version: 1.3.0
    Summary: A pure python implementation of the Android ADB and Fastboot protocols
    Home-page: https://github.com/google/python-adb
    Author: Fahrzin Hemmati
    Author-email: fahhem@gmail.com
    Maintainer: Fahrzin Hemmati
    Maintainer-email: fahhem@google.com
    License: UNKNOWN
    Keywords: android,adb,fastboot
    Platform: UNKNOWN
    Classifier: Development Status :: 4 - Beta
    Classifier: License :: OSI Approved :: Apache Software License
    Classifier: Programming Language :: Python
    Classifier: Programming Language :: Python :: 2
    Classifier: Programming Language :: Python :: 3
    Classifier: Topic :: Software Development :: Testing
    Requires-Dist: libusb1 (>=1.0.16)
    Requires-Dist: M2Crypto (<=0.26.4,>=0.21.1)
    
    This repository contains a pure-python implementation of the Android
    ADB and Fastboot protocols, using libusb1 for USB communications.
    
    This is a complete replacement and rearchitecture of the Android
    project's ADB and fastboot code available at
    https://github.com/android/platform_system_core/tree/master/adb
    
    This code is mainly targeted to users that need to communicate with
    Android devices in an automated fashion, such as in automated
    testing. It does not have a daemon between the client and the device,
    and therefore does not support multiple simultaneous commands to the
    same device. It does support any number of devices and never
    communicates with a device that it wasn't intended to, unlike the
    Android project's ADB.
    
    
    ➜  /tmp
    
  5. chilicheech commented on Jun 12, 2018

    @chilicheech
    Author

    OK, I think I figured it out. pip install adb will by default install the whl, or binary, if it's available on pypi. I can tell it not to by running: pip install --no-binary :all: adb. That installs the tarball instead.

  6. evgps commented on Sep 12, 2019

    @evgps
    sudo apt install python-rsa
    sudo apt install swig
    sudo pip3 install pyOpenSSL
    sudo apt  install python3-m2crypto
    sudo mkdir /usr/include/openssl
    sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/opensslconf.h
    sudo apt-get install libssl-dev
    sudo pip3 install M2Crypto
    sudo pip3 install adb
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions