Skip to content

kerasty2024/learning_tools

Repository files navigation

Python Version Management Project

This project provides a personal solution for managing version numbers in my Python projects. It includes scripts for updating version numbers in pyproject.toml, src/version.py, and version_info.txt. This is a private repository for my own use, but I’m open to contributions and support to keep it running smoothly.

Features

  • Version Management: Update version numbers manually by editing files, using provided scripts with a GUI dialog, or via PyCharm External Tools.

Project Structure

python-version-template/
├── .github/
│   └── funding.yml               (Funding configuration)
├── contents/
│   ├── BTC_QR.png               (Bitcoin QR code)
│   ├── ETH_QR.png               (Ethereum QR code)
│   └── Solana_QR.jpg            (Solana QR code)
├── scripts/
│   ├── increment_version.py      (Update version with GUI)
│   ├── update_version.py         (Update version manually via command line)
├── src/
│   ├── init.py
│   ├── version.py                (Version information)
│   └── main.py                   (Sample main script)
├── .gitattributes                (Line ending normalization)
├── .gitignore
├── LICENSE
├── README.md
├── pyproject.toml                (Project metadata with version)
├── requirements.txt              (Dependencies)
└── version_info.txt              (Version information file)

Prerequisites

  • Python: 3.8 or higher (with tkinter installed; usually included by default)
  • Git: For version control

Setup Instructions

1. Clone the Repository

git clone https://github.com/kerasty2024/python-version-template.git
cd python-version-template

2. Install Dependencies

pip install -r requirements.txt

If running on Linux and the GUI dialog does not appear, install tkinter:

sudo apt install python3-tk  # For Ubuntu/Debian

3. Customize the Project

Update pyproject.toml with your project name and initial version:

[project]
name = "your-project-name"
version = "1.0.0"

Modify version_info.txt for version metadata (e.g., ProductName, CompanyName).

Add your application code to src/ (replace main.py).

Usage

Update Version Manually

You can update the version in two ways:

Option 1: Use the GUI Script

Open a terminal and navigate to the project directory:

cd /path/to/python-version-template
python scripts/increment_version.py

A dialog will appear showing the current version (e.g., Current Version: 1.0.0).

Enter the new version in the text field (e.g., 1.0.1).

Click "Update" to apply the change.

Commit the updated files:

git commit -m "Update version to 1.0.1"
git push origin main

Option 2: Edit Files Directly

Open the following files and update the version number:

pyproject.toml:

[project]
version = "1.1.0"  # Update this line

src/version.py:

__version__ = "1.1.0"  # Update this line

version_info.txt:

VSVersionInfo(
  ffi=FixedFileInfo(
    filevers=(1, 1, 0, 0),  # Update this line
    prodvers=(1, 1, 0, 0),  # Update this line
    ...
  ),
  kids=[
    StringFileInfo(
      [
        StringStruct('FileVersion', '1.1.0'),  # Update this line
        StringStruct('ProductVersion', '1.1.0'),  # Update this line
        ...
      ]
    ),
    ...
  ]
)

Commit the updated files:

git add pyproject.toml src/version.py version_info.txt
git commit -m "Update version to 1.1.0"
git push origin main

Option 3: Use the Command-Line Script

cd /path/to/python-version-template
python scripts/update_version.py 1.1.0
git add .
git commit -m "Update version to 1.1.0"
git push origin main

Option 4: Use PyCharm External Tools

If you prefer a more integrated experience in PyCharm, you can set up an External Tool to run the version update script with a single click.

Setup Instructions

  1. Open PyCharm and load the project.

  2. Go to File > Settings > Tools > External Tools.

  3. Click + to add a new tool:

    • Name: Update Version
    • Program: python
    • Arguments: $ProjectFileDir$/scripts/increment_version.py
    • Working directory: $ProjectFileDir$
  4. Save and run the tool:

    • Right-click anywhere in the project > External Tools > Update Version.
    • A dialog will appear showing the current version.
    • Enter the new version and click Update.
  5. Commit the updated files:

git add .
git commit -m "Update version to 1.1.0"
git push origin main
  1. (Optional) Assign a shortcut in Settings > Keymap > External Tools (e.g., Ctrl+Alt+V).

Troubleshooting

Version Update Issues:

  • Verify toml is installed (pip install toml) if using scripts.
  • Ensure all version numbers in pyproject.toml, src/version.py, and version_info.txt are consistent.
  • If the GUI dialog does not appear, ensure tkinter is available:
    • On Windows/macOS, it is usually included with Python.
    • On Linux, install python3-tk (e.g., sudo apt install python3-tk).

Command Not Found:

  • Ensure you are in the correct directory.
  • Use the full path to Python if needed (e.g., /path/to/python3).

QR Code Not Displaying:

  • Ensure the images in the contents/ folder are correctly committed to the repository.
  • Check file names for case sensitivity (e.g., BTC-QR.png vs btc-qr.png).

Funding

If you find this template useful, your support would mean the world to me! It helps me dedicate more time to maintaining and improving this project, ensuring it remains a valuable resource for the community. There are several ways to contribute:

Support via Sponsorship Platforms

Support with Cryptocurrency

You can also support the project by sending cryptocurrency to the addresses below. Simply copy the address or scan the QR code to make a contribution—every bit helps keep this project alive and growing!

Cryptocurrency Address QR Code
Bitcoin (BTC) bc1qn72yvftnuh7jgjnn9x848pzhhywasxmqt5c7wp BTC QR Code
Ethereum (ETH) 0x2175Ed9c75C14F113ab9cEaDc1890b2f87f40e78 ETH QR Code
Solana (SOL) 6Hc7erZqgreTVwCsTtNvsyzigN2oHJ4EgNGaLWtRWJ69 Solana QR Code

How to Contribute with Crypto

  1. Copy the address for your preferred cryptocurrency, or scan the QR code using your wallet app.
  2. Send any amount you’d like to contribute.
  3. Your support will help fund server costs, development time, and future enhancements—thank you! Thank you for considering a contribution! Your generosity helps ensure this project can continue to grow and serve the developer community.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published