Compare commits

..

2 Commits

Author SHA1 Message Date
62e1917a95 actions test
Some checks failed
CI / linter (ubuntu-latest, 3.9) (push) Successful in 23s
Rename the project from template / rename-project (push) Successful in 16s
CI / tests_linux (ubuntu-latest, 3.9) (push) Successful in 20s
CI / tests_mac (macos-latest, 3.9) (push) Has been cancelled
CI / tests_win (windows-latest, 3.9) (push) Has been cancelled
2024-11-09 09:06:45 -08:00
43ff10817d Revert " Ready to clone and code."
This reverts commit e4f251f138.
2024-11-09 09:05:53 -08:00
18 changed files with 78 additions and 74 deletions

View File

@ -16,10 +16,10 @@ echo "Description: $description";
echo "Renaming project..."
original_author="Templates"
original_name="python"
original_urlname="Python"
original_description="Awesome python created by Templates"
original_author="author_name"
original_name="project_name"
original_urlname="project_urlname"
original_description="project_description"
# for filename in $(find . -name "*.*")
for filename in $(git ls-files)
do
@ -30,7 +30,7 @@ do
echo "Renamed $filename"
done
mv python $name
mv project_name $name
# This command runs only once on GHA!
rm -rf .gitea/template.yml

1
.gitea/template.yml Normal file
View File

@ -0,0 +1 @@
author: rochacbruno

View File

@ -6,7 +6,7 @@ permissions: write-all
jobs:
rename-project:
if: ${{ !contains (github.repository, '/python-project-template') }}
if: ${{ !contains (gitea.repository, '/Pythonx') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -14,29 +14,32 @@ jobs:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
ref: ${{ github.head_ref }}
ref: ${{ gitea.head_ref }}
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- run: env
shell: bash
# - run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# shell: bash
- run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
shell: bash
# - run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
# shell: bash
- run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
shell: bash
# - run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
# shell: bash
- name: Is this still a template
id: is_template
run: echo "::set-output name=is_template::$(ls .gitea/template.yml &> /dev/null && echo true || echo false)"
# - name: Is this still a template
# id: is_template
# run: echo "::set-output name=is_template::$(ls .gitea/template.yml &> /dev/null && echo true || echo false)"
- name: Rename the project
if: steps.is_template.outputs.is_template == 'true'
run: |
echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }} -u(urlname) ${{ env.REPOSITORY_URLNAME }}"
.gitea/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -u ${{ env.REPOSITORY_URLNAME }} -d "Awesome ${{ env.REPOSITORY_NAME }} created by ${{ env.REPOSITORY_OWNER }}"
# - name: Rename the project
# if: steps.is_template.outputs.is_template == 'true'
# run: |
# echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }} -u(urlname) ${{ env.REPOSITORY_URLNAME }}"
# .gitea/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -u ${{ env.REPOSITORY_URLNAME }} -d "Awesome ${{ env.REPOSITORY_NAME }} created by ${{ env.REPOSITORY_OWNER }}"
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "✅ Ready to clone and code."
# commit_options: '--amend --no-edit'
push_options: --force
# - uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: "✅ Ready to clone and code."
# # commit_options: '--amend --no-edit'
# push_options: --force

View File

@ -32,7 +32,7 @@ Lets take a look at the structure of this template:
├── Makefile # A collection of utilities to manage the project
├── MANIFEST.in # A list of files to include in a package
├── mkdocs.yml # Configuration for documentation site
├── python # The main python package for the project
├── project_name # The main python package for the project
│   ├── base.py # The base module for the project
│   ├── __init__.py # This tells Python that this is a package
│   ├── __main__.py # The entry point for the project
@ -109,7 +109,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
wherever I want without the need to install the package.
e.g: `cat python/VERSION` will get the project version without harming
e.g: `cat project_name/VERSION` will get the project version without harming
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?

View File

