Skip to main content

Setupinit

Properly initialize Python projects

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 such as setup.cfg.

No existing file will be removed or modified by Setupinit. If, for example, you accidentally corrupted the contents of setup.cfg, you can simply manually 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.is_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]
    src
        demo/  # this is the package directory ($PKG_DIR) [2]
            __init__.py
            __main__.py  # the main entry point
    tests/
        __init__.py
        __main__.py
    MANIFEST.in  # already filled with convenient lines of rules
    pyproject.toml  # the new unified Python project settings file [3]
    README.md
    setup.cfg  # you MUST edit this file [4]
    setup.py  # don't remove nor edit this file [5]
    VERSION  # unique location to define the version number [6]
    .gitignore
  • [1] This is the project directory ($PROJECT_DIR).
  • [2] Your codebase lives in the package directory ($PKG_DIR).
  • [3] Read What the heck is pyproject.toml ? and the PEP 518.
  • [4] Read this user guide to edit the setup.cfg file.
  • [5] If you want editable installs you still need a setup.py shim.
  • [6] You won't need to edit this file if you use Buildver to build Python packages.

Testing and contributing

Feel free to open an issue to report a bug, suggest some changes, show some useful code snippets, or discuss anything related to this project. You can also directly email me.

Setup your development environment

Following are instructions to setup your development environment

# create and activate a virtual environment
python -m venv venv
source venv/bin/activate

# clone the project then change into its directory
git clone https://github.com/pyrustic/setupinit.git
cd setupinit

# install the package locally (editable mode)
pip install -e .

# run tests
python -m tests

# deactivate the virtual environment
deactivate

Back to top

Installation

Setupinit is cross-platform. It is built on Ubuntu and should work on Python 3.8 or newer.

Create and activate a virtual environment

python -m venv venv
source venv/bin/activate

Install for the first time

pip install setupinit

Upgrade the package

pip install setupinit --upgrade --upgrade-strategy eager

Deactivate the virtual environment

deactivate

Back to top

About the author

Hello world, I'm Alex, a tech enthusiast ! Feel free to get in touch with me !




Back to top

Metadata

Release files for setupinit 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for setupinit 0.0.5
File Size Uploaded
setupinit-0.0.5.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for setupinit 0.0.5
File Interpreter ABI Platform
setupinit-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / setupinit-0.0.5.tar.gz

Download URL setupinit-0.0.5.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8bb945464cf7907ee25a1b01218770236bfd339511fd59842fc0c49392f1ccee
BLAKE2b-256 checksum
How to use checksums
617bd8e63e49e5c4945ab6e12593928ef19402b2f54e8792a5d9c0e4f31b48e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / setupinit-0.0.5-py3-none-any.whl

Download URL setupinit-0.0.5-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11ffc31ed2d198ec73fa728fc341e53a806a27f4c34dce0b0254a1b7ae4fa93a
BLAKE2b-256 checksum
How to use checksums
eea3928641240c4cb60dc98540b68d20db83b94c30ff8480a4ef6f498c39e68f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page