Compile python virtual environment
<p>I created a Python script for a Freelance job and I can't find how to compile/build/package it for easy sharing. The person for which I created it is not a technical one, so I can't explain him how to activate a virtualenv, install requirements and so on.</p>

<p>What is the easiest way for him to run the project right after downloading it?</p>

<p>Can the whole virtualenv be compiled into an <code>.exe</code>? If yes, can this be done inside a macOS system?</p>

<p>Yes you can package your python programs and it's dependencies with</p>

<p><a href="https://cx-freeze.readthedocs.io/en/latest/" rel="nofollow">Cx_Freeze</a></p>

<p>There are other python modules that do the same, personally i prefer <code>cx_Freeze</code> because it's cross platform and was the only one that worked out of the box for me.</p>

<p>By default <code>cx_Freeze</code> automatically discovers modules and adds them to the exe to be generated. but sometimes this doesn't work and you might have to add them by yourself</p>

<p>To create a simple executable from a file. you can just use the bundled <code>cxfreeze</code> script</p>

<pre><code>cxfreeze hello.py --target-dir dist
</code></pre>

<p>but more for more complex applications that have different files you'll have to create a distutils setup script.</p>

<p>Note that <code>cx_freeze</code> doesn't compile your code like a traditional compiler. it simply zips your python files and all it's dependencies ( as byte code) together, and includes the python interpreter to make your program run. So your code can be disassembled. (if anyone wants to) and you'll also notice that the size of your program would be larger than it was initially (Because of the extra files included)</p>

python virtualenv