[Python, shell script, team development] Create a nifty Git repository

Overview

Here's how to make your Git repository more accessible with ** three-line shell scripts ** and ** a little care **.

Even if it's not python

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.

What is a shell script?

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.

I want you to use it at such times

--When a new member is assigned to the development team. --When you want to make Git code ** usable immediately after cloning **.

Preparation

python3 -m venvcommand python3 -m pipcommand Please prepare an environment where you can use.

Main subject

This is the main subject.

Creating requirements.txt

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 freezeYou 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.

Creating a shell script

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.

Code commentary

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

[Python, shell script, team development] Create a nifty Git repository
Create a shell script to run the python file multiple times
Create a New Todoist Task from Python Script
Launch a shell while a Python script is running
Create a Python virtual development environment on Windows
Create a Python module
Create a Python environment
Create a comfortable Python 3 (Anaconda) development environment on windows
Create a python development environment with vagrant + ansible + fabric
Python script to create a JSON file from a CSV file
Create a decent shell and python environment on Windows
Create a Python development environment on OS X Lion
Create a local pypi repository
Create a dictionary in Python
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Let's create a script that registers with Ideone.com in Python.
Let's try a shell script
Create a python numpy array
Create a simple Python development environment with VSCode & Docker Desktop
Create a Python script for Wake on LAN (NAT traversal Wake on LAN [5])
Create a directory with python
I wrote a script to create a Twitter Bot development environment quickly with AWS Lambda + Python 2.7
I wrote a function to load a Git extension script in Python
Create a simple Python development environment with VS Code and Docker
Create a python GUI using tkinter
Create a DI Container in Python
Create a Python environment on Mac (2017/4)
Create a virtual environment with Python!
Create a binary file in Python
Create a python environment on centos
Create a Python general-purpose decorator framework
Create a Kubernetes Operator in Python
5 Ways to Create a Python Chatbot
Launch a Python script as a service
Create a random string in Python
Write a batch script with Python3.5 ~
Create a Python development environment locally at the fastest speed (for beginners)
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Create a Python function decorator with Class
Create a new Python numerical calculation project
How to create a git clone folder
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
Create a python environment on your Mac
Create a simple GUI app in Python
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Let's create a free group with Python
Create a JSON object mapper in Python
[Python] Create a Batch environment using AWS-CDK
[Ubuntu] How to execute a shell script
Run the Python interpreter in a script
[Python] [LINE Bot] Create a parrot return LINE Bot
Create a star system with Blender 2.80 script
Create a word frequency counter with Python 3.4
Create a deb file from a python package
Manage logrotate generations with a shell script.
[Python] Create a LineBot that runs regularly
[GPS] Create a kml file in Python
How to create a repository from media
Use Django from a local Python script