abantos / bolt

A task automation tool (similart to grunt) for Python
MIT License
15 stars 8 forks source link

Setup Task Swallows Errors Building Distribution #87

Closed CurroRodriguez closed 7 years ago

CurroRodriguez commented 7 years ago

Description

The current implementation of the Setup task does not evaluate the return object from distutils.core.run_setup() and it just assumes it works. Unfortunately, some environments will not have the right tools to build a distribution; therefore, the task will silently fail.

I found this problem in another project's pipeline where building a wheel inside the official Python 2.7 Docker container silently failed because the wheel package is not installed by default like when creating a virtual environment.

Steps to Reproduce

The current behavior shows that the return code from distutils.core.run_setup() invoked by the task is not evaluated, and the task seems to succeed; however, the .whl file has not been created.

An exception is expected to be raised if the wheel doesn't succeed.

Fix Analysis

Looking at the implementation of distutils.core.run_setup(), you can see the function returns a Distribution instance. The instance exposes a dist_files property, which is empty if the distribution failed to build. If it succeeds, the return value is a list of tuples containing information about each distribution. This allow us to fix the problem, or at list report an error if no distribution was built, by checking the contents of dist_files; something like the following code:

# dcore is an alias to distutils.core.
dist_info = dcore.run_setup(self.setup_script, self.args)
if not dist_info.dist_files:
    raise DistributionBuildError()

NOTE:I need to think on how to handle multiple distributions; although, I believe right now the task only supports one distribution per configuration.

The following is an example of the contents of the dist_files property:

[('bdist_wheel', '3.5', 'D:\\Projects\\Abantos\\bolt\\dist\\bolt_ta-0.2.1-py2.py3-none-any.whl')]

Acceptance Criteria

Raises exception if building the distribution fails.

CurroRodriguez commented 7 years ago

Issue #87: Setup Task Swallows Errors Building Distribution