问题
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