Junior
216
Why did you use makefile in Linux?
Answer from AI
sobes.tech AI
I used Makefile to automate routine tasks during Python development, such as:
- Installing dependencies:
install: pip install -r requirements.txt - Running tests:
test: pytest - Code style checking (linters):
lint: flake8 mypy - Building documentation:
docs: sphinx-build -b html docs/ build/html/ - Deploying the application (in simple cases):
deploy: @echo "Simulating deployment..." #scp -r . user@remote_server:/opt/myapp - Cleaning project of temporary files:
clean: find . -name '__pycache__' -delete find . -name '*.pyc' -delete rm -rf build dist *.egg-info
Advantages of using Makefile include:
- Simplifying workflows: Managing complex command sequences with a single
make <target>command. - Reproducibility: Ensuring the same actions are performed consistently regardless of environment.
- Efficiency: Makefile constructs a dependency graph and executes only necessary actions if files haven't changed.
- Standardization: Defines common targets (
install,test,clean) for the project, facilitating team collaboration.
Comparison table with manual command execution:
| Action | Without Makefile | With Makefile |
|---|---|---|
| Installing dependencies | pip install -r requirements.txt |
make install |
| Running tests | pytest |
make test |
| Code checking | flake8 .; mypy . |
make lint |
| Full build/test cycle | Sequential commands | make install test lint |