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
Create a setup task that builds a simple distribution wheel.
Create a virtual environment, activate it, and uninstall the wheel package.
Run the setup task within the environment.
Check the dist folder, which will be empty.
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:
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 thewheel
package is not installed by default like when creating a virtual environment.Steps to Reproduce
wheel
package.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 aDistribution
instance. The instance exposes adist_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 ofdist_files
; something like the following code:The following is an example of the contents of the
dist_files
property:Acceptance Criteria
Raises exception if building the distribution fails.