Esempio n. 1
0
#cx freeze is for making a windows exe. this file is used by the release script to invoke it
from cx_Freeze import main

main()
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
with open(os.path.join(base_dir, 'readme.txt'), 'w', encoding='utf8') as readme:
    readme.writelines((readme1, readme2, readme3, readme4, readme5, readme6, 
                       readme7, readme8))

# Create the executable in the same directory
sys.argv.extend(['TrimSubs.py', '--target-dir', base_dir, '--exclude-modules', 
                 'tkinter,socket,webbrowser,socketserver,mimetypes,ssl',  
                 '--compress', '-O'])
cx_Freeze.main()

# Compress executable files with UPX, if present
if not os.path.isfile(upx_path):
    upx_path = 'upx.exe' if os.path.isfile('upx.exe') else ''
if upx_path:
    for file in (file for file in os.listdir(base_dir) if 
                 os.path.splitext(file)[1] in ('.exe', '.dll', '.pyd')):
        subprocess.call([upx_path, os.path.join(base_dir, file), 
                         '--lzma', '--best', '--no-progress'], shell=True)

# Create ZIP archive and delete the temporal directory
with zipfile.ZipFile('TrimSubs {} (Windows executable).zip'.format(
                     version), 'w', compression=zipfile.ZIP_DEFLATED
                     ) as zip:
    for dirpath, dirnames, filenames in os.walk(base_dir):