Skip to content

Commit

Permalink
Initial expansion on Roman's original version: VS Code configs, pylin…
Browse files Browse the repository at this point in the history
…t, proprietary license option, src/ folder, pyenv+gh added to instructions, and a few bug fixes
  • Loading branch information
Jens Roland committed Feb 27, 2022
1 parent 7a92979 commit 1ae07c3
Show file tree
Hide file tree
Showing 34 changed files with 744 additions and 874 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ assignees:

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [ ] I've searched the project's [`issues`](https://github.com/TezRomacH/python-package-template/issues?q=is%3Aissue).
- [ ] I've searched the project's [`issues`](https://github.com/JensRoland/python-package-template/issues?q=is%3Aissue).

## ❓ Question

Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<!-- Mark with an `x` all the checkboxes that apply (like `[x]`) -->

- [ ] I've read the [`CODE_OF_CONDUCT.md`](https://github.com/TezRomacH/python-package-template/blob/master/CODE_OF_CONDUCT.md) document.
- [ ] I've read the [`CONTRIBUTING.md`](https://github.com/TezRomacH/python-package-template/blob/master/CONTRIBUTING.md) guide.
- [ ] I've read the [`CODE_OF_CONDUCT.md`](https://github.com/JensRoland/python-package-template/blob/master/CODE_OF_CONDUCT.md) document.
- [ ] I've read the [`CONTRIBUTING.md`](https://github.com/JensRoland/python-package-template/blob/master/CONTRIBUTING.md) guide.
- [ ] I've updated the code style using `make codestyle`.
- [ ] I've written tests for all new methods and classes that I created.
- [ ] I've written the docstring in `Google` format for all the methods and classes that I used.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v2.3.2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: make poetry-download

- name: Set up cache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
Expand Down
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ repos:
rev: v2.5.0
hooks:
- id: check-yaml
name: Validate YAML syntax
exclude: ^{{ cookiecutter.project_name }}/.github/
- id: end-of-file-fixer
exclude: LICENSE
name: Fix End-of-File blank lines
exclude: ^(LICENSE|requirements.txt)$

- repo: local
hooks:
- id: pyupgrade
name: pyupgrade
name: pyupgrade - Upgrade Python code to the latest standard
entry: poetry run pyupgrade --py37-plus
exclude: ^{{ cookiecutter.project_name }}/
types: [python]
Expand All @@ -24,7 +26,7 @@ repos:
- repo: local
hooks:
- id: isort
name: isort
name: isort - reorder Python imports
entry: poetry run isort --settings-path pyproject.toml
exclude: ^{{ cookiecutter.project_name }}/
types: [python]
Expand All @@ -33,7 +35,7 @@ repos:
- repo: local
hooks:
- id: black
name: black
name: black - reformat Python code
entry: poetry run black --config pyproject.toml
exclude: ^{{ cookiecutter.project_name }}/
types: [python]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ PYTHONPATH := `pwd`
#* Poetry
.PHONY: poetry-download
poetry-download:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(PYTHON) -
curl -sSL https://install.python-poetry.org | $(PYTHON) -

.PHONY: poetry-remove
poetry-remove:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(PYTHON) - --uninstall
curl -sSL https://install.python-poetry.org | $(PYTHON) - --uninstall

#* Installation
.PHONY: install
Expand Down
166 changes: 79 additions & 87 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Vulnerabilities can be reported by emailing core members:

- Roman Tezikov [tez.romach@gmail.com](mailto:tez.romach@gmail.com)
- Jens Roland [mail@jensroland.com](mailto:mail@jensroland.com)

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

Expand Down
14 changes: 7 additions & 7 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"project_name": "python-project",
"project_description": "Awesome `{{ cookiecutter.project_name.lower().replace(' ', '-') }}` is a Python cli/package created with https://github.com/TezRomacH/python-package-template",
"project_description": "{{ cookiecutter.project_name.lower().replace(' ', '-') }} is a python project",
"organization": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}",
"license": ["MIT", "BSD-3", "GNU GPL v3.0", "Apache Software License 2.0"],
"license": ["MIT", "BSD-3", "GNU GPL v3.0", "Apache Software License 2.0" ,"Proprietary"],
"_all_python_minor_version": [7, 8, 9],
"minimal_python_version": [3.7, 3.8, 3.9],
"github_name": "{{ cookiecutter.organization.lower().replace(' ', '_').replace('-', '_') }}",
"email": "hello@{{ cookiecutter.organization.lower().replace(' ', '-') }}.com",
"minimum_python_version": [3.7, 3.8, 3.9],
"github_username": "{{ cookiecutter.organization.lower().replace(' ', '_').replace('-', '_') }}",
"email": "mail@{{ cookiecutter.organization.lower().replace(' ', '-') }}.com",
"version": "0.1.0",
"line_length": 88,
"create_example_template": ["cli", "none"],
"line_length": 120,
"create_example_template": ["none", "cli"],

"_copy_without_render": [
"poetry.lock"
Expand Down
29 changes: 18 additions & 11 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
ORGANIZATION = "{{ cookiecutter.organization }}"

# Values to generate github repository
GITHUB_USER = "{{ cookiecutter.github_name }}"
GITHUB_USER = "{{ cookiecutter.github_username }}"

licences_dict = {
"MIT": "mit",
"BSD-3": "bsd3",
"GNU GPL v3.0": "gpl3",
"Apache Software License 2.0": "apache",
"Proprietary": "proprietary",
}


Expand All @@ -48,7 +49,7 @@ def remove_unused_files(directory: Path, module_name: str, need_to_remove_cli: b
files_to_delete: List[Path] = []

def _cli_specific_files() -> List[Path]:
return [directory / module_name / "__main__.py"]
return [directory / "src" / module_name / "__main__.py"]

if need_to_remove_cli:
files_to_delete.extend(_cli_specific_files())
Expand All @@ -57,7 +58,7 @@ def _cli_specific_files() -> List[Path]:
path.unlink()


def print_futher_instuctions(project_name: str, github: str) -> None:
def print_further_instructions(project_name: str, directory: Path, github: str) -> None:
"""Show user what to do next after project creation.
Args:
Expand All @@ -69,27 +70,31 @@ def print_futher_instuctions(project_name: str, github: str) -> None:
1) Now you can start working on it:
$ cd {project_name} && git init
$ cd {directory} && git init -b main
2) If you don't have Poetry installed run:
2) If your system Python version is not {{ cookiecutter.minimum_python_version }} or higher:
$ pyenv local $(pyenv versions | grep ' {{ cookiecutter.minimum_python_version }}' | xargs)
3) If you don't already have Poetry installed:
$ make poetry-download
3) Initialize poetry and install pre-commit hooks:
4) Initialize Poetry and install pre-commit hooks:
$ make install
$ make pre-commit-install
4) Run codestyle:
5) Activate virtual environment shell:
$ make codestyle
$ source "$(poetry env list --full-path | grep Activated | cut -d' ' -f1)/bin/activate"
5) Upload initial code to GitHub:
6) Upload initial code to GitHub:
$ git add .
$ git commit -m ":tada: Initial commit"
$ git branch -M main
$ git remote add origin https://github.com/{github}/{project_name}.git
$ gh repo create --private {github}/{project_name}
$ git push -u origin main
"""
print(textwrap.dedent(message))
Expand All @@ -102,7 +107,9 @@ def main() -> None:
module_name=PROJECT_MODULE,
need_to_remove_cli=CREATE_EXAMPLE_TEMPLATE != "cli",
)
print_futher_instuctions(project_name=PROJECT_NAME, github=GITHUB_USER)
print_further_instructions(
project_name=PROJECT_NAME, directory=PROJECT_DIRECTORY, github=GITHUB_USER
)


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 1ae07c3

Please sign in to comment.