Update page 'Day 10 homework - Sloetjes '
@@ -121,3 +121,46 @@ Module directory histogram:
|
|||||||
* In the case of Pandas, many of the sub-modules and sub-packages are implemented using compiled extensions, and therefore they are loaded using an extension loader rather than the `SourceFileLoader`. This is why we see a mix of different types of loaders in the `loader` column when we run the module-inspector script on a system that has Pandas installed.
|
* In the case of Pandas, many of the sub-modules and sub-packages are implemented using compiled extensions, and therefore they are loaded using an extension loader rather than the `SourceFileLoader`. This is why we see a mix of different types of loaders in the `loader` column when we run the module-inspector script on a system that has Pandas installed.
|
||||||
|
|
||||||
**Extra credit: use the freeze utility to turn the module-inspector script into a real app.**
|
**Extra credit: use the freeze utility to turn the module-inspector script into a real app.**
|
||||||
|
* Install `cx_Freeze` using `pip`:
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install cx_Freeze
|
||||||
|
|
||||||
|
```
|
||||||
|
* Create a new file named `setup.py` in the same directory as `module-inspector.py`:
|
||||||
|
###### setup.py
|
||||||
|
```
|
||||||
|
import sys
|
||||||
|
from cx_Freeze import setup, Executable
|
||||||
|
|
||||||
|
# Dependencies are automatically detected, but it might need fine tuning.
|
||||||
|
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
|
||||||
|
|
||||||
|
# GUI applications require a different base on Windows (the default is for a
|
||||||
|
# console application).
|
||||||
|
base = None
|
||||||
|
if sys.platform == "win32":
|
||||||
|
base = "Win32GUI"
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="Module Inspector",
|
||||||
|
version="1.0",
|
||||||
|
description="A utility to inspect Python modules",
|
||||||
|
options={"build_exe": build_exe_options},
|
||||||
|
executables=[Executable("module-inspector.py", base=base)]
|
||||||
|
)
|
||||||
|
```
|
||||||
|
* Run the following command to create the executable:
|
||||||
|
|
||||||
|
```
|
||||||
|
python setup.py build
|
||||||
|
```
|
||||||
|
|
||||||
|
* Navigate to the build directory, and run the module-inspector executable to launch the app:
|
||||||
|
|
||||||
|
```
|
||||||
|
chmod +x module-inspector.py
|
||||||
|
```
|
||||||
|
```
|
||||||
|
./module-inspector.py
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user