Updated on 2026-01-08 GMT+08:00

Using Setuptools for Build

In this action, you build a Python project with Setuptools.

Preparations

When using setuptools to pack the code, ensure that the setup.py file exists in the root directory of the code. For details on how to write the setup file, see the official instructions of Python.

Graphical Build

Add Build with Setuptools, when configuring build actions.

The parameters are described in the following table.

Parameter

Description

Action Name

Name of a build action. It can be customized.

Tool Version

Select a tool version.

Commands

Configure the pack commands.

  • You can use the default commands to pack the file into an .egg file.
  • For Python 2.7 or later, it is advised to use python setup.py sdist bdist_wheel to pack the source code package and .whl installation package for pip installation.

Code-based Build

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
version: 2.0 # The value must be 2.0.
steps:
  BUILD:
    - python: 
        name: Build with Setuptools
        image: cloudbuild@python3.6
        inputs: 
          command: |
            pip config set global.index-url https://pypi.org/simple
            pip config set global.trusted-host repo.xxcloud.com
            python setup.py bdist_egg

Parameter

Type

Description

Mandatory

Default Value

name

/

Name of a build action. It can be customized.

No

None

image

/

Image version. cloudbuild@ is a fixed part, followed by the supported Python version. You can view the tool versions supported for Build with Setuptools in the graphical build mode.

No

cloudbuild@python3.6

command

string

Commands to be run. Enter related code.

Yes

None