In a Python Pyramid project, I tried to rename a project view file temporarily while testing a new version of this file. Originally, the project started with the following view file:
/myproject/myproject/views/default.py
I then renamed this file to some other temporary name:
/myproject/myproject/views/stable_default.py
and created a new default.py in the same directory for testing purpose. The idea was that I could return to my starting point by removing the new default.py and again renaming stable_default.py back to default.py.
However, after building the project (using myproject/env/bin/pip install e .), the original/renamed view file stable_default.py became recognized as being part of the project (and caused various problems because there are repeating blocks of code in the 2 view files...bad choice on my part to try using this approach). Next, if I remove the file stable_default.py, such that it no longer exists in the source directory (or anywhere else), and try to build the project again, stable_default.py is still being recognized as part of the project (and causing various problems since the source file does not exist...causing the project to fail).
In searching through the project files, I found 2 file names associated with the build results that reference the non-existent view source file. In this case, I am using Python version 3.9x, which also influences the file/path names shown below:
/myproject/env/lib/python3.9/site-packages/myproject/views/stable_default.py
and
/myproject/env/lib/python3.9/site-packages/myproject/views/__pycache__/stable_default.cpython-39.pyc
If I simply delete the above 2 files, then all of the problems go away and the project runs properly.
I have not been able to determine what aspect of the source files or build system is holding onto the file name stable_default.py even after this file has been removed from the view source directory.
My workaround is to remove those 2 generated files referencing the stable_default.py source after each build of the project, but I would really like to fix this project such that these 2 files do get generated at all.
I suppose a more general question is...how can the developer of a Pyramid project have complete control over which view files are included or not included in the build?