Skip to content

Commit 549e180

Browse files
committed
adding cli entrypoint and pyproject build
1 parent 90a6a32 commit 549e180

File tree

6 files changed

+267
-3
lines changed

6 files changed

+267
-3
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.py[oc]
2+
.DS_Store
3+
/*.egg-info/
4+
/dist/
5+
__pycache__/
6+
difPy_*.json
7+
difPy_*_lower_quality.txt
8+
Thumbs.db

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ difPy.search(difpy_obj, similarity='duplicates', rotate=True, same_dim=True, sho
156156
## CLI Usage
157157
difPy can also be invoked through the CLI by using the following commands:
158158

159+
### From Source
159160
```python
160161
python dif.py #working directory
161162

@@ -164,6 +165,15 @@ python dif.py -D 'C:/Path/to/Folder/'
164165
python dif.py -D 'C:/Path/to/Folder_A/' 'C:/Path/to/Folder_B/' 'C:/Path/to/Folder_C/'
165166
```
166167

168+
### Installed Package
169+
```shell
170+
pip install difPy
171+
172+
difpy
173+
# or
174+
python -m difpy
175+
```
176+
167177
> :point_right: Windows users can add difPy to their [PATH system variables](https://www.computerhope.com/issues/ch000549.htm) by pointing it to their difPy package installation folder containing the [`difPy.bat`](https://github.com/elisemercury/Duplicate-Image-Finder/difPy/difPy.bat) file. This adds `difPy` as a command in the CLI and will allow direct invocation of `difPy` from anywhere on the device.
168178
169179
difPy CLI supports the following arguments:

difPy/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .dif import cli
2+
3+
if __name__ == '__main__':
4+
cli()

difPy/dif.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,8 @@ def _strtobool(v):
971971
return False
972972
else:
973973
raise argparse.ArgumentTypeError('Boolean value expected')
974-
975-
if __name__ == '__main__':
974+
975+
def cli():
976976
# Parameters for when launching difPy via CLI
977977
parser = argparse.ArgumentParser(description='Find duplicate or similar images with difPy - https://github.com/elisemercury/Duplicate-Image-Finder')
978978
parser.add_argument('-D', '--directory', type=str, nargs='+', help='Paths of the directories to be searched. Default is working dir.', required=False, default=[os.getcwd()])
@@ -1040,4 +1040,7 @@ def _strtobool(v):
10401040
# delete search.lower_quality files
10411041
se.delete(silent_del=args.silent_del)
10421042

1043-
print(f'''\n{result_file}\n{lq_file}\n{stats_file}\n\nsaved in '{dir}'.''')
1043+
print(f'''\n{result_file}\n{lq_file}\n{stats_file}\n\nsaved in '{dir}'.''')
1044+
1045+
if __name__ == '__main__':
1046+
cli()

pyproject.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[project]
2+
name = "difpy"
3+
dynamic = ["version"]
4+
description = "Duplicate Image Finder - Python package for finding duplicate and similar images"
5+
readme = "README.md"
6+
keywords = ["duplicate", "image", "finder", "similarity", "pictures"]
7+
classifiers = [
8+
"Development Status :: 5 - Production/Stable",
9+
"Intended Audience :: Developers",
10+
"License :: OSI Approved :: MIT License",
11+
"Programming Language :: Python",
12+
"Programming Language :: Python :: 3.11",
13+
"Topic :: Software Development :: Build Tools"
14+
]
15+
requires-python = ">=3.11"
16+
dependencies = [
17+
"numpy>=1.26.4",
18+
"pillow>=10.2.0",
19+
]
20+
21+
[project.urls]
22+
homepage = "https://github.com/elisemercury/Duplicate-Image-Finder"
23+
documentation = "https://difpy.readthedocs.io"
24+
repository = "https://github.com/elisemercury/Duplicate-Image-Finder"
25+
26+
[project.scripts]
27+
difpy = "difPy.dif:cli"
28+
29+
[tool.setuptools]
30+
packages = ["difPy"]
31+
32+
[tool.setuptools.dynamic]
33+
version = {attr = "difPy.version.__version__"}

0 commit comments

Comments
 (0)