Packaging As a Wheel
摘要
Deploying unpackaged source code into production environments introduces critical inconsistencies and causes deployment errors. Within the DevOps and DevSecOps frameworks, standardized software packaging is the fundamental methodology for ensuring installation consistency, seamless upgrades, and rigorous version control. This chapter provides a systematic analysis of Python project deployment, focusing on using setuptools and the build module to package not only core application modules but also essential documentation and supporting configuration files. In particular, we will examine a nonstandard yet highly effective architectural pattern: integrating the entire unit test suite directly into the source code deployment artifact (sdist). Although often omitted in standard development cycles, including tests in the source package is crucial for downstream pipelines. This ensures that, when transitioning from language-specific formats to platform-native infrastructures, such as compiling an RPM package from Python source code, the test suite remains fully accessible for performing localized validation during the native build sequence. Whether you’re a student learning to structure code for enterprise environments or an experienced administrator automating artifact generation, this guide provides the technical blueprint needed to ensure reproducible software deployment.