Note: For non-members, this article is also available at https://dineshkumarkb.com/tech/package-data-files-to-pyinstaller-binaries/
I am sure most of you would have used pyinstaller for generating executables. This article does not cover what a pyinstaller is. However, the focus of the article will be on how to add external data files to your pyinstaller binaries and their use cases.
Usually, we generate a one file executable in pyinstaller using the following command.
$pyinstaller --onefile --clean <file_name.py>
Let’s say you have a help file for your application which needs to be packed along with your executable. …
Note: For non-members, this article is also available at https://dineshkumarkb.com/tech/meet-ochrona-an-application-to-validate-your-dependencies/
Security in your code is considered to be of paramount importance today, especially when we work remotely. We do a lot of proof-of-concepts, implement business logic with multiple libraries. Though most of them are open source, there could be vulnerabilities, license issues when we productize the code for commercial use. It is almost impossible to keep an eye on every single library and their possibility for commercial use. That’s why we have vulnerability scanners to make lives easier.
Ochrona security provides solution for validating dependencies of your python project.
Note: For non-members, this article is also available at https://dineshkumarkb.com/tech/display-markdown-text-in-command-line-using-python/
Recently, I was given a task of refactoring our legacy command line application. I was thinking what more could we do to improvise a legacy command line application that’s working just fine.
Remembering the commands and their respective flags, optional parameters etc is bit hectic. Of course you could copy all the commands in a notepad and use ’em as needed. But that’s still annoying if you ask me.
So what did I do?
I came across this library called PyInquirer and
rich with which we could make colorful command…
Note: For non-members, this article is also available at https://dineshkumarkb.com/tech/build-command-line-applications-in-python-using-rich/
Do you want to get over the regular monochrome command line? Interested in building visually appealing clis? …Or want to showcase your cli with cool enhancements? If you have any of these on your mind, then you should definitely try using python’s
Rich works on OSX, linux and windows platforms
≥ Python 3.6.1
pip install rich
Rich is a Python library for writing rich text (with color and style) to the terminal, and for displaying advanced content such as tables, markdown, and syntax highlighted code.
Did you ever know that GitHub could host your static pages? If you didn’t, well you are not alone. GitHub provides GitHub Pages to host your documentation which contains static pages.
GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.
From GitHub Pages
Let’s assume you already have sphinx documentation generated in a
html format. If you don't know how to get started, please refer here.
By default, your GitHub pages will be disabled. …
Note: This article was originally published on https://dineshkumarkb.com/tech/generate-professional-python-sdk-documentation-using-sphinx/
Are you working on a Python SDK or a library that will be consumed by multiple users? Ever wondered how professional SDK documentations like boto3, read the docs are generated? Do you want to generate one like them? I know you would love to. Please read ahead.
Sphinx is a tool to generate attractive and professionally appealing documentation. This supports multiple output formats, great cross-references across the documentation, handling sample code, etc.
Sphinx uses reSTructuredText as its mark-up language. The sphinx documentation file’s extension is
Let’s assume you have already created…
Note : This article is also published in my personal blog (https://dineshkumarkb.com/tech/start-managing-your-python-dependencies-using-poetry/)
Pip has been the package installer for Python libraries for a long time. However, pip has a few limitations. We don’t have a single solution to download, install, package, build and publish in Python.
Traditionally we download and install dependencies using
pip in Python. However, we have to rely on
setuptools to build and distribute packages in Python.
We use the following commands to build a source distribution/binary distribution or a wheel file.
$python setup.py bdist
$python setup.py bdist_wheel
$python setup.py sdist
To publish to PyPI, we may…
The most common mistakes we make in interviews are the most silly ones. Do you agree? This happens because we ignore the ones which we are quite familiar. During interviews, we prepare the most difficult data structure and algo questions and seldom give importance to fibonacci or prime number programs. However, sometimes we get stuck during interviews in these petty programs. This article is a refresher for fibonacci series generation using python.
🆗 Now, let’s cut to the chase!
Note: For non-members, this article is also available at https://dineshkumarkb.com/tech/pip-the-complete-reference-guide/
pip is the package manager for python.pip can be used to install python libraries from PyPI. In other words,
pip is the
python. We use pip to install and manage python libraries that are not part of the python standard library.
Any python developer predeminantly uses
pip day in and out.However, the usage is limited to just install and occasionally upgrade.
This article is a consolidated non-exhaustive list of all the pip commands every python developer should know. This could be a reference for any future pip commands.
Note: For non-members, this article is also available at https://dineshkumarkb.com/tech/why-you-should-start-using-python-dataclasses/
I hope we all are familiar how plain Python classes work and their use cases. Python also provides an indirect way to implement immutable classes using namedtuples. Wait, why are we talking about
namedtuples here? Well, there is a reason why I am talking about them here.
For people, who are new to namedtuples please have a look here to understand more about it and it’s applications.
namedtuple is a container provided as part of the
collections module which has the same properties as a
tuple. The only difference…