Managing FastAPI Projects with Poetry: A Step-by-Step Guide

Image
This guide will walk you through how to use Poetry to manage dependencies and structure your project in FastAPI . It includes detailed explanations of Poetry's core concepts and commands to help prevent issues that can arise during team collaboration and deployment. 1. What is Poetry? Poetry is a dependency management and packaging tool for Python. It goes beyond simply installing libraries by allowing you to clearly declare the dependencies your project needs and ensuring that all developers on the project have the same library versions. Clarity in Dependency Management : Explicitly manage your project's basic information and required libraries through the pyproject.toml file. Reproducible Builds : By locking all dependency versions in the poetry.lock file, it fundamentally prevents "it works on my machine" problems. Integrated Development Environment : It automatically creates and manages isolated virtual environments for each project and handles mo...

How to get rid of ^M from a text file on Linux or Unix

^M

When you transfer text files from Windows to Linux or Unix systems, you often see '^M' characters at the end of lines. This happens because Windows and Linux/Unix handle line breaks differently—Windows uses CR+LF (\r\n), while Linux/Unix just uses LF (\n).

In this guide, we’ll look at a few simple ways to remove these characters and explain how each method works.

$ cat -v HelloWorld.java

public class HelloWorld^M
{^M
	public static void main(String[] args) {^M
		System.out.println("Hello World!");^M
	}^M
}^M

Using the dos2unix command

The dos2unix command is a simple and widely used method.

$ dos2unix filename

Using vi/vim editor

In Vi/Vim, You can directly search for and remove the '^M' character. The command above searches for '^M' at the end of each line throughout the entire file and removes it.

To input '^M', push Ctrl down and then press v and n consecutively.

  • Vim on Linux: 'Ctrl + v + m'
  • Gvim on Windows: 'Ctrl + q + m'
  • '\015' instead of '^M'

:%s/^M$//g

Using sed (stream editor)

sed is a stream editor, which is a tool that allows you to automatically modify the contents of a file. The above command removes the '^M' characters from the original file and saves the result to a new file.

Note that ^M must be entered by pressing 'Ctrl + v + m', or you can use '\r' as an alternative.
$ sed -e "s/^M//g" org_file > new_file
$ sed 's/\r//g' org_file > new_file

Comments

Popular posts from this blog

Resolving Key Exchange Failure When Connecting with SecureCRT to OpenSSH

SecureCRT] How to Back Up and Restore SecureCRT Settings on Windows

How to Set Up Vaultwarden (Bitwarden) on Synology NAS (Best Free Alternative to LastPass)