This is similar to an answer I wrote here:
Where is the PYTHONPATH defined in the first place?
That is not a good idea: you'd have to modify python's built-in code
and libraries. I do not even know if they are compiled but if they
weren't, even though you'd be able to modify the code (which I do not
know if that is possible in the simple way we assume it) you would run
into trouble:
- You may screw up any other part of the code by which python won't ever run and you won't ever know why
- Your application wouldn't be compatible with any other computer since you'd have to modify the package too.
- Even though you had a script modifying the package (so it is compatible) or even if you just ran it in a unique machine, you may
not have enough system permissions to do so (in your case I suppose
you do since I assume you are the machine's owner, but you may not)
- Most Python implementations do not have the raw source code available on-site. It's all compiled. So, you would need to go
download the raw code and compile yourself, which is yet another
problem.
I do not really recommend it, but if you still want to try, I hope
someone may answer your question better than me.
I now add
Maybe if the modifications you want to add to the language are very consistent and so frequent that you can build your own version of Python that you can install anywhere and share with friends.
As @user286474 pointed out there
It sounds like a proper Python environment has not been established .. don't go changing the tooling, change the environment. It's much simpler and will do what you need - the only reason to modify Python's core is to extended the language at a core level, such as adding new syntax or modifying how the VM works.-
I think he is right. Nevertheless, you may still want to modify the original content of Python to replace it with your custom stuff. I do not really recommend it. However, if you consider it appropriate, you can download the raw code of Python and compile it yourself. It is a hard but an interesting task.