newville / pyshortcuts

create desktop shortcuts to python scripts on Windows, Mac, or Linux
MIT License
101 stars 15 forks source link

double up of PATH in envrunner #25

Open maphew opened 4 years ago

maphew commented 4 years ago
exception executing script
OSError: [Errno 22] Invalid argument: 'C:\\tools\\miniconda3\\envs\\leo-dev\\Scripts\\envrunner-C:\\tools\\miniconda3\\envs\\leo-dev.bat'

only 17 lines
--------------------
  line 133:         runner = os.path.join(sys.prefix, 'Scripts', runnerbat)
* line 134:         with open(runner, 'w') as fh:
  line 135:             fh.write(ENVRUNNER)
  line 136:         time.sleep(0.05)

This is the bug I mentioned in #21, no time to dig in right now as I have to run out the door. It might be something in my code so don't spend much energy troubleshooting as it could be all my fault. ;-)

newville commented 4 years ago

@maphew I tagged 1.7.1 and pushed that to PyPI. If we a fix and 1.7.2, that's OK.

Could it be that you have CONDA_DEFAULT_ENV set to C:\\tools\\miniconda3\\envs\\leo-dev instead of leo-dev? I guess we could split the path of CONDA_DEFAULT_ENV.

maphew commented 4 years ago

The activate.bat within conda base sets CONDA_DEFAULT_ENV to be the short name while the env activate sets a full path:

c:\tools\miniconda3\Scripts\activate.bat --> CONDA_DEFAULT_ENV=leo-dev C:\tools\miniconda3\envs\leo-dev\Scripts\activate --> CONDA_DEFAULT_ENV=C:\tools\miniconda3\envs\leo-dev

This might be idiosyncratic to my machine as I have 2 conda installs* and they're kind of intermingled as in the past I tried to get them to co-operating to share package cache, with mixed success.

(* Miniconda, as in the example, and a vendor delivered one via ArcGIS Pro)

Still digging...

newville commented 4 years ago

@maphew Well, that would be a pretty easy fix, basically

 conda_env = os.environ.get('CONDA_DEFAULT_ENV', '')
 conda_env = os.path.split(conda_env)[1]
bollwyvl commented 4 years ago

Shame on me for not looking here, but I think #28 handles this situation!