Repository: psychopy/psychopy

Issue:
Working directory issues with 2020.1.1 (most likely related to the new run window)
See https://discourse.psychopy.org/t/working-directory-change-with-2020-1-and-later/11143 and https://discourse.psychopy.org/t/both-the-stim3d-py-and-trialhandler-py-programs-with-psychopy-2020-1-1-do-not-run-properly/11201

At least on Mac (have not tested on Windows), since upgrading to 2020.1.1, if you run a script, the working directory is set to /Applications/PsychoPy3.app/Contents/Resources, rather than the directory that contains the script. This completely breaks any script that uses relative paths for relevant files expecting the working directory to be the script's directory. This includes some of the demos (see second link above) and my PyHab project.

In the short run you can just add the following to the top of every file where it matters:

```
import os
os.chdir(os.path.dirname(os.path.realpath(__file__)))
```

but this is basically a kludge and bad for backwards-compatibility. Does it need to be this way or can we get the new running window to use the script's directory as the working directory by default?


Discussion:
I'm sure there's no need for it to be this way. Looks like the code copied over to Runner class 

https://github.com/psychopy/psychopy/blob/3e8adf5debf381169a8598e799dbd0b71243bfa7/psychopy/app/runner/scriptProcess.py#L91

came from Builder 

https://github.com/psychopy/psychopy/blob/7d6b1a878f124999f986828e612bc6b36b68963c/psychopy/app/builder/builder.py#L2198

Now, Builder doesn't strictly need to update the cwd because your solution (set cwd to __file__) is done automatically in the Builder-output scripts, so it was probably left out but for hand-written scripts I definitely think it's amore expected thing to have the cwd automatically set to the script folder, so I think it would be cool to update scriptProcess as above to point the process cwd to the necessary location. Do you want to submit a PR on that or shall I?

I'm traveling, so probably faster if you do it, but if I get a moment and
you haven't already taken care of it I'll take a crack at it.

On Thu, Feb 27, 2020, 2:37 PM Jon Peirce <notifications@github.com> wrote:

> I'm sure there's no need for it to be this way. Looks like the code copied
> over to Runner class
>
>
> https://github.com/psychopy/psychopy/blob/3e8adf5debf381169a8598e799dbd0b71243bfa7/psychopy/app/runner/scriptProcess.py#L91
>
> came from Builder
>
>
> https://github.com/psychopy/psychopy/blob/7d6b1a878f124999f986828e612bc6b36b68963c/psychopy/app/builder/builder.py#L2198
>
> Now, Builder doesn't strictly need to update the cwd because your solution
> (set cwd to *file*) is done automatically in the Builder-output scripts,
> so it was probably left out but for hand-written scripts I definitely think
> it's amore expected thing to have the cwd automatically set to the script
> folder, so I think it would be cool to update scriptProcess as above to
> point the process cwd to the necessary location. Do you want to submit a PR
> on that or shall I?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/psychopy/psychopy/issues/2816?email_source=notifications&email_token=AFKKAKXCNJN6GGM26A22X2LRFAI6BA5CNFSM4K5AK2R2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENFVNKQ#issuecomment-592139946>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFKKAKWFI3OYWGUN3IASHTDRFAI6BANCNFSM4K5AK2RQ>
> .
>

 #2819 Submitted. NOTE: I don't have access to a Windows machine for a couple days to test it on Windows, and I highly recommend testing it. I couldn't just create a path object because the cwd argument of popen does not accept path objects in windows prior to Python 3.7, according to docs. It has to be a string. So, I had to manually get the last / or \ from the filename, in the conditionals that are already in the RunFile function for dealing with Windows-specific stuff.

Resolving patch:
diff --git a/psychopy/__init__.py b/psychopy/__init__.py
--- a/psychopy/__init__.py
+++ b/psychopy/__init__.py
@@ -12,7 +12,7 @@
 import os
 import sys
 
-__version__ = '2020.1.2'
+__version__ = '2020.1.3'
 __license__ = 'GNU GPLv3 (or more recent equivalent)'
 __author__ = 'Jonathan Peirce'
 __author_email__ = 'jon.peirce@gmail.com'
diff --git a/setupApp.py b/setupApp.py
--- a/setupApp.py
+++ b/setupApp.py
@@ -134,10 +134,11 @@ def dyld_find(name, loader=None, **kwargs):
                   CFBundleIconFile='psychopy.icns',
                   CFBundleName               = "PsychoPy3",
                   CFBundleShortVersionString = version,  # must be in X.X.X format
-                  CFBundleGetInfoString      = "PsychoPy3 "+version,
+                  CFBundleVersion            = version,
                   CFBundleExecutable         = "PsychoPy3",
                   CFBundleIdentifier         = "org.psychopy.PsychoPy3",
                   CFBundleLicense            = "GNU GPLv3+",
+                  NSHumanReadableCopyright   = "Open Science Tools Ltd.",
                   CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=['*'],
                                               CFBundleTypeRole='Editor')],
                   LSEnvironment=dict(PATH="/usr/local/git/bin:/usr/local/bin:"


Test patch: