What is setup.py?

后端 未结 10 1658
囚心锁ツ
囚心锁ツ 2020-11-22 09:59

Can anyone please explain what setup.py is and how it can be configured or used?

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 10:51

    setup.py can be used in two scenarios , First, you want to install a Python package. Second, you want to create your own Python package. Usually standard Python package has couple of important files like setup.py, setup.cfg and Manifest.in. When you are creating the Python package, these three files will determine the (content in PKG-INFO under egg-info folder) name, version, description, other required installations (usually in .txt file) and few other parameters. setup.cfg is read by setup.py while package is created (could be tar.gz ). Manifest.in is where you can define what should be included in your package. Anyways you can do bunch of stuff using setup.py like

    python setup.py build
    python setup.py install
    python setup.py sdist  upload [-r urltorepo]  (to upload package to pypi or local repo)
    

    There are bunch of other commands which could be used with setup.py . for help

    python setup.py --help-commands
    

提交回复
热议问题