Change output directory in setup.py

≡放荡痞女 提交于 2019-12-11 17:06:47

问题


I'm using setup from setuptools to create a setup.py, and I was wondering if it's possible to change the output directory programmatically to change it from dist/.

I'm aware that you can do this from the command line using the --dist-dir flag, but I want to be able to do from within the setup.py file instead.

Anyone have any ideas?


回答1:


You need to override code that set the default name:

from distutils.command.bdist import bdist as _bdist
from distutils.command.sdist import sdist as _sdist

dist_dir = 'my-dist-dir'

class bdist(_bdist):
    def finalize_options(self):
        _bdist.finalize_options(self)
        self.dist_dir = dist_dir

class sdist(_sdist):
    def finalize_options(self):
        _sdist.finalize_options(self)
        self.dist_dir = dist_dir

setup(
    cmdclass={
        'bdist': bdist,
        'sdist': sdist,
    },
    …
)

Other bdist_* commands copy the value from bdist.



来源:https://stackoverflow.com/questions/54627315/change-output-directory-in-setup-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!