Adding python-minimizer to PyCharm External Tools

Open the Settings dialog by clicking on the gear wheel in the upper right-hand corner.

Select Settings

On the left side of the Settings screen, expand the Tools entry and then select External Tools.

Click on the Plus sign.

Now, let's fill in the specifics for python-minimizer.

Enter a name for the tool in the name field. You can name it anything you like.

Enter a description for the tool.

In the Tool Settings section, we need to enter the Program. The Program field contains a path to the command the tool will execute.

PyCharm uses macros to help create the entries. Pressing the Plus sign on the right of the Program field shows a list of available macros. Select the desired option in the list to add a macro and then press Insert. The macro will be expanded in the macro preview window and added to the field.

The Program field should be edited to contain:

$PyInterpreterDirectory$/python-minimizer

After inserting the $PyInterpreterDirectory$, we manually append a slash and the name of the python-minimizer command.

Next, we add the command arguments to the Arguments field. I prefer not to have the original source file minified but to create a new file with "_min" appended to the file name.

To do this, we use the following arguments:

-o $FileNameWithoutExtension$_min.$FileExt$ $FilePath$

The -o option specifies the output file and $FilePath$ specifies the input file.

The Working Directory is set to $FileDir$

When you have completed entering all the information, click OK, and you should see that the Python-minimizer external tool has been created.