Properly initialize a Python project
Project description
Setupinit
Properly initialize a Python project
This project is part of the Pyrustic Open Ecosystem.
Table of contents
Overview
Setupinit is a command line tool that turns an empty directory into a Python project. This tool also ensures that an existing Python project is properly initialized. When you run setupinit init
from the command line, the current working directory is populated with files and folders following the conventional Python project structure as described in the Python Packaging User Guide.
Setupinit derives the project name from the current working directory, then computes the package name from it. The package name is different from the project name. For example, the package name of the cyberpunk-theme
project is cyberpunk_theme
. The package name is then used to initialize the contents of certain files like setup.cfg
.
As a developer, you remain in control of your project, so no existing file will be modified by Setupinit. If, for example, you accidentally corrupted the contents of setup.cfg
, you can simply delete it, then run setupinit init
from the command line to create a brand new setup.cfg
.
Example
Initialize an empty Python project:
$ cd /path/to/project
$ setupinit init
Successfully initialized !
Check if a project is initialized:
$ cd /path/to/demo
$ setupinit check
This project is already initialized !
API
Setupinit exposes an API (the same used by the CLI) with which you can interact programmatically in Python.
import setupinit
PROJECT_DIR = "/path/to/project"
project_name = setupinit.get_project_name(PROJECT_DIR)
if setupinit.initialized(PROJECT_DIR):
msg = "{} is already initialized.".format(project_name)
print(msg)
else:
setupinit.initialize(PROJECT_DIR)
msg = "{} is initialized !".format(project_name)
print(msg)
Read the modules documentation.
Project structure
This is the contents of a newly created Python project with Setupinit:
demo/ # the demo project ($PROJECT_DIR) [1]
demo/ # this is the app package ($APP_PKG) [2]
__init__.py
__main__.py # the mighty entry point of your app !
tests/
__init__.py
MANIFEST.in # already filled with convenient lines of rules
pyproject.toml # the new unified Python project settings file [3]
README.md
setup.cfg # define here your name, email, dependencies, and more [4]
setup.py # it is not a redundancy, don't remove it, don't edit it [5]
VERSION # unique location to define the version of the app [6]
.gitignore # you can edit it if you want
[1]
This is the project directory ($PROJECT_DIR).[2]
Your codebase lives in the app package ($APP_PKG).[3]
Read What the heck is pyproject.toml ? and the PEP 518.[4]
Read this user guide to edit thesetup.cfg
file.[5]
If you want editable installs you still need asetup.py
shim.[6]
You won't need to edit this file if you use Backstage or Buildver a command line tool with a built-in intuitive versioning mechanism.
You can even run this new project:
$ cd /path/to/demo
$ python -m demo
Hello Friend !
Related projects
For a smooth developer experience, you can try related projects: buildver and backstage.
Buildver
Buildver is a command line tool to build a Python distribution package from a project. This tool comes with a built-in versioning mechanism that works smoothly with the package builder while being intuitive for the user.
Discover Buildver !
Backstage
Backstage is a language-agnostic command line tool that allows the developer to define, coordinate, and use the various resources at his disposal to create and manage a software project.
Discover Backstage !
Installation
Setupinit is cross platform and versions under 1.0.0 will be considered Beta at best. It is built on Ubuntu with Python 3.8 and should work on Python 3.5 or newer.
For the first time
$ pip install setupinit
Upgrade
$ pip install setupinit --upgrade --upgrade-strategy eager
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
Built Distribution
File details
Details for the file setupinit-0.0.4.tar.gz
.
File metadata
- Download URL: setupinit-0.0.4.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.6.1 requests/2.9.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2aac7a86a42ab351be6cc54f360edbe19a4622fe53a342e64d3fb0952f73d0a |
|
MD5 | af19b810a8b0164f8807fa105cc009f5 |
|
BLAKE2b-256 | d36f09baa81f43592d6bd4ac0501a0f1bf2df4dfbff4b23926fa3341a8f9c87d |
File details
Details for the file setupinit-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: setupinit-0.0.4-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.6.1 requests/2.9.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d215e3153d2ec36514170d32d40d74ee123043b10986b093e6d84cb935777052 |
|
MD5 | c3fdff5af8e5d7d1fbf191597ce2046d |
|
BLAKE2b-256 | 36e4872a0a55f54d11e1f1cb5d6654fd61a87f5d1ff31949e26d0000c7a4531f |