Название: Hypermodern Python Tooling: Building Reliable Workflows for an Evolving Python Ecosystem (8th Early Release) Автор: Claudio Jolowicz Издательство: O’Reilly Media, Inc. Год: 2024-04-16 Страниц: 501 Язык: английский Формат: pdf, epub Размер: 10.1 MB
Keeping up with the Python ecosystem can be daunting. Its developer tooling doesn't provide the out-of-the-box experience native to languages like Rust and Go. When it comes to long-term project maintenance or collaborating with others, every Python project faces the same problem: how to build reliable workflows beyond local development while staying in sync with the evolving ecosystem.
With this hands-on guide, Python developers will learn how to forge the moving parts of a Python project into an easy-to-use toolchain, using state-of-the-art tools including Poetry, Nox, GitHub Actions, Dependabot, pytest, mypy, pre-commit, Black, Ruff, and more. Author Claudio Jolowicz shows you how to create robust Python project structures complete with unit tests, static analysis, code formatting, type checking, and documentation as well as continuous integration and delivery.
Python folks use the word package for two distinct concepts. Import packages are Python modules that contain other modules, typically directories with an __init__.py file. Distribution packages are archive files for distributing Python software— they are the subject of this chapter. Creating a package from your project makes it easy to share your code with others. Packaging also has a less obvious benefit: Installing your project as a package makes it a first-class citizen of a Python environment. The metadata in a package specifies the minimum Python version and any third-party packages it depends on. Installers ensure the environment matches these prerequisites; they even install missing project dependencies and upgrade those whose version doesn’t match the requirements. Once installed, the package has an explicit link to the environment it’s installed in. Compare this to running a script from your working directory, which may well end up on an outdated Python version, or in an environment that doesn’t have all the dependencies installed.
Python programs often target several versions of the language and standard library at once. This may come as a surprise. Why would you run your code with anything but the latest Python? After all, this lets your programs benefit from new language features and library improvements immediately. As it turns out, runtime environments often come with a variety of older versions of Python. Even if you have tight control over your deployment environments, you may want to get into the habit of testing against multiple versions. The day the trusty Python in your production environment features in a security advisory better not be the day you start porting your code to newer releases.
You'll learn how to:
Create open source projects with state-of-the-art infrastructure Build a custom infrastructure for all Python projects in a company or team Improve and modernize the infrastructure of an existing Python project Evaluate modern Python tooling for adoption in existing projects Use tools for packaging and dependency management Automate common development tasks such as testing, dependency updates, and publishing releases
Who Should Read This Book? If you’re one of these people, you’ll benefit from reading this book:
• You’re proficient with Python, but you’re not sure how to create a package. • You’ve been doing this for years— setuptools, virtualenv, and pip are your friends. You’re curious about recent developments in tooling and what they bring to the table. • You maintain mission-critical code that runs in production. But there must be a better way to do all of this. You want to learn about state-of-the art tools and evolving best practices. • You want to be more productive as a Python developer. • You’re an open source maintainer looking for a robust and modern project infrastructure. • You’re using a bunch of Python tools in your projects, but it’s hard to see how everything fits together. You want to reduce the friction that comes with all this tooling. • “Things just keep breaking— why doesn’t Python find my module now? Why can’t I import the package I just installed?”
This book assumes that you have a basic knowledge of the Python programming language. The only tooling you need to be familiar with are the Python interpreter, an editor or IDE, and the command line of your operating system.
Скачать Hypermodern Python Tooling, 8th Early Release