Pyscaffold module in Python
Last Updated :
19 Nov, 2021
Starting off with a Python project is usually quite complex and complicated as it involves setting up and configuring some files. This is where Pyscaffold comes in. It is a tool to set up a new python project, is very easy to use and sets up your project in less than 10 seconds! To use Pyscaffold, Git is a must, especially Windows users should have “Git Bash” installed. Additionally, the installation of PyScaffold also requires a recent version of “setup tools”.
Each Python package project is internally represented by PyScaffold as a tree data structure that directly relates to a directory entry in the file system. This tree is implemented as a simple dictionary in which keys indicate the path where files will be generated, while values indicate their content.
Installation
To install Pyscaffold using pip, carry out the following command which installs the latest Pyscaffold version:
pip install --upgrade pyscaffold

In case you do not have pip installed, refer to this article: How to install pip command
PyScaffold can also be installed with conda by carrying out the following on Anaconda Command Prompt:
conda install -c conda-forge pyscaffold


If you see anything like this, then this means Pyscaffold has been installed successfully!
Setting the new Project
PyScaffold comes with a lot of characteristics and configuration defaults to make the frequent tasks in developing, maintaining and distributing your own Python package as easy as possible.
To set up a new python project, use the putup command:
putup Your_Project
This creates a folder Your_Project with the project layout of a Python project and it has a Your_Project package folder along with documents and tests folders and the files setup.py, setup.cfg, AUTHORS.txt, README.txt, and LICENSE.txt. All configuration is done in “setup.cfg” instead of setup.py. Here, you can change all the settings related to the package (i.e., author, URL, license, etc.). Also, to add additional data files, we can add their names in the setup.cfg and they’ll be automatically added.
PyScaffold is designed to cover the essentials of authoring and distributing Python packages. Most of the time, setting up putup options is enough to ensure the proper configuration of a project. PyScaffold can be extended at runtime by other Python packages. It is also possible to write an external script or program that embeds PyScaffold and use it to perform some user-defined actions.
Example:
Python3
from pyscaffold.log import logger
logger.report( 'invoke' , 'custom_action' )
with logger.indent():
logger.report( 'create' , 'some / file / path' )
|
Updates:
- Whenever a new update of PyScaffold gets released, you can use this command to update the
structure/scaffold of your project:
output --update my_project
- An update will only update files that are not usually used or modified by the user, therefore, to
update all the files, use force update:
--update --force
- Note:
- If you are updating from a PyScaffold version before 2.0, you must manually remove the files versioneer.py and MANIFEST.in.
- If you are updating from a version before 2.2, you must remove ${PACKAGE}/_version.py.
How to migrate to PyScaffold
Initially, the project (let’s say my_project) has to be on a Git repository and includes a package (let’s say my_package) along with your python modules.
Note: Your working tree is not dirty, i.e. all changes are committed and all important files are under version control.
- Start by changing into the parent folder of my_project and type the following command in order to deploy the new project structure in your repository.
putup my_project --force --no-skeleton -p my_package
- Change into my_project and move your old package folder into src with this command and use the same technique if the project has a test folder other than tests or a documentation folder other than docs.
git mv my_package/* src/my_package/
- Use git status to check for untracked files and add them with git add.
- . Eventually, use git difftool to check all overwritten files for changes that need to be transferred. All configuration that you may have done in setup.py, need to be moved to setup.cfg. In most cases you will not need to make changes to the new setup.py file provided by PyScaffold.
- Run these commands to check everything works:
run python setup.py install and python setup.pysdist
- Also run python setup.py docs and python setup.py test to check that Sphinx and PyTest runs correctly.
Similar Reads
Pylint module in Python
We often get stuck in the middle or encounter errors when we code/run some programs. We usually surf the internet for help and make our code run. But how do we understand the published code on the internet? Some of the typical answers to this question are docstrings, articles written above that code
4 min read
Pymatrix module in python
Pymatrix is a lightweight matrix library which supports basic linear algebra operations. The elements in matrix should be numeric type to support basic algebra operations - int, float, rational, complex. Instantiating Matrix  Using Matrix constructor Matrix can be initialised using constructor of
3 min read
Pygorithm module in Python
Pygorithm module is a Python module written purely in Python and for educational purposes only. One can get the code, time complexities and much more by just importing the required algorithm. It is a good way to start learning Python programming and understanding concepts. Pygorithm module can also
2 min read
PyDictionary module in Python
AyDictionary It's a Python module used to fetch definitions of words, while googletrans provides translation services. meaningstranslationsInstallation To install AyDictionary run the following pip code on the terminal / command prompt: pip install AyDictionary googletrans==4.0.0-rc1Getting Started
1 min read
Python Module Index
Python has a vast ecosystem of modules and packages. These modules enable developers to perform a wide range of tasks without taking the headache of creating a custom module for them to perform a particular task. Whether we have to perform data analysis, set up a web server, or automate tasks, there
4 min read
Python Modules
Python Module is a file that contains built-in functions, classes,its and variables. There are many Python modules, each with its specific work. In this article, we will cover all about Python modules, such as How to create our own simple module, Import Python modules, From statements in Python, we
7 min read
Python Fire Module
Python Fire is a library to create CLI applications. It can automatically generate command line Interfaces from any object in python. It is not limited to this, it is a good tool for debugging and development purposes. With the help of Fire, you can turn existing code into CLI. In this article, we w
3 min read
Basics Of Python Modules
A library refers to a collection of modules that together cater to a specific type of needs or application. Module is a file(.py file) containing variables, class definitions statements, and functions related to a particular task. Python modules that come preloaded with Python are called standard li
3 min read
Built-in Modules in Python
Python is one of the most popular programming languages because of its vast collection of modules which make the work of developers easy and save time from writing the code for a particular task for their program. Python provides various types of modules which include Python built-in modules and ext
9 min read
struct module in Python
This module performs conversions between Python values and C structs represented as Python bytes objects. Format strings are the mechanism used to specify the expected layout when packing and unpacking data. Module struct is available in Python 3.x and not on 2.x, thus these codes will run on the Py
5 min read