8 Popular Python Distribution Libraries

In this Python article, let's learn about Distribution: 8 Popular Python Distribution Libraries

Table of contents:

  • dh-virtualenv - Build and distribute a virtualenv as a Debian package.
  • Nuitka - Compile scripts, modules, packages to an executable or extension module.
  • py2app - Freezes Python scripts (Mac OS X).
  • py2exe - Freezes Python scripts (Windows).
  • pyarmor - A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
  • PyInstaller - Converts Python programs into stand-alone executables (cross-platform).
  • pynsist - A tool to build Windows installers, installers bundle Python itself.
  • shiv - A command line utility for building fully self-contained zipapps (PEP 441), but with all their dependencies included.

What is distribution in Python?

A distribution of Python is a bundle that contains an implementation of Python along with a bunch of libraries or tools. In theory, a distribution of Python could use any implementation, although all the ones I know of use CPython.


Libraries to create packaged executables for release distribution

  1. dh-virtualenv

dh-virtualenv is a tool that aims to combine Debian packaging with self-contained virtualenv based Python deployments.

The idea behind dh-virtualenv is to be able to combine the power of Debian packaging with the sandboxed nature of virtualenvs. In addition to this, using virtualenv enables installing requirements via Python Package Index instead of relying on the operating system provided Python packages. The only limiting factor is that you have to run the same Python interpreter as the operating system.

For complete online documentation including installation instructions, see the online documentation.

Presentations, Blogs & Other Resources

Here are a few external resources that can help you to get a more detailed first impression of dh-virtualenv, or advocate its use in your company or project team.

Using dh-virtualenv

Using dh-virtualenv is fairly straightforward. First, you need to define the requirements of your package in requirements.txt file, in the format defined by pip.

To build a package using dh-virtualenv, you need to add dh-virtualenv in to your build dependencies and write following debian/rules file:

  %:
          dh $@ --with python-virtualenv

Note that you might need to provide additional build dependencies too, if your requirements require them.

Also, you are able to define the root path for your source directory using --sourcedirectory or -D argument:

  %:
          dh $@ --with python-virtualenv --sourcedirectory=root/srv/application

NOTE: Be aware that the configuration in debian/rules expects tabs instead of spaces!

Once the package is built, you have a virtualenv contained in a Debian package and upon installation it gets placed, by default, under /opt/venvs/<packagename>.

For more information and usage documentation, check the accompanying documentation in the doc folder, also available at Read the Docs.

View on GitHub


2.  Nuitka

Nuitka is the optimizing Python compiler written in Python that creates executables that run without an need for a separate installer. Data files can both be included or put alongside.

It is easy to use and just works. It is fully compatible with Python2 (2.6, 2.7) and Python3 (3.3 - 3.10), works on Windows, macOS, Linux and more, basically where Python works for you already.

Nuitka Standard

The standard edition bundles your code, dependencies and data into a single executable if you want. It also does acceleration, just running faster in the same environment, and can produce extension modules as well. It is freely distributed under the Apache license.

View on Source


3.  py2app

py2app is a Python setuptools command which will allow you to make standalone application bundles and plugins from Python scripts. py2app is similar in purpose and design to py2exe for Windows.

NOTE: py2app must be used on macOS to build applications, it cannot create Mac applications on other platforms.

View on GitHub


4.  py2exe

py2exe is a software to build standalone Windows executable programs (32-bit and 64-bit) from Python scripts. py2exe can build console executables and windows (GUI) executables. py2exe supports the Python versions included in the official development cycle.

Changes

The detailed changelog is published on GitHub.

Version 0.12.0.0:

  • Introduce the new py2exe.freeze API. Documentation can be found here.
  • Use of the setup.py py2exe command and of distutils is deprecated as per PEP 632. Both these interfaces will be removed in the next major release. See here for a migration guide.
  • Add two hooks to fix the bundling of winrt and passlib.

