How did Windows python Setup add python PATH to the user enviroment variables?

i made alot of researches about this topic but didnt find any solution or documentation about the process of adding Python to the PATH , i’m trying to automate something to add a directory automatically to the user’s env var path like you did in the Setup, but it seems like: setx PATH “%PATH%;C:\something” doesnt work well because it made my user env var the same as the System env vars and it doesnt add the path i want to.when trying to print the path with:
user_path = os.environ.get(‘Path’)
it print out both the SYS first and then ;USER

It can be done using the setx /m command. See setx | Microsoft Learn for details.