Here's how to make your Git repository more accessible with ** three-line shell scripts ** and ** a little care **.
This time, I'm assuming a repository where Python code is placed, but I think that it is necessary to prepare the development environment before writing code in any language. By practicing what is described in this article, I think that when a new member joins the development team, for example, that member will be able to start development quickly and easily.
I think this article is the easiest to understand. Simply put, the shell is the Linux command you normally use (ls, cd, ...). If you write a list of Linux commands in a file with the extension `` `.sh```, it will be executed line by line when executed.
--When a new member is assigned to the development team. --When you want to make Git code ** usable immediately after cloning **.
python3 -m venv
command
python3 -m pip
command
Please prepare an environment where you can use.
This is the main subject.
First, let's create a file called `` `requirements.txtin the same hierarchy as
README.md``` in the Git repository. Below is an example,
requirements.txt
Django==3.1.3
Pillow==8.0.1
python3 -m pip freeze
You can get a list of currently installed packages with the command, so
python3 -m pip freeze > requirements.txt
I think you can update `` `requirements.txt``` immediately.
Next, let's create a install.sh
shell script file in the same hierarchy.
Then add the following code to the file.
install.sh
python3 -m venv env
source ./env/bin/activate
cat requirements.txt | xargs -I@ python3 -m pip install @
This file is
source install.sh
You can do it with. After execution, a virtual environment of python will be created, and the necessary packages will be installed there.
python3 -m venv env
-> Create a virtual environment (independent Python package space) named env
source ./env/bin/activate
-> Enable the virtual environment created in the first line
#### **`cat requirements.txt | xargs -I@ python3 -m pip install @ `**
```txt | xargs -I@ python3 -m pip install @
-> Pass the packages described in requirements.txt to the argument of the `` `python3 -m pip install` `` command using [pipe](https://qiita.com/akym03/items/aadef9638f78e222de22) I will.
# At the end
Now you can create a nice repository!
Friendly to new development members!
# Super digression
For those who can, Docker or Vagrant may seem more like it.
This is completely subjective, but recently, there are many cases where IT companies hire information students who have no experience in team development as part-time jobs or internships.
For such students, it is difficult to receive a Dockerfile and say `` `docker run``` or `` `vagrant up``` and ssh. (Actual experience)
However, even an information university student who is a beginner in development has touched Linux.
For such beginner students, give the shell script file gently and gently.
Recommended Posts