2

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your suggestion. So it looks like it isn't one of the kw args for setup then? I that overriding the sdist is a bit overkill.
You can pass dist_dir to setup() but you need to do that conditionally: don't do that for non bdist_* commands.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.