generated from ProtossDragoon/vscode-py-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 68b7667
Showing
10 changed files
with
402 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI - 디스코드 알림 | ||
|
||
# NOTE: 브랜치 지정 방법 | ||
# https://stackoverflow.com/questions/57699839/github-actions-how-to-target-all-branches-except-master | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
# NOTE: github 컨텍스트 변수와 디스코드 액션 사용법 | ||
# https://github.com/rjstone/discord-webhook-notify | ||
# https://docs.github.com/ko/actions/learn-github-actions/contexts | ||
jobs: | ||
discord_notify: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Send Notification to Discord | ||
uses: rjstone/[email protected] | ||
with: | ||
webhookUrl: ${{ secrets.DISCORD_WEBHOOK_URL }} | ||
username: ${{ github.event.repository.name }} | ||
severity: info | ||
avatarUrl: https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png | ||
text: | | ||
**${{ github.ref_name }}** 브랜치에 **${{ github.actor }}**님의 새로운 **${{ github.event_name }}**가 있어요! | ||
description: | | ||
${{ github.event.head_commit.message }} | ||
footer: | | ||
${{ github.ref_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
Pipfile.lock | ||
Pipfile | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
|
||
# Windows thumbnail cache files | ||
Thumbs.db | ||
Thumbs.db:encryptable | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msix | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"[python]": { | ||
"editor.formatOnSaveMode": "file", | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "eeyore.yapf", | ||
"editor.formatOnType": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
PROJECT = myproject | ||
|
||
all: install lint test format | ||
|
||
install: | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install --require-virtualenv -e .[dev] | ||
|
||
install-without-venv: | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -e .[dev] | ||
|
||
uninstall: | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip uninstall ${PROJECT} | ||
# NOTE: 이 패키지로 인해 설치된 의존성은 가상환경을 삭제하는 방식으로 제거되어야 합니다. | ||
|
||
lint: | ||
python3 -m pylint --rcfile=pylintrc ./${PROJECT} | ||
|
||
format: | ||
python3 -m yapf -ir . | ||
|
||
test: | ||
python3 -m unittest discover -s ./${PROJECT} -p "*_test.py" -v | ||
python3 -m unittest discover -s ./${PROJECT} -p "test_*.py" -v | ||
|
||
publish: | ||
python3 -m flit publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# vscode-py-template | ||
|
||
환경은 MacOS, Linux 를 기준으로 합니다. | ||
|
||
## 셋업 | ||
|
||
1. 프로젝트의 이름을 정해 `myproject`(가명) 디렉토리의 이름을 변경합니다 | ||
- 이때 `myproject` 는 파이썬에서 임포트가능한 이름이어야 합니다. (e.g. `tensorflow`, `torch`, `Flask`) | ||
- 소문자만으로 이루어진 단일단어로 구성하세요. *'_' 같은 것이 덕지덕지 붙으면 멋이 없어요.* | ||
- `Makefile`의 `PROJECT` 변수값을 동일하게 변경합니다. | ||
- `pyproject.yaml` 의 `name` 변수값을 동일하게 변경합니다. | ||
2. 가상환경을 준비하고 활성화한 다음 `make install` 명령을 실행합니다. | ||
- `make install` 은 개발 모드로 패키지를 설치합니다. | ||
- 개발 모드로 설치하는 것이기 때문에, 가상환경의 `site-package` 디렉토리에 소프트 링크를 거는 방식으로 작동합니다. | ||
- 동일한 가상환경을 사용하는 프로젝트에서 이 `myproject`(가명) 을 임포트해 사용할 수 있습니다. 이때, 현재 프로젝트 폴더 내에서 파일을 수정하면, 링크가 걸려 있기 때문에 `myproject` 를 사용하는 다른 프로젝트에서도 별도의 업데이트 없이 곧바로 수정내용이 반영됩니다. 물론, 이미 특정 모듈을 불러왔다면 파이썬을 닫았다가 다시 켜야 합니다. | ||
3. 디스코드를 사용하는 경우, 깃허브 액션 secret 변수 `DISCORD_WEBHOOK_URL` 을 지정합니다. | ||
- 알림을 보내고 싶은 디스코드 채널의 웹훅 URL을 값으로 등록합니다. | ||
- 관련 액션은 [ci-discord-noti.yml](.github/workflows/ci-discord-noti.yml) 입니다. | ||
|
||
## `Makefile` | ||
|
||
`Makefile`은 다음과 같은 기능들을 가지고 있습니다. | ||
|
||
### `make lint` | ||
|
||
- `.vscode` 설정을 사용하려면 `pylint` 익스텐션을 설치하세요. | ||
- 린터의 기본 세팅에 `pyproject.toml` 파일에 명시된 옵션을 오버라이딩해 코드를 린팅합니다. | ||
|
||
### `make format` | ||
|
||
- 포매터는 google의 `yapf`를 사용합니다. | ||
- `yapf` 포매터의 기본 세팅에 `pyproject.toml` 파일에 명시된 옵션을 오버라이딩해 코드를 포매팅합니다. | ||
- `.vscode` 설정을 사용하려면 `yapf` 익스텐션을 설치하세요. | ||
|
||
### `make test` | ||
|
||
- 테스트는 `unittest`를 사용합니다. | ||
- `test_*.py` 와 `*_test.py` 패턴을 모두 지원합니다. | ||
- 테스트 파일이 존재하는 위치까지 `__init__.py` 로 연결되어 있어야 합니다. | ||
|
||
### `make publish` | ||
|
||
- `~/.pypirc` 파일을 아래와 같이 작성하세요. | ||
``` | ||
[pypi] | ||
username = __token__ | ||
password = pypi-어쩌고저쩌고 # 개인 API 토큰을 발급받아 작성하세요. | ||
``` | ||
- 이 명령을 실행하면 `flit` 을 사용하여 PyPI 공개 레지스트리에 패키지를 푸시합니다. | ||
- 앞서 이름으로 지정한 `myproject`(가명)이 업로드되어, 전세계 누구나 `python3 -m pip install myproject`로 패키지를 설치해 사용할 수 있게 됩니다. |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
print(__file__) | ||
|
||
|
||
def hello_world(): | ||
print('hello world!') | ||
|
||
|
||
if __name__ == '__main__': | ||
print('hello!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import unittest | ||
|
||
|
||
class Testing(unittest.TestCase): | ||
|
||
def test_string(self): | ||
a = 'some' | ||
b = 'some' | ||
self.assertEqual(a, b) | ||
|
||
def test_boolean(self): | ||
a = True | ||
b = True | ||
self.assertEqual(a, b) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.