Skip to content

Instantly share code, notes, and snippets.

@giorgiovilardo
Last active September 7, 2020 11:17
Show Gist options
  • Save giorgiovilardo/ce7e32150a02446e826d9f3beec9b6c7 to your computer and use it in GitHub Desktop.
Save giorgiovilardo/ce7e32150a02446e826d9f3beec9b6c7 to your computer and use it in GitHub Desktop.
quick shell script to create a python+pytest project for my environment
if [ -z "$1" ]
then
echo "no argument given. pass a project name"
exit 1
fi
mkdir -p $1
cd $1
mkdir -p ".vscode"
mkdir -p "src/$1"
touch "src/$1/__init__.py"
mkdir -p "tests"
touch "tests/conftest.py"
touch "tests/pytest.ini"
touch ".vscode/settings.json"
touch "tox.ini"
touch "setup.py"
touch ".gitignore"
python3 -m venv env
source env/bin/activate
poetry init -n --name $1
poetry add -n -D rope mypy flake8 black pytest pytest-cov
echo "{
\"python.pythonPath\": \"env/bin/python\",
\"python.formatting.provider\": \"black\",
\"python.linting.pylintEnabled\": false,
\"python.linting.flake8Enabled\": true,
\"python.linting.mypyEnabled\": true,
\"python.linting.enabled\": true,
\"files.trimFinalNewlines\": true,
\"python.testing.pytestArgs\": [
\"tests\",
\"-s\",
\"-v\",
\"--cov=src\",
],
\"python.testing.unittestEnabled\": false,
\"python.testing.nosetestsEnabled\": false,
\"python.testing.pytestEnabled\": true,
}" > ".vscode/settings.json"
echo "[flake8]
exclude=.git,__pycache__,env
ignore=E231,E501,W503,E203" > "tox.ini"
echo "from setuptools import setup, find_packages
setup(
name=\"$1\",
version=\"0.1.0\",
packages=find_packages(where=\"src\"),
package_dir={\"\": \"src\"},
author=\"\",
author_email=\"\",
python_requires=\">=3.8\",
)" > "setup.py"
echo "env/
.mypy_cache/
.pytest_cache/
__pycache__/
.ropeproject/
notes.txt
.coverage
*.egg-info/
.DS_Store" > ".gitignore"
pip install -e .
git init
git add .
git commit -m "project setup"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment