How to access installed scripts on Windows?

Paul Moore p.f.moore at gmail.com
Mon Mar 6 05:29:45 EST 2017


On Sunday, 5 March 2017 22:26:17 UTC, eryk sun  wrote:
> On Sun, Mar 5, 2017 at 2:35 AM, ddbug <pavel.aronsky at gmail.com> wrote:
> >
> >> You can also develop using venv virtual environments. You can symlink
> >> or shell-shortcut to the activation script of a virtual environment.
> >
> > Interesting idea. But I have not seen any installers or guidance how to deploy something packaged
> > as a venv to users. Can you share any pointers please?
> 
> Are we talking about scripts for programmers to work with libraries
> that you publish (e.g. a command-line tool like cythonize), or
> applications for end users and IT staff? Virtual environments are
> primarily a solution for developers. For deployment to end users, take
> a look at what Paul Moore is doing with pylaunch and the embedded
> Python distribution:
> 
> https://github.com/pfmoore/pylaunch
> https://docs.python.org/3/using/windows.html#embedded-distribution

To clarify the situation, the "entry point" facility is basically designed to provide a command line interface to a Python module you are distributing. The target audience is therefore people who are using Python as a language, and so are (somewhat) familiar with setting up PATH, maybe even using virtualenvs, etc. That's not always how entry points are used in practice, because a lot of the alternatives for other use cases are not well known and/or limited. So entry points get used for situations where they aren't always ideal for the target audience.

If you're looking to deploy an application written in Python to users who don't really care about the implementation language, and just want to use the application, then entry points may not be the best option for you.

If you can rely on your users having Python installed and set up correctly (as an analogy, when distributing a Java program, users need to have a Java runtime installed) and you don't use any C extensions, then a zipapp (see https://docs.python.org/3.6/library/zipapp.html) may be enough for you - Python 3.6 registers the ".pyz" and ".pyzw" extensions for zipapps, so they should be runnable via double click without much difficulty. In a similar manner, but with a little more effort, you can deploy your application as a runnable directory, which supports C extensions, but may need a launcher script to work easily.

If you want to bundle Python with your application, so that it looks basically like a "native" executable, then py2exe and cx_Freeze are two projects that do this and have been round for quite some time. They may suit your needs better.

My pylaunch project (that Eryk linked to) is a prototype approach that is intended for distributors that want more control over the build process, which provides a flexible set of tools for people to build applications using the (somewhat smaller, and completely self-contained) embeddable distribution that became available with recent Python 3.x builds. It's targeted at the soon-to-be-released Python 3.6.1 and later (there's a minor issue with 3.6.0 that makes putting the embedded distribution in a subdirectory a little fiddly). If you're interested in building your own custom solution, it's probably something you should look at, but it's definitely not a finished product yet.

Hope this helps,
Paul



More information about the Python-list mailing list