Muutke küpsiste eelistusi

E-raamat: Python Packages [Taylor & Francis e-raamat]

, (University of British Columbia)
  • Formaat: 222 pages, 8 Tables, black and white; 2 Line drawings, black and white; 43 Halftones, black and white; 45 Illustrations, black and white
  • Sari: Chapman & Hall/CRC The Python Series
  • Ilmumisaeg: 21-Apr-2022
  • Kirjastus: Chapman & Hall/CRC
  • ISBN-13: 9781003189251
  • Taylor & Francis e-raamat
  • Hind: 156,95 €*
  • * hind, mis tagab piiramatu üheaegsete kasutajate arvuga ligipääsu piiramatuks ajaks
  • Tavahind: 224,21 €
  • Säästad 30%
  • Formaat: 222 pages, 8 Tables, black and white; 2 Line drawings, black and white; 43 Halftones, black and white; 45 Illustrations, black and white
  • Sari: Chapman & Hall/CRC The Python Series
  • Ilmumisaeg: 21-Apr-2022
  • Kirjastus: Chapman & Hall/CRC
  • ISBN-13: 9781003189251
Python Packages introduces Python packaging at an introductory and practical level thats suitable for those with no previous packaging experience. Despite this, the text builds up to advanced topics such as automated testing, creating documentation, versioning and updating a package, and implementing continuous integration and deployment. Covering the entire Python packaging life cycle, this essential guide takes readers from package creation all the way to effective maintenance and updating.

Python Packages focuses on the use of current and best-practice packaging tools and services like poetry, cookiecutter, pytest, sphinx, GitHub, and GitHub Actions.

Features:





