How to use netifaces package and package management using pipenv, pip

223 views Asked by At

I have installed certain python packages along with the netifaces package, using the pipenv and then exported it to requirements.pip. The workflow is as follows.

export PIPENV_VENV_IN_PROJECT=1                                                                        
pipenv --three                                                                                         
                                                                                                       
# Arrange packages alphabetically for easy search.                                                     
declare -a pkg_list=( \                                                                                                                                                         
    "multiprocessing-logging" \                                                                        
    "nested-lookup" \                                                                                  
    "netifaces" \                                                                                      
    "openstacksdk" \                                                                                                                                                                    
    "oslo_config" \                                                                                    
    "oslo.messaging" \                                                                                 
    "paramiko" \                                                                                       
    "pika"                                                                                                                                                                              
)                                                                                                      
                                                                                                       
# Iterate through the array and install each package.                                                  
for i in "${pkg_list[@]}"                                                                              
do                                                                                                     
   echo Installing "$i"                                                                                
   pipenv install $i                                                                                   
done                                                                                                   
                                                                                                       
# Lock the pipenv.lock file and also generate requirements file                                        
# to be used for download packages uing 'pip install -d'                                               
pipenv lock                                                                                            
pipenv lock -r > requirements.pip 

Later I use the requirements.pip file to recreate the installed package image wherever I want, as follows.

# Download python packages to a local pkg folder.                                                   
python3 -m pip install --target=./pkg -r ./requirements.pip 

After I recreate the package, I do not see the source/package folder for netifaces package in the site-package folder and my application fails to import the package.

The site-package folder contains the following files and I am not sure how the application does not find the package and complains about it.

ls -lrt pkg/ | grep neti
-rwxr-xr-x  1 user eng  68095 Mar 12 00:42 netifaces.cpython-36m-x86_64-linux-gnu.so
drwxr-xr-x  2 user eng   4096 Mar 12 00:42 netifaces-0.10.9.dist-info

I am not sure if it is something to do with the .so file above. Can you please help me fix this issue?

0

There are 0 answers