当前位置:   article > 正文

学习python setup.py_python setup.py develop

python setup.py develop

from setuptools import find_packages, setup

python setup.py --help

python setup.py --help-commands

python setup.py build --help
python setup.py install --help
python setup.py develop --help

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

python setup.py build和python setup.py install

python setup.py install包括两步:python setup.py build, python setup.py install,这两步,可分开执行, 也可只执行python setup.py install, 因为python setup.py install总是会先build后install. 

python setup.py build 是python编译这个module的过程, 这个过程比较复杂,最后会生成build文件夹。除去build过程后的install过程,就是复制build/lib文件到用户指定的lib库。
  • 1
  • 2
  • 3

python setup.py install和python setup.py develop

https://blog.csdn.net/yywan1314520/article/details/50457835

1.在安装某个库或包时,发现可以python setup.py install 和python setup.py develop两种方式来安装,这两种方法有什么不同?一直困扰着我,下面我们就来讨论下这个简单的问题
2.python setup.py install:主要是安装典型第三方包,这种包比较稳定,不再需要你去编辑、修改或是调试。
3.python setup.py develop:当你安装一个包后,这个包需要你不断修改,这样你就不得不重新安装,这时就采用这种安装方法。

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

pip install安装包与python install安装包的区别

例如以安装requests包为例。 
1、如果用 pip install requests 安装requests模块,则会把requests依赖的其它库都安装上,不用再费力去安装依赖的库了。 
2、如果用 python setup.py install 安装requests模块,还要手动去安装第三方依赖的模块,否则在import requests的时候会报错。 
例如当执行 python setup.py install 后,显示安装成功。 
执行import requests,提示错误信息: 
ImportError: No module named 'urllib3' 
然后你再下载urllib3模块,用python setup.py install 安装,安装成功后,再执行import requests ,提示错误信息: 
ImportError: No module named 'chardet' 
你重复上面的操作,用同样的方法安装chardet后,你再执行import requests ,提示错误信息: 
ImportError: No module named 'certifi' 
最后我放弃了,不知道request到底依赖了多少的包(通过看源码可知) 。

通过上面两种方法对比,建议直接用pip的方法进行安装,一次到位。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

在virtualenv中设置:pip install -e . vs python setup.py install

Editable   pip                    setup.py
yes        pip install -e .       python setup.py develop
no         pip install .          python setup.py install

  • 1
  • 2
  • 3
  • 4

我自己总结的

这个.表示在当前目录下面找setup.py文件
如果setup.py在liuhao里面,就需要使用pip install ./liuhao/

-e就是--editable
-e, --editable <path/url>   Install a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS url.
  • 1
  • 2
  • 3
  • 4
  • 5

只需要这一个setup.py文件就可以安装下面的

liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ tree
.
└── liuhao
    └── setup.py

1 directory, 1 file
liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

pip install ./liuhao/

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip install ./liuhao/
Processing ./liuhao
Building wheels for collected packages: DCNv2
  Building wheel for DCNv2 (setup.py) ... done
  Created wheel for DCNv2: filename=DCNv2-0.1-cp37-cp37m-linux_x86_64.whl size=2972 sha256=7ce42fa9f4e0537b49446ae02d34f4060704fb0c1b31b7d95c44862db3bb3fd3
  Stored in directory: /tmp/pip-ephem-wheel-cache-gc_pgq8e/wheels/e0/88/72/76ba75e305b4a20501b63b64cdc7a5db23a7b93b2dd7bcb9cd
Successfully built DCNv2
Installing collected packages: DCNv2
Successfully installed DCNv2-0.1
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
_ext.cpython-37m-x86_64-linux-gnu.so
DCNv2-0.1.dist-info文件夹

#==========================================================================
#没有在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/生成任何文件

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package              Version
-------------------- ------------------

DCNv2                0.1

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages
Requires: 
Required-by: 
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

