Logo

dev-resources.site

for different kinds of informations.

Python Project Creation on Mac OS X

Published at
10/16/2024
Categories
python
automation
mac
osx
Author
hasii2011
Categories
4 categories in total
python
open
automation
open
mac
open
osx
open
Author
9 person written this
hasii2011
open
Python Project Creation on Mac OS X

Introduction

PyFabricate is a Mac OS X application that simplifies the creation of Python projects. Since I authored it, obviously it is an opinionated version of what I think a Python project should look like. Additionally, I have a certain toolset that I use to enable me to write Python Mac OS X applications. However, I tried to create a bit of customization by exposing the templates from which I create project files. More on this later.

Overview

PyFabricate uses a wizard-like interface to query for the project details.

Opinionated Assumptions

  • The developer uses HomeBrew to install the opinionated dependencies.

    • Python is managed via pyenv (For use in the created virtual environments)
    • direnv is installed (optional)
  • The project name is the same as the module package name

Installation

Get the current release from here.

Copy this file to your Mac OS applications folder. The application is Apple code signed so you will get a simple message you have to acknowledge the first time you execute it.

Project Skeleton Details

The following is a sample of the initial skeleton that PyFabricator creates. It does now show the virtual environment that it creates. More on this later.

Sample PyFabricate Project

Essentially, PyFabricate creates the src and tests directories. In the project root directory it creates the following files:

  • .envrc
  • .gitignore
  • .mypi.ini
  • .python_version
  • .LICENSE
  • README.md
  • pyproject.toml
  • requirements.txt

Additionally, PyFabricate creates all the python package files (__init__.py) in all the appropriate places. And finally, it places two sets of logging configurations files, one for your application and one for your unit tests.

At the end of the fabrication, PyFabricate creates a Python virtual environment. Because of technical limitations PyFabricate cannot use a pyenv version of Python to create the virtual environment. Thus, it depends on a homebrew installed version.

Wizard UI

The wizard UI is a 4 step process where PyFabricate gathers sufficient project details that it uses to populate the skeleton templates. The templates use the following self-explanatory substitution tokens.

Token Name Description
PROJECT_NAME Used to construct the base project directory and is the Python module name
DESCRIPTION Placed as the description in the generated pyproject.toml
OWNER_NAME Placed as the author name and maintainer name in the generated pyproject.toml
OWNER_EMAIL Placed as the email address for botht the author and the maintainer in the generated pyproject.toml
KEYWORDS Used as the project keywords in the generated pyproject.toml
PYTHON_VERSION Used in the generated .gitignore file to exclude the directory that contains the virtual environment. Additionally appended as the directory name for the generated virtual environment. For example, 'pyenv-3.12.0'

The following is an annotated graphic of the pyroject.toml template.

Substitution Tokens

Wizard UI Step 1 - Introduction

This step is an introduction to PyFabricate. After this step, PyFabricate does a best effort to ensure that its execution dependencies are met. If not, the developer cannot proceed past this step.

Wizard Step 1

Wizard UI Step 2 - Project Details

At this step PyFabricate collects project specific information. Most of this serves to populate the pyproject.toml template.

Wizard Step 2

Wizard UI Step 3 - Base Directory

PyFabricate assumes that the developer keeps all of his Python projects in a single subdirectory. This is an opinionated view and is simply an organizational preference.

Wizard Step 3

Wizard UI Step 4 - Python Version

PyFabricate queries pyenv for the developer installed Python versions. These are the only ones from which PyFabricate can create Python virtual environments.

Wizard Step 4

Action Log

At the end of the wizard, PyFabricate presents a log as it creates the project. The following is an example log.

Console Log

Customization

As mentioned earlier the developer can customize some aspects of the project generation. PyFabricate stores the templates it uses in $HOME/.config/pyfabricate/templates as noted below.

Template Location
For example, a developer may want to use a difference license. Simply, replace the LICENSE.template file

Wrap Up

PyFabricate is currently only at version 0.5.0. I am currently investigating adding additional features and removing limitations.

mac Article's
30 articles in total
Favicon
Scan Your Linux Disk and Visualize It on Mac with GrandPerspective
Favicon
Build a Mac Tool to Fix Grammar Using TypeScript, OpenAI API, and Automator
Favicon
install guile to mac
Favicon
Why is CPU usage more than 100% in Mac activity monitor?
Favicon
How to create Mac GUI applications in SPVM?
Favicon
Mac Mini M4 Storage Upgrade: NAS vs SSD upgrade – Complete Solution
Favicon
Unlock 1 Billion NYC Taxi Rides: A Step-by-Step Guide
Favicon
Cómo usar aplicaciones de Windows en Mac
Favicon
Run lunarvim in a devcontainer
Favicon
Making Your Docker Network Reachable In MacOS
Favicon
How I cleaned my MacBookPro 2015 and released 50Gb of disk space
Favicon
Sharing My Experience (Mac Users): Time to Get Rid of the Mouse with Homerow and Aerospace
Favicon
Python Project Creation on Mac OS X
Favicon
How To Solve The Problem of the Vanishing PDF Form Data
Favicon
Obsidian - How to create Daily note every day, even if I don't open it
Favicon
🍏 If I Got a New Mac, Here's What I'd Install First as a DevOps Engineer 🧑‍💻
Favicon
Run Flux.1 on M3 Mac with Diffusers
Favicon
Top Project Management Software for Mac Users: What to Choose
Favicon
Unlock Your Mac’s Full Potential: 8 Game-Changing Apps to Supercharge Your Productivity
Favicon
How I build simple Mac apps using Go
Favicon
Vagrant and VMWare Fusion in Mac M1
Favicon
Обнаружение потери пакетов
Favicon
TIL you can create keyboard shortcuts to switch between a specific desktop
Favicon
Solving frequent MacBook problems
Favicon
zsh: command not found ui5 tooling.
Favicon
Best OLM To PST Converter Software - 2024
Favicon
How To Import Mail from Mac Outlook to Windows Outlook? – Solved
Favicon
How to setup Mac for development in 2024. (Ruby on Rails and NodeJS)
Favicon
Docker Build with Mac
Favicon
How to Add VSCode path to Mac path permanently

Featured ones: