Skip to main content

py-to-zip

py-to-zip is a Python library for distributing Python files. It creates a zip file and a command file from your python code. The result is a zip file that includes the source python files and a file that can be double-clicked in order to run the main python file. The receiving computer should have Python installed and in PATH, but it is not necessary for the receiver to open a python IDE or a command line window.

py-to-zip runs in Python 3+ and only in Windows. The receiving computer can have all Python versions if your source code supports them.

Instructions

You need to make a settings.ini file like this:

[settings]
main_file=main.py
# The main file that would be run with the cmd file
name=name of project
# You can leave empty, default value is the name of your main file without extension
glob_pattern=*.py,data/*.png,data/**/*.txt
# The glob patterns for all the files to add the zip, separated by commas. 
# Use ** only if using python 3.5 and higher. make sure that it includes your 
# main file as well. 
glob_recursive=1 
# Optional. Set the recursive variable for the glob function,
# this is only for python 3.5+. If python version is lower, ignores this value.
cmd_file=command.bat
# The name of command file,(like run.cmd or play.bat)
# By default it will be <main_file>.cmd
python_exe=py
# The python command that is to be run on receiving computer (py,python,python3,...)

Important: The main file must be found by glob using the pattern glob_pattern.

To create zip from ini using command line:

czip {your ini file}
# or
CZip.bat {your ini file}
# for example:
czip settings.ini

And the py-to-zip creates the zip that includes source and command file automatically in the current folder.

Access from python

To access the py-to-zip from a python file:

from py_to_zip.py_to_zip import by_config

# create ini parameters in python code

by_config(
    dict(main_file="py_to_zip.py", 
         name="py-to-zip", 
         glob_pattern="*.py,data\\**\\*.txt",
         glob_recursive=True, 
         cmd_file="czip.bat", 
         python_exe="py",
         )
)

And the py-to-zip creates the zip that includes source and command file automatically in the current folder, without additional command line commands.

Installation

To install with pip - type in terminal:

(python -m) pip install py_to_zip

Additional options

Additional options when calling from Python file:

from py_to_zip.py_to_zip import Zip
z= Zip(
         main_file = "py_to_zip.py",  
         name = "py-to-zip", 
         glob_pattern = "*.py,data\\**\\*.txt",
         glob_recursive = True,  
         cmd_file = "czip.bat",  
         python_exe = "py",
         quiet = True or False,
        # if set to False,py-to-zip will not print anything.
        # this can be used also in INI file
)

#to do the same as before you can use the command:
z.create_zip()
#but you can also acsess
z._find_names() #to find names of file with glob
z._create_cmd() #to create the cmd script
### or alternatively
from py_to_zip.py_to_zip import _parse_cmd_argev 
_parse_cmd_argev(["file.ini"])#exactly likce czip {your ini file}

Author

matan h

License

This project is licensed under the MIT License.

created by

This library was created and uploaded using libtool

Metadata

Release files for py-to-zip 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-to-zip 0.0.6
File Size Uploaded
py-to-zip-0.0.6.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-to-zip 0.0.6
File Interpreter ABI Platform
py_to_zip-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / py-to-zip-0.0.6.tar.gz

Download URL py-to-zip-0.0.6.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fb252e3e8d943e7b31ae67cbddab7f8cc605fe1c8b50ba372a7bd319ca3a9480
BLAKE2b-256 checksum
How to use checksums
79723e7ecadcaec687a50ba6995c607cf5ecb86a576bf3d246c002ce7d489d2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

Release files / py_to_zip-0.0.6-py3-none-any.whl

Download URL py_to_zip-0.0.6-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
090c8ea5ac026a7db12a4750c0738a4d7fd845ad67570665dfc1732a9f7b7d19
BLAKE2b-256 checksum
How to use checksums
aa7ebcef2f4e81985694120b777e2d0bded5d6683400957a679997214be81617
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page