<#19772 Running a python script always executes th...
# github-notifications
c
#19772 Running a python script always executes the and parent __init__.py files Issue created by chrismatix Describe the bug When trying to run a standalone script file located in a directory (using
pex_binary
) the script will always execute the
__init__.py
file in the same directory and all parent init files. Setting the `init_files` option has no effect which is expected given the documentation:
Copy code
Even if this is set to never or content_only, Pants will still always include any ancestor __init__.py files in the sandbox. Only, they will not be "proper" dependencies, e.g. they will not show up in pants dependencies and their own dependencies will not be used.
Coming from other build tooling such as Bazel this behavior is confusing because one expects to have fine-grained control over dependencies. Source files in parent directories should by default not be considered dependencies. Here is a file structure to illustrate the problem:
Copy code
.
└── apps/
    ├── BUILD
    ├── __init__.py # outer init
    └── scripts/
        ├── BUILD
        ├── __init__.py # inner init
        └── script.py
Pants version 2.16.0 OS MacOS Additional info I reproduced the behavior in this repository: https://github.com/chrismatix/pants-pex-repro pantsbuild/pants