Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in build.py not logged helpfully in "BUILD FAILED" error message #638

Closed
dsynkov opened this issue Jul 15, 2019 · 0 comments · Fixed by #684
Closed

Errors in build.py not logged helpfully in "BUILD FAILED" error message #638

dsynkov opened this issue Jul 15, 2019 · 0 comments · Fixed by #684
Milestone

Comments

@dsynkov
Copy link

dsynkov commented Jul 15, 2019

Right now, when there is an error in the build.py script itself, the "BUILD FAILED" error message does not provide the full stack trace, nor does the logger provide information about the type of exception or line number. For example:

An AttributeError example in build.py

Given a sample task of:

@task('analyze')
def sample_task():
    import os
    os.getcd()

Where os.getcwd() is replaced with the incorrect os.getcd(), running pyb will print the following error message:

BUILD FAILED - module 'os' has no attribute 'getcd'

A more helpful error message would be:

BUILD FAILED - AttributeError: module 'os' has no attribute 'getcd' (build.py:37)

Where AttributeError is the type of exception, followed by the message, followed by the line number.

An KeyError example in build.py

Given a task of:

@task('analyze')
def sample_task():
    d = {'foo': 1, 'bar': 2}
    print(d['baz'])

The failure message will be:

BUILD FAILED - 'baz'

A more helpful error message would be:

BUILD FAILED - KeyError: 'baz' (build.py:22)

Where KeyError is the type of exception and 22 is the line number.

Potential Solution

Using sys.exc_info() to capture a tuple containing the exception type and traceback can provide the needed functionality to implement this. A sample implementation in the main method of clip.py might look something like:

        except PyBuilderException as e:
            exc_type, exc_obj, exc_tb = sys.exc_info()

            filename = exc_tb.tb_frame.f_code.co_filename
            lineno = exc_tb.tb_lineno

            msg = "{exc_type}: {e} ({filename}:{lineno})".format(
                exc_type=exc_type, e=e, filename=filename, lineno=lineno
            )

            print_build_status(str(msg), options, successful=False)
            return 1
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 30, 2019
1. Vendorization of dependencies.
2. New <build-dir>/.pybuilder is created in the project directory to house
PyB plugins and plugin dependencies.
3. Dependencies are installed in a venvs with an eye for multi-Python build environments via pyenv
4. New PIP install batching, utilizing pkg_resources and WorkingSet for package inspection.
5. Support for Python 3.7 and 3.8.

fixes pybuilder#644, pybuilder#623, pybuilder#607, pybuilder#606, pybuilder#638
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 30, 2019
1. Vendorization of dependencies.
2. New <build-dir>/.pybuilder is created in the project directory to house
PyB plugins and plugin dependencies.
3. Dependencies are installed in a venvs with an eye for multi-Python build environments via pyenv
4. New PIP install batching, utilizing pkg_resources and WorkingSet for package inspection.
5. Support for Python 3.7 and 3.8.

fixes pybuilder#644, pybuilder#623, pybuilder#607, pybuilder#606, pybuilder#638
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 30, 2019
1. Vendorization of dependencies.
2. New <build-dir>/.pybuilder is created in the project directory to house
PyB plugins and plugin dependencies.
3. Dependencies are installed in a venvs with an eye for multi-Python build environments via pyenv
4. New PIP install batching, utilizing pkg_resources and WorkingSet for package inspection.
5. Support for Python 3.7 and 3.8.

fixes pybuilder#644, pybuilder#623, pybuilder#607, pybuilder#606, pybuilder#638
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Nov 6, 2019
1. Vendorization of dependencies.
2. New <build-dir>/.pybuilder is created in the project directory to house
PyB plugins and plugin dependencies.
3. Dependencies are installed in a venvs with an eye for multi-Python build environments via pyenv
4. New PIP install batching, utilizing pkg_resources and WorkingSet for package inspection.
5. Support for Python 3.7 and 3.8.
6. Coverage accepts module exclusion patterns

fixes pybuilder#644, pybuilder#623, pybuilder#607, pybuilder#606, pybuilder#638
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Nov 6, 2019
1. Vendorization of dependencies.
2. New <build-dir>/.pybuilder is created in the project directory to house
PyB plugins and plugin dependencies.
3. Dependencies are installed in a venvs with an eye for multi-Python build environments via pyenv
4. New PIP install batching, utilizing pkg_resources and WorkingSet for package inspection.
5. Support for Python 3.7 and 3.8.
6. Coverage accepts module exclusion patterns

fixes pybuilder#644, pybuilder#623, pybuilder#607, pybuilder#606, pybuilder#638
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Nov 6, 2019
1. Vendorization of dependencies.
2. New <build-dir>/.pybuilder is created in the project directory to house
PyB plugins and plugin dependencies.
3. Dependencies are installed in a venvs with an eye for multi-Python build environments via pyenv
4. New PIP install batching, utilizing pkg_resources and WorkingSet for package inspection.
5. Support for Python 3.7 and 3.8.
6. Coverage accepts module exclusion patterns

fixes pybuilder#644, pybuilder#623, pybuilder#607, pybuilder#606, pybuilder#638
@arcivanov arcivanov added this to the v0.12.0 milestone Mar 20, 2020
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants