Skip to content Skip to sidebar Skip to footer

How To Make Setuptools Install A Wheel Containing Multiple Packages?

Suppose this wheel: M Filemode Length Date Time File - ---------- -------- ----------- -------- ------------------------------------------- -rw-rw-r--

Solution 1:

It sounds like only few sub-directories like azure.common installed into your environment when you installed dependencies via setup.py with install_requires=['azure-common']. I tried to reproduce this issue, but failed that all files in this package has been installed.

Here is my steps on my local Windows machine as below, which you can refer to.

  1. Create a directory mkdir setuptmp, and create a virtual environment virtualenv setuptmp, then to cd setuptmp.
  2. Create a setup.py file with the content as below.\

    from setuptools import setup, find_packages  
    
    setup(
        name = "setuptmp",
        install_requires = ['azure-common']
    )
    
  3. Activate the virtual environment via Scripts\activate.bat.

  4. Run python setup.py install to install the dependency described in my setup.py.
  5. Run python to open the REPL interpreter to test all packages as you said,

    (setuptmp) D:\projects\setuptmp>python
    Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import azure.common
    >>> import azure.profiles
    >>> azure.common.__file__
    'D:\\projects\\setuptmp\\lib\\site-packages\\azure_common-1.1.16-py3.7.egg\\azure\\common\\__init__.py'
    >>> azure.profiles.__file__
    'D:\\projects\\setuptmp\\lib\\site-packages\\azure_common-1.1.16-py3.7.egg\\azure\\profiles\\__init__.py'
    >>> import azure_common
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'azure_common'
    

Note: azure_common is not a module, just an egg info directory.

  1. Check the packages installed in my environment via cd Lib\site-packages, dir and tree azure_common-1.1.16-py3.7.egg /F as below.

    (setuptmp) D:\projects\setuptmp\Lib\site-packages>dir
     Volume in drive D is Data
     Volume Serial Number is BA4B-64AA
    
     Directory of D:\projects\setuptmp\Lib\site-packages
    
    2018/12/26  14:48    <DIR>          .
    2018/12/26  14:48    <DIR>          ..
    2018/12/26  14:48    <DIR>          azure_common-1.1.16-py3.7.egg
    2018/12/26  14:48                61 easy-install.pth
    2018/12/26  14:46               126 easy_install.py
    2018/12/26  14:46    <DIR>          pip
    2018/12/26  14:46    <DIR>          pip-18.1.dist-info
    2018/12/26  14:46    <DIR>          pkg_resources
    2018/12/26  14:48               965 setuptmp-0.0.0-py3.7.egg
    2018/12/26  14:46    <DIR>          setuptools
    2018/12/26  14:46    <DIR>          setuptools-40.6.3.dist-info
    2018/12/26  14:46    <DIR>          wheel
    2018/12/26  14:46    <DIR>          wheel-0.32.3.dist-info
    2018/12/26  14:46    <DIR>          __pycache__
                   3 File(s)          1,152 bytes
                  11 Dir(s)  80,896,319,488 bytes free
    
    (setuptmp) D:\projects\setuptmp\Lib\site-packages>tree azure_common-1.1.16-py3.7.egg /F
    Folder PATH listing for volume Data
    Volume serial number is BA4B-64AA
    D:\PROJECTS\SETUPTMP\LIB\SITE-PACKAGES\AZURE_COMMON-1.1.16-PY3.7.EGG
    ├─azure
      ├─common
          client_factory.py
          cloud.py
          credentials.py
          exceptions.py
          _version.py
          __init__.py
        
        └─__pycache__
                _version.cpython-37.pyc
                __init__.cpython-37.pyc
      
      └─profiles
              multiapiclient.py
              __init__.py
    
    └─EGG-INFO
            PKG-INFO
            RECORD
            requires.txt
            top_level.txt
            WHEEL
    
  2. Compare the above with the file structure of azure-common package downloaded from the link of Pypi website. I decompressed azure_common-1.1.16-py2.py3-none-any.whl file using 7-Zip into a temp directory and tree it.

    D:\tmp>tree azure_common-1.1.16-py2.py3-none-any /F
    Folder PATH listing for volume Data
    Volume serial number is BA4B-64AA
    D:\tmp\AZURE_COMMON-1.1.16-PY2.PY3-NONE-ANY
    ├─azure
    │  ├─common
    │  │      client_factory.py
    │  │      cloud.py
    │  │      credentials.py
    │  │      exceptions.py
    │  │      _version.py
    │  │      __init__.py
    │  │
    │  └─profiles
    │          multiapiclient.py
    │          __init__.py
    │
    └─azure_common-1.1.16.dist-info
            METADATA
            RECORD
            top_level.txt
            WHEEL
    

Then, you will find the file structure of step 6 & 7 is almost same.

Hope it helps. If you have any concern, please feel free to let me know.


I did the same above on Linux and got the same result. I saved the output of tree lib/ > lib_[before|after].txt of my Linux setuptmp before and after run python setup.py install, then to compare them using diff lib_*.txt as below.

(setuptmp) peter@peterpc:~/setuptmp$ diff lib*.txt
92a93,111
>     │   ├── azure_common-1.1.16-py3.6.egg
>     │   │   ├── EGG-INFO
>     │   │   │   ├── PKG-INFO
>     │   │   │   ├── RECORD
>     │   │   │   ├── WHEEL
>     │   │   │   ├── requires.txt
>     │   │   │   └── top_level.txt
>     │   │   └── azure
>     │   │       ├── common
>     │   │       │   ├── __init__.py
>     │   │       │   ├── _version.py
>     │   │       │   ├── client_factory.py
>     │   │       │   ├── cloud.py
>     │   │       │   ├── credentials.py
>     │   │       │   └── exceptions.py
>     │   │       └── profiles
>     │   │           ├── __init__.py
>     │   │           └── multiapiclient.py
>     │   ├── easy-install.pth
827a847
>     │   ├── setuptmp-0.0.0-py3.6.egg
1043c1063
< 118 directories, 922 files
---
> 123 directories, 937 files

Post a Comment for "How To Make Setuptools Install A Wheel Containing Multiple Packages?"