Version 0.11.1.1:

  • The log file for windows apps is now stored in %APPDATA% by default
  • ModuleFinder now raises an explicit error if a required module is in excludes
  • Restore hook functionality for pkg_resources
  • The Stderr.write method used for windows apps now returns the number of written bytes

Version 0.11.1.0:

  • Drop support for Python 3.6
  • Include package metadata in the bundle archive (to be used by e.g. importlib.metadata)
  • Fixed a bug that prevented to use the optimize option when six was in the bundle
  • Fixed a bug that ignored the optimize flag for some packages

Version 0.11.0.1:

  • Show again relative paths in Tracebacks that happen from the frozen application (#12 and #114)

View on GitHub


5.  PyArmor

PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts. It protects Python scripts by the following ways:

  • Obfuscate code object to protect constants and literal strings.
  • Obfuscate co_code of each function (code object) in runtime.
  • Clear f_locals of frame as soon as code object completed execution.
  • Verify the license file of obfuscated scripts while running it.

Support Platforms

  • Python 2.7 and Python3.0~Python3.10
  • Prebuilt Platform: win32, win_amd64, linux_i386, linux_x86_64, macosx_x86_64
  • Embedded Platform: Raspberry Pi, Banana Pi, Orange Pi, TS-4600 / TS-7600 and more

Quick Start

Installation

pip install pyarmor

Obfuscate scripts

pyarmor obfuscate foo.py

Run obfuscated scripts

python dist/foo.py

Pack obfuscated scripts into one bundle

pip install pyinstaller
pyarmor pack foo.py

Obfuscate scripts with an expired license

pyarmor licenses --expired 2018-12-31 r001
pyarmor obfuscate --with-license licenses/r001/license.lic foo.py

There is also a web-ui package pyarmor-webui

pip install pyarmor-webui

Start webui, open web page in browser (snapshots)

pyarmor-webui

View on GitHub


6.  PyInstaller

PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules.


PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files -- including the active Python interpreter! -- and puts them with your script in a single folder, or optionally in a single executable file.

PyInstaller is tested against Windows, macOS, and GNU/Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a GNU/Linux app you run it in GNU/Linux, etc. PyInstaller has been used successfully with AIX, Solaris, FreeBSD and OpenBSD, but is not tested against them as part of the continuous integration tests.

Installation

PyInstaller is available on PyPI. You can install it through pip:

pip install pyinstaller

Requirements and Tested Platforms

  • Python:
  • Windows (32bit/64bit):
  • Linux:
  • macOS (x86_64 or arm64):
    • macOS 10.15 (Catalina) or newer.
    • Supports building universal2 applications provided that your installation of Python and all your dependencies are also compiled universal2.
    • GNU libc based distributions on architectures x86_64, aarch64, i686, ppc64le, s390x.
    • musl libc based distributions on architectures x86_64, aarch64.
    • ldd: Console application to print the shared libraries required by each program or shared library. This typically can be found in the distribution-package glibc or libc-bin.
    • objdump: Console application to display information from object files. This typically can be found in the distribution-package binutils.
    • objcopy: Console application to copy and translate object files. This typically can be found in the distribution-package binutils, too.
    • Raspberry Pi users on armv5-armv7 should add piwheels as an extra index url then pip install pyinstaller as usual.
    • PyInstaller should work on Windows 7 or newer, but we only officially support Windows 8+.
    • Support for Python installed from the Windows store without using virtual environments requires PyInstaller 4.4 or later.
    • Note that Windows on arm64 is not yet supported. If you have such a device and want to help us add arm64 support then please let us know on our issue tracker.
    • 3.7-3.10. Note that Python 3.10.0 contains a bug making it unsupportable by PyInstaller. PyInstaller will also not work with beta releases of Python 3.11.
    • tinyaes 1.0+ (only if using bytecode encryption). Instead of installing tinyaes, pip install pyinstaller[encryption] instead.

View on GitHub


7.  pynsist

Pynsist is a tool to build Windows installers for your Python applications. The installers bundle Python itself, so you can distribute your application to people who don't have Python installed.

Pynsist 2 requires Python 3.5 or above. You can use Pynsist 1.x on Python 2.7 and Python 3.3 or above.

Quickstart

  1. Get the tools. Install NSIS, and then install pynsist from PyPI by running pip install pynsist.

2.    Write a config file installer.cfg, like this:

[Application]
name=My App
version=1.0
# How to launch the app - this calls the 'main' function from the 'myapp' package:
entry_point=myapp:main
icon=myapp.ico

[Python]
version=3.6.3

[Include]
# Packages from PyPI that your application requires, one per line
# These must have wheels on PyPI:
pypi_wheels = requests==2.18.4
     beautifulsoup4==4.6.0
     html5lib==0.999999999

# Other files and folders that should be installed
files = LICENSE
    data_files/

See :doc:`cfgfile` for more details about this, including how to bundle packages which don't publish wheels.

3.    Run pynsist installer.cfg to generate your installer. If pynsist isn't found, you can use python -m nsist installer.cfg instead.

View on GitHub


8.  shiv

shiv is a command line utility for building fully self-contained Python zipapps as outlined in PEP 441, but with all their dependencies included!

shiv's primary goal is making distributing Python applications fast & easy.

📗 Full documentation can be found here.

sys requirements

  • python3.6+
  • linux/osx/windows

quickstart

shiv has a few command line options of its own and accepts almost all options passable to pip install.

simple cli example

Creating an executable of flake8 with shiv:

$ shiv -c flake8 -o ~/bin/flake8 flake8
$ ~/bin/flake8 --version
3.7.8 (mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.7.4 on Darwin

-c flake8 specifies the console script that should be invoked when the executable runs, -o ~/bin/flake8 specifies the location of the generated executable file and flake8 is the dependency that should be installed from PyPI.

Creating an interactive executable with the boto library:

$ shiv -o boto.pyz boto
Collecting boto
Installing collected packages: boto
Successfully installed boto-2.49.0
$ ./boto.pyz
Python 3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import boto
>>> boto.__version__
'2.49.0'

installing

You can install shiv by simply downloading a release from https://github.com/linkedin/shiv/releases or via pip / pypi:

pip install shiv

You can even create a pyz of shiv using shiv!

python3 -m venv .
source bin/activate
pip install shiv
shiv -c shiv -o shiv shiv

View on GitHub


Frequently asked questions about Distribution python

  • How do you create a distribution in Python?

You can generate a binomial distributed discrete random variable using scipy. stats module's binom. rvs() method which takes $n$ (number of trials) and $p$ (probability of success) as shape parameters. To shift distribution use the loc parameter.

  • How do you plot a distribution curve in Python?

Approach

  1. Import module.
  2. Create data.
  3. Calculate mean and deviation.
  4. Calculate normal probability density.
  5. Plot using above calculated values.
  6. Display plot.
  • Which Python distribution is best?

Based on the open source Conda packaging system, Anaconda is the best Python distribution I have found till now. For one, it comes with all the scientific libraries like numpy, scipy etc preinstalled, so you don't have to worry about messing with compiling them yourself.

  • What is distribution in programming?

In computer software, distribution is the phase that follows packaging. The package will be on some distribution medium, such as compact disc, or may be simply located on a server where customers can download it electronically.


Related videos:

Python Statistics - Normal Distribution and Probability Functions


Related posts:

#python 

What is GEEK

Buddha Community

8 Popular Python Distribution Libraries
Shardul Bhatt

Shardul Bhatt

1626775355

Why use Python for Software Development

No programming language is pretty much as diverse as Python. It enables building cutting edge applications effortlessly. Developers are as yet investigating the full capability of end-to-end Python development services in various areas. 

By areas, we mean FinTech, HealthTech, InsureTech, Cybersecurity, and that's just the beginning. These are New Economy areas, and Python has the ability to serve every one of them. The vast majority of them require massive computational abilities. Python's code is dynamic and powerful - equipped for taking care of the heavy traffic and substantial algorithmic capacities. 

Programming advancement is multidimensional today. Endeavor programming requires an intelligent application with AI and ML capacities. Shopper based applications require information examination to convey a superior client experience. Netflix, Trello, and Amazon are genuine instances of such applications. Python assists with building them effortlessly. 

5 Reasons to Utilize Python for Programming Web Apps 

Python can do such numerous things that developers can't discover enough reasons to admire it. Python application development isn't restricted to web and enterprise applications. It is exceptionally adaptable and superb for a wide range of uses.

Robust frameworks 

Python is known for its tools and frameworks. There's a structure for everything. Django is helpful for building web applications, venture applications, logical applications, and mathematical processing. Flask is another web improvement framework with no conditions. 

Web2Py, CherryPy, and Falcon offer incredible capabilities to customize Python development services. A large portion of them are open-source frameworks that allow quick turn of events. 

Simple to read and compose 

Python has an improved sentence structure - one that is like the English language. New engineers for Python can undoubtedly understand where they stand in the development process. The simplicity of composing allows quick application building. 

The motivation behind building Python, as said by its maker Guido Van Rossum, was to empower even beginner engineers to comprehend the programming language. The simple coding likewise permits developers to roll out speedy improvements without getting confused by pointless subtleties. 

Utilized by the best 

Alright - Python isn't simply one more programming language. It should have something, which is the reason the business giants use it. Furthermore, that too for different purposes. Developers at Google use Python to assemble framework organization systems, parallel information pusher, code audit, testing and QA, and substantially more. Netflix utilizes Python web development services for its recommendation algorithm and media player. 

Massive community support 

Python has a steadily developing community that offers enormous help. From amateurs to specialists, there's everybody. There are a lot of instructional exercises, documentation, and guides accessible for Python web development solutions. 

Today, numerous universities start with Python, adding to the quantity of individuals in the community. Frequently, Python designers team up on various tasks and help each other with algorithmic, utilitarian, and application critical thinking. 

Progressive applications 

Python is the greatest supporter of data science, Machine Learning, and Artificial Intelligence at any enterprise software development company. Its utilization cases in cutting edge applications are the most compelling motivation for its prosperity. Python is the second most well known tool after R for data analytics.

The simplicity of getting sorted out, overseeing, and visualizing information through unique libraries makes it ideal for data based applications. TensorFlow for neural networks and OpenCV for computer vision are two of Python's most well known use cases for Machine learning applications.

Summary

Thinking about the advances in programming and innovation, Python is a YES for an assorted scope of utilizations. Game development, web application development services, GUI advancement, ML and AI improvement, Enterprise and customer applications - every one of them uses Python to its full potential. 

The disadvantages of Python web improvement arrangements are regularly disregarded by developers and organizations because of the advantages it gives. They focus on quality over speed and performance over blunders. That is the reason it's a good idea to utilize Python for building the applications of the future.

#python development services #python development company #python app development #python development #python in web development #python software development

Ray  Patel

Ray Patel

1619571780

Top 20 Most Useful Python Modules or Packages

 March 25, 2021  Deepak@321  0 Comments

Welcome to my blog, In this article, we will learn the top 20 most useful python modules or packages and these modules every Python developer should know.

Hello everybody and welcome back so in this article I’m going to be sharing with you 20 Python modules you need to know. Now I’ve split these python modules into four different categories to make little bit easier for us and the categories are:

  1. Web Development
  2. Data Science
  3. Machine Learning
  4. AI and graphical user interfaces.

Near the end of the article, I also share my personal favorite Python module so make sure you stay tuned to see what that is also make sure to share with me in the comments down below your favorite Python module.

#python #packages or libraries #python 20 modules #python 20 most usefull modules #python intersting modules #top 20 python libraries #top 20 python modules #top 20 python packages

Top 7 Python Libraries Used For Hacking

python is one of the most go-for languages among the developers due to the availability of open-source libraries and frameworks. According to a survey reportPython is the top language preferred for Statistical Modelling, and an overwhelming majority of practitioners prefer Python as the language for statistical works.

Python has become a favourite language for hackers these days. The reason is the presence of pre-built tools and libraries, which makes hacking easy. In fact, the language is adequate for ethical hacking as ethical hackers need to develop smaller scripts, and Python fulfils this criterion.

Below here, we listed down the top 7 Python libraries used in hacking.

1| Requests

Stars: 43.3k

**About: **Requests is a simple HTTP library for Python that allows a user to send HTTP/1.1 requests extremely easily. This library helps in building robust HTTP applications and includes intuitive features such as automatic content decompression and decoding, connection timeouts, basic & digits authentication, among others.

Know more here.

2| Scapy

Stars: 5.5k

About: Scapy is a powerful Python-based interactive packet manipulation program and library. This library is able to forge or decode packets of a wide number of protocols, send them on the wire, capture them, store or read them using pcap files, match requests, and more. It allows the construction of tools that can easily scan or attack networks. It is designed to allow fast packet prototyping by using default values that work. It can also perform tasks such as sending invalid frames, injecting your own 802.11 frames, combining techniques, such as VLAN hopping with ARP cache poisoning, VOIP decoding on WEP encrypted channel, etc., which most other tools cannot.

Know more here.

3| IMpacket

**Stars: **5.3k

**About: **IMpacket is a library that includes a collection of Python classes for working with network protocols. It is focused on providing low-level programmatic access to network packets. It allows Python developers to craft and decode network packets in a simple and consistent manner. The library provides a set of tools as examples of what can be done within the context of this library.

Know more here.

4| Cryptography

**Stars: **3.5k

**About: **Cryptography is a package which provides cryptographic recipes and primitives to Python developers. It includes both high-level recipes and low-level interfaces to common cryptographic algorithms such as symmetric ciphers, message digests and key derivation functions. This library is broadly divided into two levels. One is with safe cryptographic recipes that require little to no configuration choices. The other level is low-level cryptographic primitives, which are often dangerous and can be used incorrectly.

Know more here.

#developers corner #hacking tools #libraries for hacking #python #python libraries #python libraries used for hacking #python tools

August  Larson

August Larson

1625100480

4 Cool Python Libraries That You Should Know About

Discover useful Python libraries that you should try out in your next project

Some of my most popular blogs are about Python libraries. I believe that they are so popular because Python libraries have the power to save us a lot of time and headaches. The problem is that most people focus on those most popular libraries but forget that multiple less-known Python libraries are just as good as their most famous cousins.

Finding new Python libraries can also be problematic. Sometimes we read about these great libraries, and when we try them, they don’t work as we expected. If this has ever happened to you, fear no more. I got your back!

In this blog, I will show you four Python libraries and why you should try them. Let’s get started.

#python #coding #programming #cool python libraries #python libraries #4 cool python libraries

Art  Lind

Art Lind

1602968400

Python Tricks Every Developer Should Know

Python is awesome, it’s one of the easiest languages with simple and intuitive syntax but wait, have you ever thought that there might ways to write your python code simpler?

In this tutorial, you’re going to learn a variety of Python tricks that you can use to write your Python code in a more readable and efficient way like a pro.

Let’s get started

Swapping value in Python

Instead of creating a temporary variable to hold the value of the one while swapping, you can do this instead

>>> FirstName = "kalebu"
>>> LastName = "Jordan"
>>> FirstName, LastName = LastName, FirstName 
>>> print(FirstName, LastName)
('Jordan', 'kalebu')

#python #python-programming #python3 #python-tutorials #learn-python #python-tips #python-skills #python-development