Skip to content

Starting Python Module in pynsist instllation via sys.executable -m my_module does not include .pth file #267

Description

@monzelr

Hi,

first of all, thank you for this great tool - it is easy to understand and super usefull.

Problem

My problem is, that some python packages are modules, which can be started with the python -m my_module command. However, this will not setup the pkgs folder of pynsist correctly, which is done like in *launch.pyw command.

This is the reason why some of my python -m my_module-commands resulting in an ImportError, e.g. they can not find all .pth files from pywin32.

Some Version Infos:
pynsist 2.8
Python 3.9

Possible Solution

What I am currently doing is to ship an extra file sitecustomize.py which is inside the pkgs folder. It is automatically called by the python interpreter (more information in the python docs sitecustomize).

sitecustomize.py:

import os
import site

pkgs_dir, _ = os.path.split(os.path.abspath(__file__))
site.USER_SITE = pkgs_dir
site.main()

I first tried it with site.addsitedir because it is also in the *.launch.pyw files but it does not work. I dont know why...

However, I am wondering if the sitecustomize.py would be a standard solution for pynsist? Also I am wondering if there is another solution available - so far, I did not find another one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions