Skip to main content

py-to-zip is a Python library that creates a zip file and a command file from your python code

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-to-zip-0.0.6.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

py_to_zip-0.0.6-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file py-to-zip-0.0.6.tar.gz.

File metadata

  • Download URL: py-to-zip-0.0.6.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for py-to-zip-0.0.6.tar.gz
Algorithm Hash digest
SHA256 fb252e3e8d943e7b31ae67cbddab7f8cc605fe1c8b50ba372a7bd319ca3a9480
MD5 b694e74336c510120434edf74a74e63b
BLAKE2b-256 79723e7ecadcaec687a50ba6995c607cf5ecb86a576bf3d246c002ce7d489d2b

See more details on using hashes here.

File details

Details for the file py_to_zip-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: py_to_zip-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for py_to_zip-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 090c8ea5ac026a7db12a4750c0738a4d7fd845ad67570665dfc1732a9f7b7d19
MD5 e3614f4f7fe02c69fb7b048a0a1bfd2e
BLAKE2b-256 aa7ebcef2f4e81985694120b777e2d0bded5d6683400957a679997214be81617

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page