Courseiva
SDLC AutomationhardMultiple ChoiceObjective-mapped

DOP-C02 SDLC Automation Practice Question

Exhibit

Refer to the exhibit.
version: 0.2
phases:
  install:
    runtime-versions:
      python: 3.8
  pre_build:
    commands:
      - pip install flake8
      - flake8 src/
  build:
    commands:
      - python setup.py build
  post_build:
    commands:
      - python -m unittest discover
artifacts:
  files:
    - '**/*'
  discard-paths: yes

Refer to the exhibit. The above buildspec.yml is used in AWS CodeBuild. The build is failing during the 'build' phase with a 'FileNotFoundError: setup.py' error. What is the MOST likely cause?

⚠ Common exam trap

Watch out — candidates often confuse the build phase error with post_build test failures or artifact configuration issues, but the specific 'FileNotFoundError: setup.py' message directly points to a missing source file, not a runtime or configuration problem.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The source code does not contain a setup.py file in the root directory.

The error 'FileNotFoundError: setup.py' indicates that the build process is attempting to run a command (likely `python setup.py install` or `pip install -e .`) that requires a `setup.py` file in the root directory of the source code. Since the buildspec.yml does not explicitly override the default build commands, CodeBuild uses the default build command for Python, which expects `setup.py` to be present. Option A is correct because the most likely cause is that the source code repository lacks a `setup.py` file in its root directory, causing the build phase to fail.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The source code does not contain a setup.py file in the root directory.

    Why this is correct

    The build phase executes `python setup.py build`, which requires a `setup.py` file to be present in the current working directory (the root of the source checkout). If the repository lacks this file—for instance, if it uses `pyproject.toml` or is a plain script—the Python interpreter exits with `python: can't open file 'setup.py': [Errno 2] No such file or directory`, causing the build to fail. This error occurs during the build phase, so no later phases are reached.

  • The unit tests in the post_build phase are failing.

    Why it's wrong here

    The `post_build` phase runs only after the `build` phase has completed successfully. Because the failure happens during the `build` phase while running `python setup.py build`, the `post_build` commands—including any unit test execution—are never executed. Even if a test in `post_build` were failing, it would not produce this build-phase error; the reported error is specifically a missing `setup.py` file in the source root.

  • The Python version 3.8 is not supported by CodeBuild.

    Why it's wrong here

    AWS CodeBuild's managed Python images include Python 3.8 in their supported runtime versions, so specifying `python: 3.8` is valid and fully supported. If the runtime version were unsupported, CodeBuild would fail during environment preparation, not with a missing-file error from the build command. The runtime configuration has no bearing on whether `setup.py` exists in the repository, so it cannot explain this failure.

  • The artifacts configuration discarding paths is causing the error.

    Why it's wrong here

    The `artifacts` configuration determines what output files are collected and uploaded after a successful build; it does not affect the execution of build phase commands. Setting `discard-paths: yes` merely strips directory paths when files are copied to the destination S3 bucket, which happens after the build completes. This configuration cannot cause a command in the `build` phase to fail and is entirely unrelated to the `setup.py` missing-file error.

About these practice questions

This DOP-C02 question is part of Courseiva's 251-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.