Skip to content

__init__.py file is 0KB after successful pip install (Windows) #51

@riphet

Description

@riphet

## Problem: `tonsdk` Installation Appears Corrupt - `__init__.py` is 0KB

**Description:**
After attempting to install `tonsdk` using `pip`, the library appears to be corrupt or incomplete on my Windows system. Specifically, the crucial `__init__.py` file within the `tonsdk` package directory is consistently found to be **0KB in size**.

This issue persists even after multiple attempts to clean, reinstall, use virtual environments, and disable antivirus software. The installation command reports success, but the library is not functional.

**Symptoms:**
1.  **`tonsdk version (from __version__): No disponible`**: The `__version__` attribute for the `tonsdk` package is not found, indicating the `__init__.py` file is not being loaded or is empty.
2.  **`'Cell' object has no attribute 'hash_'` error**: When attempting to use core `tonsdk` functionalities, specifically the **`hash_` property of the `Cell` object** (e.g., from `tonsdk.boc.Cell`), this attribute is missing, leading to a runtime error. This strongly indicates that the `Cell` class or its implementation is not loaded correctly due to the corrupted installation.
3.  **Inconsistent Wallet Code Hashes**: When comparing a generated V4R2 wallet (`Hash de Code B`) with a known good reference wallet (`Hash de Code A`), the code hashes are consistently different. This implies that the `tonsdk` library is not using the expected or correct wallet code definitions, despite the data hashes matching, pointing to a corrupted or non-standard `tonsdk` installation.

    * `Hash de Code A: 83a22325407c8161fea0968aab944876656ad09626429a0e0ec42acf89748873`
    * `Hash de Code B: 8a3e04432d90139709770e99742a4fb03efd87544643a45107af2fa615700fac`

4.  **Program Termination:** The script eventually terminates with messages like "El subproceso 'MainThread' (1) terminó con código 0 (0x0). El programa 'python.exe' terminó con código 4294967295 (0xffffffff)." (This is the Spanish output for a program exiting with an error code).

**Steps to Reproduce:**
1.  **Create a new Python virtual environment:**
    ```bash
    python -m venv my_ton_env
    ```
2.  **Activate the virtual environment:**
    ```bash
    .\my_ton_env\Scripts\activate
    ```
3.  **Install `tonsdk` using forced reinstallation and no-cache option:**
    ```bash
    pip install --no-cache-dir --force-reinstall tonsdk
    ```
    * **Expected:** `Successfully installed tonsdk-1.0.15` and a fully functional library.
    * **Actual:** `Successfully installed tonsdk-1.0.15` is reported, but the library is not functional as verified in the next steps.

4.  **Verify `__init__.py` file size after installation:**
    Navigate to `C:\Users\YourUser\YourProjectFolder\my_ton_env\Lib\site-packages\tonsdk\`
    * **Expected:** `__init__.py` to be > 0KB (e.g., 1KB or more), containing Python code.
    * **Actual:** `__init__.py` is **0KB**.

5.  **Run a Python script that imports `tonsdk` and attempts to use `Cell.hash_` (e.g., a wallet generation/comparison script):**

    ```python
    # Example snippet from the affected script:
    import tonsdk
    import os
    from tonsdk.boc import Cell
    # ... other tonsdk imports and your wallet generation code ...

    print(f"tonsdk version (from __version__): {getattr(tonsdk, '__version__', 'No disponible')}")
    print(f"tonsdk path: {os.path.dirname(tonsdk.__file__)}")

    # ... later in the code where Cell.hash_ is accessed ...
    # This line consistently triggers the `'Cell' object has no attribute 'hash_'` error
    some_cell_instance.hash_
    ```

**Environment:**
* **Operating System:** Windows 11 (64-bit)
* **Python Version:** 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)]
* **`tonsdk` Version Attempted:** 1.0.15
* **`pip` Version:** (Please provide the output of `pip --version` here)
* **Antivirus/Security Software:** (Mention if you use one, e.g., Windows Defender, Avast, Norton, and whether temporarily disabling it during installation attempts had any effect).

**Troubleshooting Steps Already Attempted:**
* Deactivated `App Execution Aliases` for Python in Windows Settings.
* Modified system `PATH` environment variable to prioritize `C:\Program Files\Python311`.
* Uninstalled `tonsdk` and other related TON libraries (`ton`, `tonclient`, `toncli`) globally.
* Manually deleted `tonsdk` and related folders from `site-packages` (both global `C:\Program Files\Python311\Lib\site-packages\` and virtual environments).
* Used multiple fresh Python virtual environments for installation attempts.
* Performed `pip install --no-cache-dir --force-reinstall tonsdk` multiple times within active virtual environments.
* Rebooted the system multiple times to clear any file locks/caches before installation attempts.
* Temporarily **disabled antivirus software** during the entire installation process (deleting old venv, creating new venv, `pip install`).

The persistent 0KB `__init__.py` strongly suggests a fundamental issue with the package's integrity upon download or its writing to the file system on my specific setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions