Closed JobLeonard closed 6 years ago
This should remove the need for anaconda in the path, but still requires compilation:
set anaconda_path="conda info --root"
%anaconda_path%\python.exe .\python\loom_viewer\loom %*
So the problem may be that Anaconda does not include pylauncher
on windows:
https://stackoverflow.com/questions/30794342/python-windows-where-is-the-python-launcher
It can be installed separately: https://bitbucket.org/vinay.sajip/pylauncher
This may remove the need for a loom.bat
file, and also make loom-viewer pip-installable. Will test tonight (when I get home and have access to my Windows machine)
Ok, so after looking ta this some more I think I finally have figured out two overlapping problems are, and how to fix it by doing something different altogether:
pip install ...
saves installed python packages in C:\Anaconda3\Scripts\
, including our loom
file.loom
has no extension, even with pylauncher
it doesn't work in Windows. If I rename it to loom.py
and then type loom.py
in the windows command line after installing pylauncher
, everything works.Plan to fix:
loom.exe
as part of the build processSince it will be installed to the Scripts
folder, it should now be executable from anywhere, and without typing the full extension.
This should remove the need for compiling the loom viewer from source for windows users (and all the baggage that it brings with it)
Nopenopenope, py2exe isn't the answer either. That just creates a completely standalone exe file, which would require including all SciPi dependencies. Even assuming this is possible to begin with, that's ridiculously huge.
So finally, I figured "maybe I can trick setup.py
to include a loom.bat
file to make everything work?", and then I discuvered this in the SetupTools documentation:
Feature highlights:
- ...
- Automatically generate wrapper scripts or Windows (console and GUI) .exe files for any number of “main” functions in your project. (Note: this is not a py2exe replacement; the .exe files rely on the local Python installation.)
https://setuptools.readthedocs.io/en/latest/setuptools.html
Packaging and installing scripts can be a bit awkward with the distutils. For one thing, there’s no easy way to have a script’s filename match local conventions on both Windows and POSIX platforms. For another, you often have to create a separate file just for the “main” script, when your actual “main” is a function in a module somewhere. And even in Python 2.4, using the -m option only works for actual .py files that aren’t installed in a package.
setuptools fixes all of these problems by automatically generating scripts for you with the correct extension, and on Windows it will even create an .exe file so that users don’t have to change their PATHEXT settings. The way to use this feature is to define “entry points” in your setup script that indicate what function the generated script should import and run. For example, to create two console scripts called foo and bar, and a GUI script called baz, you might do something like this:
setup( # other arguments here... entry_points={ 'console_scripts': [ 'foo = my_package.some_module:main_func', 'bar = other_module:some_func', ], 'gui_scripts': [ 'baz = my_package_gui:start_func', ] } )
https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation
Ok... should have looked here first I guess. Let's see if usig console_scripts
does the trick
Success!!!! WHOOOHOOO!!!
So once we push this to pip, we can remove the special Windows instructions.
Done, and updated README while I was at it.
It would be great if we could avoid requiring Windows users to compile everything from source.
http://www.voidspace.org.uk/python/articles/command_line.shtml#path