depzip 1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of depzip might be problematic. Click here for more details.

depzip/__init__.py ADDED
@@ -0,0 +1,52 @@
1
+ import os
2
+ import sys
3
+
4
+ import dllist
5
+ import importlib
6
+
7
+ from modulefinder import ModuleFinder
8
+
9
+ from zipfile import ZipFile, ZIP_DEFLATED
10
+
11
+
12
+ def bundle(modules=[], includes=[], excludes=[], output="bundle.zip"):
13
+ directory = os.path.dirname(sys.executable)
14
+
15
+ bundle = set()
16
+
17
+ finder = ModuleFinder()
18
+
19
+ finder.import_hook("encodings", None, ["*"])
20
+
21
+ for m in modules:
22
+ finder.import_hook(m)
23
+
24
+ for name, module in finder.modules.items():
25
+ f = getattr(module, "__file__", None)
26
+ if f is not None:
27
+ bundle.add(os.path.relpath(f, directory))
28
+
29
+ for m in modules:
30
+ importlib.import_module(m)
31
+
32
+ for dll in dllist.dllist():
33
+ if any(x.casefold() in dll.casefold() for x in ("VCRUNTIME", "MSVCP")):
34
+ continue
35
+ if os.path.commonpath([dll, directory]) == directory:
36
+ bundle.add(os.path.relpath(dll, directory))
37
+
38
+ for element in includes:
39
+ if os.path.isdir(element):
40
+ for root, dirs, files in os.walk(element):
41
+ dirs[:] = [d for d in dirs if d != "__pycache__"]
42
+ for f in files:
43
+ bundle.add(os.path.join(root, f))
44
+ elif os.path.isfile(element):
45
+ bundle.add(element)
46
+
47
+ bundle -= set(excludes)
48
+
49
+ with ZipFile(output, mode="w", compression=ZIP_DEFLATED) as zf:
50
+ for element in sorted(bundle):
51
+ if os.path.isfile(element):
52
+ zf.write(element)
depzip/import.exe ADDED
Binary file
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: depzip
3
+ Version: 1.0
4
+ Summary: A small library for zipping Python application dependencies
5
+ Author: Pavel Demin
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/pavel-demin/depzip
8
+ Requires-Python: >=3.12
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: dllist
12
+ Dynamic: license-file
13
+
14
+ This library can be used for zipping Python application dependencies.
15
+
16
+ This library uses the [modulefinder](https://docs.python.org/3/library/modulefinder.html) and [dllist](https://github.com/wardbrian/dllist) libraries to obtain a list of files required for dependencies.
17
+
18
+ ## Installation
19
+
20
+ This library can be installed using `pip`:
21
+ ```
22
+ python -m pip install depzip
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Here is a Python script showing how to use `depzip` to copy the dependencies of a Python application using `matplotlib`, `numpy`, and `PySide6` into a file called `bundle.zip`:
28
+ ```
29
+ import depzip
30
+
31
+ depzip.bundle(
32
+ modules=[
33
+ "matplotlib.backends.backend_qtagg",
34
+ "mpl_toolkits.mplot3d",
35
+ "numpy",
36
+ "PySide6.QtCore",
37
+ "PySide6.QtGui",
38
+ "PySide6.QtNetwork",
39
+ "PySide6.QtUiTools",
40
+ "PySide6.QtWidgets",
41
+ ],
42
+ includes=[
43
+ "Lib\\site-packages\\depzip\\import.exe",
44
+ "Lib\\site-packages\\matplotlib\\mpl-data",
45
+ "Lib\\site-packages\\PySide6\\plugins\\platforms\\qwindows.dll",
46
+ "Lib\\site-packages\\PySide6\\plugins\\styles\\qmodernwindowsstyle.dll",
47
+ "Lib\\site-packages\\PySide6\\uic.exe",
48
+ ],
49
+ excludes=[
50
+ "python.exe",
51
+ "pythonw.exe",
52
+ ],
53
+ output="bundle.zip",
54
+ )
55
+ ```
56
+
57
+ The source code of this script can be found in [examples/bundle.py](https://github.com/pavel-demin/depzip/tree/main/examples/bundle.py).
58
+
59
+ The provided executable file `import.exe` can be used to run a Python application. It starts Python and imports a module with the same name as the executable file. For example, to run a Python file named `app.py`, the executable file `import.exe` should be renamed to `app.exe`.
60
+
61
+ The source code of the executable file `import.exe` can be found in [examples/import.c](https://github.com/pavel-demin/depzip/tree/main/examples/import.c).
@@ -0,0 +1,7 @@
1
+ depzip/__init__.py,sha256=1TvOKh5bCtslbY5GDdXzHewRoqdYYBx__A1-inqnByc,1446
2
+ depzip/import.exe,sha256=XxhWgVBgGzk2j8yjixvja9cGce2VNy_Vs02mT9sCQKQ,16384
3
+ depzip-1.0.dist-info/licenses/LICENSE,sha256=gs0ay_wrvZSukzd8tstR8_WMHViGB6wQ84fQJooqOOQ,1078
4
+ depzip-1.0.dist-info/METADATA,sha256=8lVccsUT_ap-Rmv_M6zHSJu3XDOfsTASIoo6CjrLcL0,2199
5
+ depzip-1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ depzip-1.0.dist-info/top_level.txt,sha256=dFMkhWqtBvkmjwkslMEgQz2HolTZIVmIUhEguKqKiVk,7
7
+ depzip-1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Pavel Demin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ depzip