python ./liuhao/setup.py install

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ python ./liuhao/setup.py install
running install
running bdist_egg
running egg_info
creating DCNv2.egg-info
writing DCNv2.egg-info/PKG-INFO
writing dependency_links to DCNv2.egg-info/dependency_links.txt
writing top-level names to DCNv2.egg-info/top_level.txt
writing manifest file 'DCNv2.egg-info/SOURCES.txt'
reading manifest file 'DCNv2.egg-info/SOURCES.txt'
writing manifest file 'DCNv2.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building '_ext' extension
creating build
creating build/lib.linux-x86_64-3.7
g++ -pthread -shared -B /home/liuhao/anaconda3/envs/mydetection_python3.7.3/compiler_compat -L/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,-rpath=/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,--no-as-needed -Wl,--sysroot=/ -L/usr/local/cuda/lib64 -lcudart -o build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
creating stub loader for _ext.cpython-37m-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/_ext.py to _ext.cpython-37.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying DCNv2.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying DCNv2.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying DCNv2.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying DCNv2.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
__pycache__._ext.cpython-37: module references __file__
creating dist
creating 'dist/DCNv2-0.1-py3.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing DCNv2-0.1-py3.7-linux-x86_64.egg
creating /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2-0.1-py3.7-linux-x86_64.egg
Extracting DCNv2-0.1-py3.7-linux-x86_64.egg to /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages
Adding DCNv2 0.1 to easy-install.pth file

Installed /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2-0.1-py3.7-linux-x86_64.egg
Processing dependencies for DCNv2==0.1
Finished processing dependencies for DCNv2==0.1
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
DCNv2-0.1-py3.7-linux-x86_64.egg文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
easy-install.pth

#==========================================================================
#会在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/生成:这个不在liuhao文件夹里面
build文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
DCNv2.egg-info文件夹
dist文件夹

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package              Version
-------------------- ------------------

DCNv2                0.1

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2-0.1-py3.7-linux-x86_64.egg
Requires: 
Required-by: 
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

pip install -e ./liuhao/

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip install -e ./liuhao/
Obtaining file:///home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao
Installing collected packages: DCNv2
  Running setup.py develop for DCNv2
Successfully installed DCNv2
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
easy-install.pth
DCNv2.egg-link

#==========================================================================
#会在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao/生成:
build文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
DCNv2.egg-info文件夹
_ext.cpython-37m-x86_64-linux-gnu.so


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package              Version            Location
-------------------- ------------------ --------------------------------------------------------------------------------

DCNv2                0.1                /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao
Requires: 
Required-by: 
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

python ./liuhao/setup.py develop

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ python ./liuhao/setup.py develop
running develop
running egg_info
creating DCNv2.egg-info
writing DCNv2.egg-info/PKG-INFO
writing dependency_links to DCNv2.egg-info/dependency_links.txt
writing top-level names to DCNv2.egg-info/top_level.txt
writing manifest file 'DCNv2.egg-info/SOURCES.txt'
reading manifest file 'DCNv2.egg-info/SOURCES.txt'
writing manifest file 'DCNv2.egg-info/SOURCES.txt'
running build_ext
building '_ext' extension
creating build
creating build/lib.linux-x86_64-3.7
g++ -pthread -shared -B /home/liuhao/anaconda3/envs/mydetection_python3.7.3/compiler_compat -L/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,-rpath=/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,--no-as-needed -Wl,--sysroot=/ -L/usr/local/cuda/lib64 -lcudart -o build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so -> 
Creating /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2.egg-link (link to .)
Adding DCNv2 0.1 to easy-install.pth file

Installed /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2
Processing dependencies for DCNv2==0.1
Finished processing dependencies for DCNv2==0.1
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
#==========================================================================
#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
easy-install.pth
DCNv2.egg-link


#会在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/生成:
build文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
DCNv2.egg-info文件夹
_ext.cpython-37m-x86_64-linux-gnu.so
#这个不在liuhao文件夹里面

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package              Version            Location
-------------------- ------------------ -------------------------------------------------------------------------

DCNv2                0.1                /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2

(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2
Requires: 
Required-by: 
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/1014880
推荐阅读
相关标签
  

闽ICP备14008679号