@ -1,6 +1,6 @@
# How to develop on this project
python welcomes contributions from the community.
project_name welcomes contributions from the community.
**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.
- On github interface click on `Fork` button.
- Clone your fork of this repo. `git clone git@github.com:YOUR_GIT_USERNAME/Python.git`
- Enter the directory `cd Python`
- Add upstream repo `git remote add upstream https://github.com/Templates/Python`
- Clone your fork of this repo. `git clone git@github.com:YOUR_GIT_USERNAME/project_urlname.git`
- Enter the directory `cd project_urlname`
- Add upstream repo `git remote add upstream https://github.com/author_name/project_urlname`
## Setting up your own virtual environment

View File

@ -2,4 +2,4 @@ FROM python:3.7-slim
COPY . /app
WORKDIR /app
RUN pip install .
CMD ["python"]
CMD ["project_name"]

View File

@ -2,4 +2,4 @@ include LICENSE
include HISTORY.md
include Containerfile
graft tests
graft python
graft project_name

View File

@ -26,20 +26,20 @@ install: ## Install the project in dev mode.
.PHONY: fmt
fmt: ## Format code using black & isort.
$(ENV_PREFIX)isort python/
$(ENV_PREFIX)black -l 79 python/
$(ENV_PREFIX)isort project_name/
$(ENV_PREFIX)black -l 79 project_name/
$(ENV_PREFIX)black -l 79 tests/
.PHONY: lint
lint: ## Run pep8, black, mypy linters.
$(ENV_PREFIX)flake8 python/
$(ENV_PREFIX)black -l 79 --check python/
$(ENV_PREFIX)flake8 project_name/
$(ENV_PREFIX)black -l 79 --check project_name/
$(ENV_PREFIX)black -l 79 --check tests/
$(ENV_PREFIX)mypy --ignore-missing-imports python/
$(ENV_PREFIX)mypy --ignore-missing-imports project_name/
.PHONY: test
test: lint ## Run tests and generate coverage report.
$(ENV_PREFIX)pytest -v --cov-config .coveragerc --cov=python -l --tb=short --maxfail=1 tests/
$(ENV_PREFIX)pytest -v --cov-config .coveragerc --cov=project_name -l --tb=short --maxfail=1 tests/
$(ENV_PREFIX)coverage xml
$(ENV_PREFIX)coverage html
@ -78,9 +78,9 @@ virtualenv: ## Create a virtual environment.
release: ## Create a new tag for release.
@echo "WARNING: This operation will create s version tag and push to github"
@read -p "Version? (provide the next x.y.z semver) : " TAG
@echo "$${TAG}" > python/VERSION
@echo "$${TAG}" > project_name/VERSION
@$(ENV_PREFIX)gitchangelog > HISTORY.md
@git add python/VERSION HISTORY.md
@git add project_name/VERSION HISTORY.md
@git commit -m "release: version $${TAG} 🚀"
@echo "creating 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
@echo "" >> pyproject.toml
@echo "[tool.poetry.scripts]" >> pyproject.toml
@echo "python = 'python.__main__:main'" >> pyproject.toml
@echo "project_name = 'project_name.__main__:main'" >> pyproject.toml
@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
@poetry install --no-interaction
@ -109,7 +109,7 @@ switch-to-poetry: ## Switch to poetry package manager.
@mv requirements* .gitea/backup
@mv setup.py .gitea/backup
@echo "You have switched to https://python-poetry.org/ package manager."
@echo "Please run 'poetry shell' or 'poetry run python'"
@echo "Please run 'poetry shell' or 'poetry run project_name'"
.PHONY: init
init: ## Initialize the project based on an application template.

View File

