generated from Templates/Python
✅ Ready to clone and code.
This commit is contained in:
parent
e0913490c3
commit
a01f457da3
@ -16,10 +16,10 @@ echo "Description: $description";
|
|||||||
|
|
||||||
echo "Renaming project..."
|
echo "Renaming project..."
|
||||||
|
|
||||||
original_author="author_name"
|
original_author="Projects"
|
||||||
original_name="project_name"
|
original_name="python_test_project"
|
||||||
original_urlname="project_urlname"
|
original_urlname="python_test_project"
|
||||||
original_description="project_description"
|
original_description="Awesome python_test_project created by Projects"
|
||||||
# for filename in $(find . -name "*.*")
|
# for filename in $(find . -name "*.*")
|
||||||
for filename in $(git ls-files)
|
for filename in $(git ls-files)
|
||||||
do
|
do
|
||||||
@ -30,7 +30,7 @@ do
|
|||||||
echo "Renamed $filename"
|
echo "Renamed $filename"
|
||||||
done
|
done
|
||||||
|
|
||||||
mv project_name $name
|
mv python_test_project $name
|
||||||
|
|
||||||
# This command runs only once on GHA!
|
# This command runs only once on GHA!
|
||||||
rm -rf .gitea/template.yml
|
rm -rf .gitea/template.yml
|
||||||
|
@ -1 +0,0 @@
|
|||||||
author: rochacbruno
|
|
@ -23,4 +23,4 @@ jobs:
|
|||||||
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }}
|
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }}
|
||||||
with:
|
with:
|
||||||
args: >
|
args: >
|
||||||
-Dsonar.projectKey=project_name
|
-Dsonar.projectKey=python_test_project
|
@ -32,7 +32,7 @@ Lets take a look at the structure of this template:
|
|||||||
├── Makefile # A collection of utilities to manage the project
|
├── Makefile # A collection of utilities to manage the project
|
||||||
├── MANIFEST.in # A list of files to include in a package
|
├── MANIFEST.in # A list of files to include in a package
|
||||||
├── mkdocs.yml # Configuration for documentation site
|
├── mkdocs.yml # Configuration for documentation site
|
||||||
├── project_name # The main python package for the project
|
├── python_test_project # The main python package for the project
|
||||||
│ ├── base.py # The base module for the project
|
│ ├── base.py # The base module for the project
|
||||||
│ ├── __init__.py # This tells Python that this is a package
|
│ ├── __init__.py # This tells Python that this is a package
|
||||||
│ ├── __main__.py # The entry point for the project
|
│ ├── __main__.py # The entry point for the project
|
||||||
@ -106,7 +106,7 @@ I had to do some tricks to read that version variable inside the setuptools
|
|||||||
I decided to keep the version in a static file because it is easier to read from
|
I decided to keep the version in a static file because it is easier to read from
|
||||||
wherever I want without the need to install the package.
|
wherever I want without the need to install the package.
|
||||||
|
|
||||||
e.g: `cat project_name/VERSION` will get the project version without harming
|
e.g: `cat python_test_project/VERSION` will get the project version without harming
|
||||||
with module imports or anything else, it is useful for CI, logs and debugging.
|
with module imports or anything else, it is useful for CI, logs and debugging.
|
||||||
|
|
||||||
### Why to include `tests`, `history` and `Containerfile` as part of the release?
|
### Why to include `tests`, `history` and `Containerfile` as part of the release?
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# How to develop on this project
|
# How to develop on this project
|
||||||
|
|
||||||
project_name welcomes contributions from the community.
|
python_test_project welcomes contributions from the community.
|
||||||
|
|
||||||
**You need PYTHON3!**
|
**You need PYTHON3!**
|
||||||
|
|
||||||
@ -8,9 +8,9 @@ This instructions are for linux base systems. (Linux, MacOS, BSD, etc.)
|
|||||||
## Setting up your own fork of this repo.
|
## Setting up your own fork of this repo.
|
||||||
|
|
||||||
- On gitea interface click on `Fork` button.
|
- On gitea interface click on `Fork` button.
|
||||||
- Clone your fork of this repo. `git clone git@git.disi.dev:YOUR_GIT_USERNAME/project_urlname.git`
|
- Clone your fork of this repo. `git clone git@git.disi.dev:YOUR_GIT_USERNAME/python_test_project.git`
|
||||||
- Enter the directory `cd project_urlname`
|
- Enter the directory `cd python_test_project`
|
||||||
- Add upstream repo `git remote add upstream https://git.disi.dev/author_name/project_urlname`
|
- Add upstream repo `git remote add upstream https://git.disi.dev/Projects/python_test_project`
|
||||||
|
|
||||||
## Setting up your own virtual environment
|
## Setting up your own virtual environment
|
||||||
|
|
||||||
|
@ -2,4 +2,4 @@ FROM python:3.7-slim
|
|||||||
COPY . /app
|
COPY . /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN pip install .
|
RUN pip install .
|
||||||
CMD ["project_name"]
|
CMD ["python_test_project"]
|
||||||
|
@ -2,4 +2,4 @@ include LICENSE
|
|||||||
include HISTORY.md
|
include HISTORY.md
|
||||||
include Containerfile
|
include Containerfile
|
||||||
graft tests
|
graft tests
|
||||||
graft project_name
|
graft python_test_project
|
||||||
|
20
Makefile
20
Makefile
@ -26,20 +26,20 @@ install: ## Install the project in dev mode.
|
|||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt: ## Format code using black & isort.
|
fmt: ## Format code using black & isort.
|
||||||
$(ENV_PREFIX)isort project_name/
|
$(ENV_PREFIX)isort python_test_project/
|
||||||
$(ENV_PREFIX)black -l 79 project_name/
|
$(ENV_PREFIX)black -l 79 python_test_project/
|
||||||
$(ENV_PREFIX)black -l 79 tests/
|
$(ENV_PREFIX)black -l 79 tests/
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: ## Run pep8, black, mypy linters.
|
lint: ## Run pep8, black, mypy linters.
|
||||||
$(ENV_PREFIX)flake8 project_name/
|
$(ENV_PREFIX)flake8 python_test_project/
|
||||||
$(ENV_PREFIX)black -l 79 --check project_name/
|
$(ENV_PREFIX)black -l 79 --check python_test_project/
|
||||||
$(ENV_PREFIX)black -l 79 --check tests/
|
$(ENV_PREFIX)black -l 79 --check tests/
|
||||||
$(ENV_PREFIX)mypy --ignore-missing-imports project_name/
|
$(ENV_PREFIX)mypy --ignore-missing-imports python_test_project/
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: lint ## Run tests and generate coverage report.
|
test: lint ## Run tests and generate coverage report.
|
||||||
$(ENV_PREFIX)pytest -v --cov-config .coveragerc --cov=project_name -l --tb=short --maxfail=1 tests/
|
$(ENV_PREFIX)pytest -v --cov-config .coveragerc --cov=python_test_project -l --tb=short --maxfail=1 tests/
|
||||||
$(ENV_PREFIX)coverage xml
|
$(ENV_PREFIX)coverage xml
|
||||||
$(ENV_PREFIX)coverage html
|
$(ENV_PREFIX)coverage html
|
||||||
|
|
||||||
@ -78,9 +78,9 @@ virtualenv: ## Create a virtual environment.
|
|||||||
release: ## Create a new tag for release.
|
release: ## Create a new tag for release.
|
||||||
@echo "WARNING: This operation will create a version tag and push to gitea"
|
@echo "WARNING: This operation will create a version tag and push to gitea"
|
||||||
@read -p "Version? (provide the next x.y.z semver) : " TAG
|
@read -p "Version? (provide the next x.y.z semver) : " TAG
|
||||||
@echo "$${TAG}" > project_name/VERSION
|
@echo "$${TAG}" > python_test_project/VERSION
|
||||||
@$(ENV_PREFIX)gitchangelog > HISTORY.md
|
@$(ENV_PREFIX)gitchangelog > HISTORY.md
|
||||||
@git add project_name/VERSION HISTORY.md
|
@git add python_test_project/VERSION HISTORY.md
|
||||||
@git commit -m "release: version $${TAG} 🚀"
|
@git commit -m "release: version $${TAG} 🚀"
|
||||||
@echo "creating git tag : $${TAG}"
|
@echo "creating git tag : $${TAG}"
|
||||||
@git tag $${TAG}
|
@git tag $${TAG}
|
||||||
@ -101,7 +101,7 @@ switch-to-poetry: ## Switch to poetry package manager.
|
|||||||
@poetry init --no-interaction --name=a_flask_test --author=rochacbruno
|
@poetry init --no-interaction --name=a_flask_test --author=rochacbruno
|
||||||
@echo "" >> pyproject.toml
|
@echo "" >> pyproject.toml
|
||||||
@echo "[tool.poetry.scripts]" >> pyproject.toml
|
@echo "[tool.poetry.scripts]" >> pyproject.toml
|
||||||
@echo "project_name = 'project_name.__main__:main'" >> pyproject.toml
|
@echo "python_test_project = 'python_test_project.__main__:main'" >> pyproject.toml
|
||||||
@cat requirements.txt | while read in; do poetry add --no-interaction "$${in}"; done
|
@cat requirements.txt | while read in; do poetry add --no-interaction "$${in}"; done
|
||||||
@cat requirements-test.txt | while read in; do poetry add --no-interaction "$${in}" --dev; done
|
@cat requirements-test.txt | while read in; do poetry add --no-interaction "$${in}" --dev; done
|
||||||
@poetry install --no-interaction
|
@poetry install --no-interaction
|
||||||
@ -109,7 +109,7 @@ switch-to-poetry: ## Switch to poetry package manager.
|
|||||||
@mv requirements* .gitea/backup
|
@mv requirements* .gitea/backup
|
||||||
@mv setup.py .gitea/backup
|
@mv setup.py .gitea/backup
|
||||||
@echo "You have switched to https://python-poetry.org/ package manager."
|
@echo "You have switched to https://python-poetry.org/ package manager."
|
||||||
@echo "Please run 'poetry shell' or 'poetry run project_name'"
|
@echo "Please run 'poetry shell' or 'poetry run python_test_project'"
|
||||||
|
|
||||||
.PHONY: init
|
.PHONY: init
|
||||||
init: ## Initialize the project based on an application template.
|
init: ## Initialize the project based on an application template.
|
||||||
|
12
README.md
12
README.md
@ -1,21 +1,21 @@
|
|||||||
# project_name
|
# python_test_project
|
||||||
|
|
||||||
project_description
|
Awesome python_test_project created by Projects
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from project_name import BaseClass
|
from python_test_project import BaseClass
|
||||||
from project_name import base_function
|
from python_test_project import base_function
|
||||||
|
|
||||||
BaseClass().base_method()
|
BaseClass().base_method()
|
||||||
base_function()
|
base_function()
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ python -m project_name
|
$ python -m python_test_project
|
||||||
#or
|
#or
|
||||||
$ project_name
|
$ python_test_project
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
site_name: project_name
|
site_name: python_test_project
|
||||||
theme: readthedocs
|
theme: readthedocs
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
"""Entry point for project_name."""
|
|
||||||
|
|
||||||
from project_name.cli import main # pragma: no cover
|
|
||||||
|
|
||||||
if __name__ == "__main__": # pragma: no cover
|
|
||||||
main()
|
|
6
python_test_project/__main__.py
Normal file
6
python_test_project/__main__.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
"""Entry point for python_test_project."""
|
||||||
|
|
||||||
|
from python_test_project.cli import main # pragma: no cover
|
||||||
|
|
||||||
|
if __name__ == "__main__": # pragma: no cover
|
||||||
|
main()
|
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
project_name base module.
|
python_test_project base module.
|
||||||
|
|
||||||
This is the principal module of the project_name project.
|
This is the principal module of the python_test_project project.
|
||||||
here you put your main classes and objects.
|
here you put your main classes and objects.
|
||||||
|
|
||||||
Be creative! do whatever you want!
|
Be creative! do whatever you want!
|
||||||
@ -14,4 +14,4 @@ and then choose `flask` as template.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# example constant variable
|
# example constant variable
|
||||||
NAME = "project_name"
|
NAME = "python_test_project"
|
@ -1,4 +1,4 @@
|
|||||||
"""CLI interface for project_name project.
|
"""CLI interface for python_test_project project.
|
||||||
|
|
||||||
Be creative! do whatever you want!
|
Be creative! do whatever you want!
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ Be creative! do whatever you want!
|
|||||||
def main(): # pragma: no cover
|
def main(): # pragma: no cover
|
||||||
"""
|
"""
|
||||||
The main function executes on commands:
|
The main function executes on commands:
|
||||||
`python -m project_name` and `$ project_name `.
|
`python -m python_test_project` and `$ python_test_project `.
|
||||||
|
|
||||||
This is your program's entry point.
|
This is your program's entry point.
|
||||||
|
|
16
setup.py
16
setup.py
@ -1,4 +1,4 @@
|
|||||||
"""Python setup.py for project_name package"""
|
"""Python setup.py for python_test_project package"""
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
@ -6,7 +6,7 @@ from setuptools import find_packages, setup
|
|||||||
|
|
||||||
def read(*paths, **kwargs):
|
def read(*paths, **kwargs):
|
||||||
"""Read the contents of a text file safely.
|
"""Read the contents of a text file safely.
|
||||||
>>> read("project_name", "VERSION")
|
>>> read("python_test_project", "VERSION")
|
||||||
'0.1.0'
|
'0.1.0'
|
||||||
>>> read("README.md")
|
>>> read("README.md")
|
||||||
...
|
...
|
||||||
@ -30,17 +30,17 @@ def read_requirements(path):
|
|||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="project_name",
|
name="python_test_project",
|
||||||
version=read("project_name", "VERSION"),
|
version=read("python_test_project", "VERSION"),
|
||||||
description="project_description",
|
description="Awesome python_test_project created by Projects",
|
||||||
url="https://git.disi.dev/author_name/project_urlname/",
|
url="https://git.disi.dev/Projects/python_test_project/",
|
||||||
long_description=read("README.md"),
|
long_description=read("README.md"),
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
author="author_name",
|
author="Projects",
|
||||||
packages=find_packages(exclude=["tests", ".gitea"]),
|
packages=find_packages(exclude=["tests", ".gitea"]),
|
||||||
install_requires=read_requirements("requirements.txt"),
|
install_requires=read_requirements("requirements.txt"),
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": ["project_name = project_name.__main__:main"]
|
"console_scripts": ["python_test_project = python_test_project.__main__:main"]
|
||||||
},
|
},
|
||||||
extras_require={"test": read_requirements("requirements-test.txt")},
|
extras_require={"test": read_requirements("requirements-test.txt")},
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from project_name.base import NAME
|
from python_test_project.base import NAME
|
||||||
|
|
||||||
|
|
||||||
def test_base():
|
def test_base():
|
||||||
assert NAME == "project_name"
|
assert NAME == "python_test_project"
|
||||||
|
Loading…
Reference in New Issue
Block a user