I want to unit test some Python extensions. To achieve this I'm running setup()
in a script:
from distutils.core import setup, Extension
import os
DIR = os.path.dirname(__file__)
def call_setup():
module1 = Extension('callbacks',
sources = [os.path.join(DIR, 'callbacks.c')])
setup(
script_name = 'setup.py',
script_args = ['build'],
name = 'PackageName',
ext_modules = [module1])
To avoid leaving junk in the test directory I want to cleanup the build after the tests run. I'd like to run distutils.command.clean.clean()
in the unittest tearDown()
. How do I get the dist
object for the distro that must be passed as an argument to clean()
?
Thanks
It looks like your call to setup()
should return a Distribution
instance.
See the
setup()
function for a list of keyword arguments accepted by theDistribution
constructor.setup()
creates a Distribution instance.