The books source code is available online as a GitHub repository where it is collaborated on, automatically tested, and built in real time as changes are made; demonstrating the use of good reproducible and clear project workflows. Covers not just the process of creating a package, but also how to document it, test it, publish it to the Python Package Index (PyPI), and how to properly version and update it. All concepts in the book are demonstrated using examples. Readers can follow along, creating their own Python packages using the reproducible code provided in the text. Focuses on a modern approach to Python packaging with emphasis on automating and streamlining the packaging process using new and emerging tools such as poetry and GitHub Actions.
List of Figures
xi
List of Tables
xiii
Preface xv
About the authors xix
1 Introduction
1(2)
1.1 Why you should create packages
2(1)
2 System setup
3(14)
2.1 The command-line interface
3(1)
2.2 Installing software
3(2)
2.2.1 Installing Python
3(1)
2.2.2 Install packaging software
4(1)
2.3 Register for a PyPI account
5(1)
2.4 Set up Git and GitHub
5(1)
2.5 Python integrated development environments
6(5)
2.5.1 Visual Studio Code
7(1)
2.5.2 JupyterLab
8(2)
2.5.3 RStudio
10(1)
2.6 Developing with Docker
11(6)
2.6.1 Docker with Visual Studio Code
12(2)
2.6.2 Docker with JupyterLab
14(3)
3 How to package a Python
17(66)
3.1 Counting words in a text file
17(5)
3.1.1 Developing our code
17(3)
3.1.2 Turning our code into functions
20(2)
3.2 Package structure
22(4)
3.2.1 A brief introduction
22(1)
3.2.2 Creating a package structure
23(3)
3.3 Put your package under version control
26(4)
3.3.1 Set up local version control
26(1)
3.3.2 Set up remote version control
27(3)
3.4 Packaging your code
30(2)
3.5 Test drive your package code
32(5)
3.5.1 Create a virtual environment
32(1)
3.5.2 Installing your package
33(4)
3.6 Adding dependencies to your package
37(6)
3.6.1 Dependency version constraints
40(3)
3.7 Testing your package
43(6)
3.7.1 Writing tests
43(2)
3.7.2 Running tests
45(3)
3.7.3 Code coverage
48(1)
3.8 Package documentation
49(23)
3.8.1 Writing documentation
52(2)
3.8.2 Writing docstrings
54(5)
3.8.3 Creating usage examples
59(1)
3.8.4 Building documentation
60(9)
3.8.5 Hosting documentation online
69(3)
3.9 Tagging a package release with version control
72(2)
3.10 Building and distributing your package
74(5)
3.10.1 Building your package
74(4)
3.10.2 Publishing to TestPyPI
78(1)
3.10.3 Publishing to PyPI
79(1)
3.11 Summary and next steps
79(4)
4 Package structure and distribution
83(28)
4.1 Packaging fundamentals
83(6)
4.2 Package structure
89(14)
4.2.1 Package contents
89(3)
4.2.2 Package and module names
92(1)
4.2.3 Intra-package references
93(1)
4.2.4 The init file
94(3)
4.2.5 Including non-code files in a package
97(1)
4.2.6 Including data in a package
98(3)
4.2.7 The source layout
101(2)
4.3 Package distribution and installation
103(7)
4.3.1 Package installation
104(3)
4.3.2 Building sdists and wheels
107(1)
4.3.3 Packaging tools
108(1)
4.3.4 Package repositories
109(1)
4.4 Version control
110(1)
5 Testing
111(28)
5.1 Testing workflow
111(3)
5.2 Test structure
114(2)
5.3 Writing tests
116(10)
5.3.1 Unit tests
116(4)
5.3.2 Test that a specific error is raised
120(3)
5.3.3 Integration tests
123(1)
5.3.4 Regression tests
124(2)
5.3.5 How many tests should you write
126(1)
5.4 Advanced testing methods
126(6)
5.4.1 Fixtures
127(2)
5.4.2 Parameterizations
129(3)
5.5 Code coverage
132(6)
5.5.1 Line coverage
133(1)
5.5.2 Branch coverage
134(1)
5.5.3 Calculating coverage
134(2)
5.5.4 Coverage reports
136(2)
5.6 Version control
138(1)
6 Documentation
139(26)
6.1 Documentation content and workflow
139(4)
6.2 Writing documentation
143(11)
6.2.1 README
144(1)
6.2.2 License
145(1)
6.2.3 Contributing guidelines
146(1)
6.2.4 Code of conduct
146(1)
6.2.5 Changelog
147(1)
6.2.6 Examples
148(2)
6.2.7 Docstrings
150(3)
6.2.8 Application programming interface (API) reference
153(1)
6.2.9 Other package documentation
153(1)
6.3 Building documentation
154(8)
6.4 Hosting documentation online
162(3)
7 Releasing and versioning
165(20)
7.1 Version numbering
165(3)
7.2 Version bumping
168(4)
7.2.1 Manual version bumping
168(1)
7.2.2 Automatic version bumping
169(3)
7.3 Checklist for releasing a new package version
172(9)
7.3.1 Step 1: make changes to package source files
173(1)
7.3.2 Step 2: document your changes
173(1)
7.3.3 Step 3: bump version number
174(2)
7.3.4 Step 4: run tests and build documentation
176(1)
7.3.5 Step 5: tag a release with version control
177(1)
7.3.6 Step 6: build and release package to PyPI
178(3)
7.4 Automating releases
181(1)
7.5 Breaking changes and deprecating package functionality
181(2)
7.6 Updating dependency versions
183(2)
8 Continuous integration and deployment
185(34)
8.1 An introduction to CI/CD
185(1)
8.2 CI/CD tools
186(1)
8.3 Introduction to GitHub Actions
187(6)
8.3.1 Key concepts
187(1)
8.3.2 A toy example
188(4)
8.3.3 Actions and commands
192(1)
8.4 Setting up continuous integration
193(7)
8.4.1 Setup
193(3)
8.4.2 Running tests
196(1)
8.4.3 Recording code coverage
196(1)
8.4.4 Build documentation
197(1)
8.4.5 Testing continuous integration
198(2)
8.5 Setting up continuous deployment
200(14)
8.5.1 Setup
201(3)
8.5.2 Automatically creating a new package version
204(3)
8.5.3 Uploading to TestPyPI and PyPI
207(3)
8.5.4 Testing continuous deployment
210(4)
8.6 Summary
214(5)
Bibliography 219(2)
Index 221
Tomas Beuzen is a data scientist and educator based in Sydney, Australia. He has a background in coastal engineering and climate science and was a teaching fellow for the Master of Data Science program at the University of British Columbia, Vancouver. He currently spends his time developing open-source, educational data science material and using data science to solve problems in the natural and engineered world.

Tiffany Timbers is an Assistant Professor of Teaching in the Department of Statistics and a Co-Director for the Master of Data Science program at the University of British Columbia, Vancouver. In these roles she teaches and develops curriculum around the responsible application of Data Science to solve real-world problems.