How to run 'python setup.py install' from within Python?

后端 未结 6 1918
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 17:15

I\'m trying to create a generic python script for starting up a python app and I would like to install any dependent python modules if they are missing from the target system.

6条回答
  •  粉色の甜心
    2021-02-05 18:09

    Way late - but if someone finds him/herself here like I did - this worked for me; (python 3.4). My script was one package down from setup.py. Note, you have to have chmod +x on setup.py, I believe.

    cwd = os.getcwd()
    parent = os.path.dirname(cwd)
    os.chdir(parent)
    os.system("python setup.py sdist")
    

提交回复
热议问题