New issue 217: Cannot invoke top-level scripts unqualified in native Windows 
install

https://bitbucket.org/blais/beancount/issues/217/cannot-invoke-top-level-scripts



Jeff:



For native Windows use, the python scripts cannot be invoked directly as 
unqualified commands. Wrapper batch scripts installed alongside the python 
scripts could address this.



I just installed beancount natively on Windows 10 (i.e., sans Cygwin, sans 
Ubuntu on Windows), as follows:



1. Per https://wiki.python.org/moin/WindowsCompilers, Installed Build Tools for 
Visual Studio 2017. (Workload: Visual C++ build tools *only*; Optionals: 
Windows 10 SDK (10.0.16299.0) for Desktop C++ *only*)

2. Downloaded copy of current source from bitbucket.

3. `cmd> python -m venv env` (just to confirm it plays nice in a venv)

4. `cmd> env\Scripts\activate.bat`

5. `cmd> pip install --upgrade setuptools` (not strictly necessary, suggested 
by link above)

6. `cmd> pip install .\<path-to-beancount>`



This works fine and dumps `bean-*` files into `env\Scripts`. These files have 
no extension, and contain a shebang with absolute path to 
`c:\<path>\<to>\env\Scripts\python.exe`, which presumably does something useful 
under Cygwin/MinGW, but is not processed by Windows command prompt. So, I 
cannot invoke `bean-*` commands unqualified at this point.



I do not know what the python community's standard practice—if any—is for 
dealing with this, but the obvious (to me) simple fix is to create `bean-*.bat` 
files in parallel (e.g., `env\Scripts\bean-bake.bat`), with the following 
trivial contents:



```

@python %~dp0%~n0 %*

```

In case it's not obvious, this passes a file in the same directory, with same 
name (sans extension) to python, forwarding all command-line arguments.



For now, I did this locally, by hand. Since `C:\<path>\<to>\env\Scripts` was 
prepended to my path by the venv's `activate.bat`, I can invoke, e.g., 
`bean-example` or `bean-example.bat` unqualified.



It would be nice if this happened automatically. Perhaps it could be done 
on-the-fly by `setup.py`?




-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/20180217053109.38999.59467%40celery-worker-108.ash1.bb-inf.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to