PyCharm 2024.2 Help

Create and run setup.py

PyCharm provides an action that helps create setup.py script, intended for building, distributing, and installing modules. Once setup.py is created, the corresponding action becomes disabled

Create setup.py

  1. In the Project tool window, select the package. Then, go to Tools | Create setup.py in the main menu.

  2. In the New Setup Script dialog, specify package name, its version, the author, the author email, the package description, and any licence details:

    Create a setup.py file
  3. Click OK when ready. PyCharm creates setup.py and opens it in the editor.

    The setup.py in the editor

    Note that PyCharm creates the setup.py file with the limited set of the arguments. You might want to manually add the rest of the needed details. For more information about setup.py arguments, refer to the Python Packaging User Guide.

When you work with any project that comes setup.py, you can run some tasks to build, install, and distribute packages described within the setup.py file. PyCharm helps you create the command-line sequence of the following format:

setup.py <task> <arguments>

Run a setup.py task

  1. In the main menu, go to Tools | Run setup.py.

  2. In the Enter setup.py task name dialog, type the letters of the task names.

    Run a setup script

    Note that asterisk wildcard and initial letters of the snake_case names are honored. As you type, the suggestion list shrinks to show the matching names only. Choose the desired task, and press Enter.

  3. In the Command Line field, enter the argument of the task to execute.

    Adding a CLI argument for the setup.py test

    You can leave this field empty if no arguments are needed.

  4. Once you click OK, the command line begins to execute in the Run tool window.

    Executing the setup.py task

    For more information about the setup.py command arguments, refer to Building and Distributing Packages with Setuptools.

Last modified: 26 May 2024