@ -11,7 +11,7 @@ See also
1. Choose a name for your project
(e.g. `my_awesome_project` recommendation is to use all lowercase and underscores separation for repo names.)
2. Replace all text instances of "python" in this repo with your new name
2. Replace all text instances of "project_name" in this repo with your new name
3. If you want Automatic Release to [PyPI](https://pypi.org)
On the new repository `settings->secrets` add your `PYPI_API_TOKEN` (get the tokens on PyPI website)
4. Read the file [CONTRIBUTING.md](CONTRIBUTING.md)
@ -35,7 +35,7 @@ See also
- 🧪 Testing structure using [pytest](https://docs.pytest.org/en/latest/)
- ✅ Code linting using [flake8](https://flake8.pycqa.org/en/latest/)
- 🛳️ Automatic release to [PyPI](https://pypi.org) using [twine](https://twine.readthedocs.io/en/latest/) and github actions.
- 🎯 Entry points to execute your program using `python -m <python>` or `$ python` with basic CLI argument parsing.
- 🎯 Entry points to execute your program using `python -m <project_name>` or `$ project_name` with basic CLI argument parsing.
- 🔄 Continuous integration using [Github Actions](.gitea/workflows/) with jobs to lint, test and release your project on Linux, Mac and Windows environments.
> Curious about architectural decisions on this template? read [ABOUT_THIS_TEMPLATE.md](ABOUT_THIS_TEMPLATE.md)
@ -46,30 +46,30 @@ See also
<!-- DELETE THE LINES ABOVE THIS AND WRITE YOUR PROJECT README BELOW -->
---
# python
# project_name
Awesome python created by Templates
project_description
## Install it from PyPI
```bash
pip install python
pip install project_name
```
## Usage
```py
from python import BaseClass
from python import base_function
from project_name import BaseClass
from project_name import base_function
BaseClass().base_method()
base_function()
```
```bash
$ python -m python
$ python -m project_name
#or
$ python
$ project_name
```
## Development

View File

@ -1,2 +1,2 @@
site_name: python
site_name: project_name
theme: readthedocs

6
project_name/__main__.py Normal file
View File

@ -0,0 +1,6 @@
"""Entry point for project_name."""
from project_name.cli import main # pragma: no cover
if __name__ == "__main__": # pragma: no cover
main()

View File

@ -1,7 +1,7 @@
"""
python base module.
project_name base module.
This is the principal module of the python project.
This is the principal module of the project_name project.
here you put your main classes and objects.
Be creative! do whatever you want!
@ -14,4 +14,4 @@ and then choose `flask` as template.
"""
# example constant variable
NAME = "python"
NAME = "project_name"

View File

@ -1,4 +1,4 @@
"""CLI interface for python project.
"""CLI interface for project_name project.
Be creative! do whatever you want!
@ -12,7 +12,7 @@ Be creative! do whatever you want!
def main(): # pragma: no cover
"""
The main function executes on commands:
`python -m python` and `$ python `.
`python -m project_name` and `$ project_name `.
This is your program's entry point.

View File

@ -1,6 +0,0 @@
"""Entry point for python."""
from python.cli import main # pragma: no cover
if __name__ == "__main__": # pragma: no cover
main()

View File

@ -1,4 +1,4 @@
"""Python setup.py for python package"""
"""Python setup.py for project_name package"""
import io
import os
from setuptools import find_packages, setup
@ -6,7 +6,7 @@ from setuptools import find_packages, setup
def read(*paths, **kwargs):
"""Read the contents of a text file safely.
>>> read("python", "VERSION")
>>> read("project_name", "VERSION")
'0.1.0'
>>> read("README.md")
...
@ -30,17 +30,17 @@ def read_requirements(path):
setup(
name="python",
version=read("python", "VERSION"),
description="Awesome python created by Templates",
url="https://git.disi.dev/Templates/Python/",
name="project_name",
version=read("project_name", "VERSION"),
description="project_description",
url="https://git.disi.dev/author_name/project_urlname/",
long_description=read("README.md"),
long_description_content_type="text/markdown",
author="Templates",
author="author_name",
packages=find_packages(exclude=["tests", ".gitea"]),
install_requires=read_requirements("requirements.txt"),
entry_points={
"console_scripts": ["python = python.__main__:main"]
"console_scripts": ["project_name = project_name.__main__:main"]
},
extras_require={"test": read_requirements("requirements-test.txt")},
)

View File

@ -1,5 +1,5 @@
from python.base import NAME
from project_name.base import NAME
def test_base():
assert NAME == "python"
assert NAME == "project_name"