Skip to content

Commit 18f45d2

Browse files
committed
project: create project base and setup build system
0 parents  commit 18f45d2

34 files changed

+1482
-0
lines changed

.flake8

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203

.github/workflows/release.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This Github workflow will create a new release when a tag is pushed.
2+
3+
name: release
4+
on:
5+
push:
6+
tags:
7+
- "v[0-9]+.[0-9]+.[0-9]+*"
8+
9+
jobs:
10+
create-release:
11+
name: create-release
12+
runs-on: ubuntu-latest
13+
outputs:
14+
upload_url: ${{ steps.release.outputs.upload_url }}
15+
version: ${{ github.ref_name }}
16+
steps:
17+
- name: Create Github Release
18+
id: release
19+
uses: actions/create-release@v1
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
with:
23+
tag_name: ${{ github.ref_name }}
24+
release_name: ${{ github.ref_name }}

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.mypy_cache
2+
__pycache__
3+
builddir
4+
.coverage
5+
htmlcov

.pre-commit-config.yaml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
ci:
2+
skip: [pip-compile]
3+
4+
repos:
5+
# General
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.5.0
8+
hooks:
9+
- id: check-added-large-files
10+
- id: check-xml
11+
- id: debug-statements
12+
- id: end-of-file-fixer
13+
- id: name-tests-test
14+
- id: trailing-whitespace
15+
- repo: https://github.com/pre-commit/mirrors-mypy
16+
rev: v1.8.0
17+
hooks:
18+
- id: mypy
19+
args:
20+
- "--check-untyped-defs"
21+
- "--ignore-missing-imports"
22+
additional_dependencies:
23+
- PyGObject-stubs
24+
- name-that-hash
25+
# Python
26+
- repo: https://github.com/PyCQA/flake8
27+
rev: 7.0.0
28+
hooks:
29+
- id: flake8
30+
additional_dependencies:
31+
- pep8-naming
32+
- "git+https://github.com/zer0-x/flake8-typehinting#egg=flake8-typehinting"
33+
- flake8-builtins
34+
- flake8-bugbear
35+
- flake8-comprehensions
36+
- repo: https://github.com/psf/black
37+
rev: 23.12.1
38+
hooks:
39+
- id: black
40+
- repo: https://github.com/asottile/reorder_python_imports
41+
rev: v3.12.0
42+
hooks:
43+
- id: reorder-python-imports
44+
- repo: https://github.com/PyCQA/pydocstyle
45+
rev: 6.3.0
46+
hooks:
47+
- id: pydocstyle
48+
# Prettier
49+
- repo: https://github.com/pre-commit/mirrors-prettier
50+
rev: v4.0.0-alpha.8
51+
hooks:
52+
- id: prettier
53+
types_or: [markdown, css]
54+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
55+
rev: v2.12.0
56+
hooks:
57+
- id: pretty-format-ini
58+
# PIP requirements
59+
- repo: https://github.com/jazzband/pip-tools
60+
rev: 7.3.0
61+
hooks:
62+
- id: pip-compile
63+
name: pip-compile requirements.in
64+
args:
65+
- --resolver=backtracking
66+
- --generate-hashes
67+
- requirements/requirements.in
68+
files: ^requirements/requirements.in$
69+
- id: pip-compile
70+
name: pip-compile requirements-dev.in
71+
args:
72+
- --resolver=backtracking
73+
- --generate-hashes
74+
- requirements/requirements-dev.in
75+
files: ^requirements/requirements-dev.in$

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Unreleased

CONTRIBUTING.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Contributing
2+
3+
## Bug report
4+
5+
For now [GitHub bug traker](https://github.com/zefr0x/hash_identifier/issues) is used for this project.
6+
7+
We aim to be user friendly, so if you have any issue or suggestion for the [UI](https://en.wikipedia.org/wiki/User_interface_design)/[UX](https://en.wikipedia.org/wiki/User_experience_design) or about the [application packging](<https://en.wikipedia.org/wiki/Package_(package_management_system)>), please tell us, we appreciate it.
8+
9+
## Development
10+
11+
- The 3rd version of the [Python](<https://en.wikipedia.org/wiki/Python_(programming_language)>) programming language is used mainly in this project.
12+
- Dependencies managment is handled using [requirements files](requirements) with [pip-tools](https://pip-tools.rtfd.io/).
13+
- `requirements.in` contain requirements for running the application and `requirements-dev.in` contain requirements for development.
14+
- `.txt` files are locked requirements with hashes generated using `pip-tools` to provide a reproducible environment.
15+
- For development you will need to use both files, while users just need to use the `requirements.txt` file.
16+
17+
> `pre-commit` will take care about generating `.txt` files. You should just edit `.in` files or use `pip-tools` to upgrade locked requirements.
18+
19+
### Create a virtual environment and install dependencies
20+
21+
First clone the git repository:
22+
23+
```
24+
git clone https://github.com/zefr0x/hash_identifier.git
25+
```
26+
27+
For development you are recomended to use [pip-tools](https://pip-tools.rtfd.io/) for reproducing the same environment.
28+
29+
1. Create a virtual environment and activate it
30+
31+
```shell
32+
virtualenv .env
33+
34+
source .env/bin/activate
35+
```
36+
37+
2. Install `pip-tools` in the virtualenv
38+
39+
```shell
40+
pip install pip-tools
41+
```
42+
43+
3. Run the folowing command in the project's root directory to install all the dependencies for development
44+
45+
```shell
46+
pip-sync requirements/{requirements,requirements-dev}.txt
47+
```
48+
49+
4. Then you can run the application as a python module
50+
51+
```shell
52+
python3 -m hash_identifier
53+
```
54+
55+
> You can use the [`justfile`](https://github.com/casey/just) if you want to.
56+
57+
### Style
58+
59+
- You should [type hint](https://docs.python.org/3/library/typing.html) every thing as possible.
60+
- You should comment every thing to keep the code easy to read. Every file, every class, every function and any line that need a comment.
61+
62+
You should use:
63+
64+
- [mypy](http://www.mypy-lang.org/) `(Static Type Checker)`
65+
- [flake8](https://flake8.pycqa.org/) `(Style Enforcer)`
66+
- [pydocstyle](https://www.pydocstyle.org/) `(Checking compliance with Python docstring conventions)`
67+
- [black](https://black.readthedocs.io/) `(Code Formatter)`
68+
69+
You can also use any tool that you want as long as it's compatable with the required style.
70+
71+
#### Installing `pre-commit`
72+
73+
To make every thing easy [**`pre-commit`**](https://pre-commit.com/) is used in this project, it should run in every commit, so you shouldn't commit any thing without checking it first.
74+
75+
First install it:
76+
77+
```shell
78+
pip install pre-commit
79+
```
80+
81+
> You can use another way to install it, maybe from your OS's package manager.
82+
83+
Then add it as a git hook while you are inside the repository:
84+
85+
```shell
86+
pre-commit install
87+
```
88+
89+
## Testing
90+
91+
TODO...
92+
93+
## Translation
94+
95+
The application's GUI is prepared for [internationalisation](https://en.wikipedia.org/wiki/Internationalization_and_localization) using [gettext](https://en.wikipedia.org/wiki/Gettext).
96+
97+
Go to the [`./po`](./po) directory for more details.
98+
99+
### Translating the application name
100+
101+
The name of the application should be changed with respect to the target locale, but it must convey the same meaning.

0 commit comments

Comments
 (0)