Skip to main content

An example of a package developed with pyenv, built with build using setuptools, uploaded to PyPI using twine, and distributed via pip.

Project description

Python Package Exercise: PetPy

Description

This Python package, PetPy, is an exciting and interactive Python package that brings your very own virtual pets to life! Imagine caring for a unique pet, whether it’s a playful dog, a magical unicorn, or even a fierce T-Rex! With Petpy, you’re in control – create your pet, feed it fun foods, train it to level up, and watch its mood and health evolve with every action you take. Each pet has its own personality and stats, and you can experiment with a range of foods that impact mood and health in surprising ways. Dive in, unleash your creativity, and enjoy endless hours of fun with Petpy – where coding meets companionship!

To Do

  • badge
  • link to show package on PyPI

Instructions for Contributing to PetPy

  1. Install Python:

    • Make sure you have Python version 3.8 or higher on your computer. If not, you can download it from python.org.
  2. Clone the repository:

    • First, clone the repository to your local machine:
      git clone https://github.com/software-students-fall2024/3-python-package-job-offer-plz.git
      cd your-cloned-directory
      
  3. Set up a Virtual Environment:

    • It’s best to work in a virtual environment to manage dependencies and avoid conflicts. You can create a virtual environment with the following command:
      python3 -m venv .venv
      
    • Activate the Virtual Environment
      • On Windows:
        .venv\Scripts\activate
        
      • On macOS/Linux:
        source .venv/bin/activate
        
  4. Install Dependencies:

    • Install the required dependencies by running the following command:
      pip install -r requirements.txt
      
  5. Build the Package:

    • First, make sure pyproject.toml is in the root directory of your project file. Install the build package by running the following command:
      pip install build
      
    • Then, run the build command:
      python -m build
      
    • This command will generate distribution files in the dist/ directory, such as a .tar.gz source distribution and a .whl wheel file.
  6. Running the Tests:

    • Testing is essential to ensure your changes work as expected. Petpy uses pytest for testing, so make sure it’s installed (should be in requirements.txt)
    • To run all tests, use:
      pytest tests/
      
  7. Guildlines for Contributing:

    • Create a New Branch for each feature or bug fix:
      git checkout -b feature-name
      
    • Make sure to write clear and descriptive commit messages:
      git add .
      git commit -m "Description of the changes"
      
    • Push your changes to the remote repository:
      git push origin feature-name
      
    • Create a Pull Request to the main branch:
      • Go to the repository on GitHub
      • Click on the "Pull Request" button on the top right
      • Select the branch you want to merge into the main branch
      • Click on the "Create Pull Request" button

Instructions for Running PetPy

  • To run all parts of the PetPy package, follow steps 1-6 in the "Contributing to PetPy" section.
  • To run the program, follow the steps below:
    • Open a new terminal window and navigate to the root directory of the cloned repository.
    • Activate the virtual environment:
      • On Windows:
        .venv\Scripts\activate
        
      • On macOS/Linux:
        source .venv/bin/activate
        
    • Run the program:
      python petpy/src/main.py
      
    • Follow the prompts to create a new pet and explore its features!

Using PetPy in Your Project

  1. Installation:

    • Install the package using pip:
      pip install petpy
      
    • Once installed, you can import and use it in your project.
  2. Importing the Package:

    • To import the package, use the following code:
      from petpy.src import petpy
      from petpy.src.petpy import pets
      

    Class and Function Documentation

    1. Pet Class:
      • Defines a virtual pet with attributes like name, type, emoji, level, experience, health, and mood.
        • name: The name of the pet.
        • type: The type of the pet.
        • emoji: The emoji of the pet.
        • level: The level of the pet.
        • experience: The experience of the pet.
        • health: The health of the pet, max health is 20 and varies between 15-20 when pet is first created.
        • mood: The mood of the pet, max mood is 10.
    2. Functions:
      • create_pet(pet_name, pet_type): Creates a new pet and adds it to the global pets dictionary.
        • Example:
              my_pet = create_pet("Buddy", "dog")
              print(f"{my_pet.name} has been created as a {my_pet.type}!")
          
      • feed_pet(pet_name, food_name): Feeds a pet, adjusting its mood and health based on the food type. Pets may leave if their mood goes too high or too low during feeding.
        • Example:
              feed_result = feed(my_pet, "kfc")
              print(feed_result)  
          
      • get_pet_mood(pet): Returns the pet's mood level with a description.
        • Example:
              print(get_pet_mood(my_pet))
          
      • get_pet_health(pet): Returns the pet's current health level.
        • Example:
              print(get_pet_health(my_pet))
          
      • train_pet(pet_name, skill_name): Trains the pet, boosting experience but reducing mood based on training intensity.
        • Example:
              train_pet(my_pet)
          
      • get_pet_level(pet): Returns the pet's current level and experience.
        • Example:
              print(get_pet_level(my_pet))
          
      • get_pet_stats(pet, pet_name): Returns all stats of the pet if the name matches.
        • Example:
              stats_info = get_pet_stats(my_pet, "Buddy")
              print(stats_info)  # Displays comprehensive stats for Buddy.
          
      • fight(pet): Engages the pet in a fight with a random outcome based on mood.
        • Example:
              fight(my_pet)   
          
      • release(pet_name): Releases a pet from the pets dictionary, removing it permanently.
        • Example:
              release_message = release_pet("Buddy")
              print(release_message)  # Output: "Buddy has been released :("
          
    3. Example Program:
      • Here is a sample program demonstrating how to create a pet, interact with it, and display its stats:

Team Members

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

petpypi-0.1.1.tar.gz (44.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

petpypi-0.1.1-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file petpypi-0.1.1.tar.gz.

File metadata

  • Download URL: petpypi-0.1.1.tar.gz
  • Upload date:
  • Size: 44.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for petpypi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aab911645fa9dd8af69ccea0e88d8cdfa9ba89b800554bfd5e4745a17fa1555e
MD5 fb66d1b4cd15fa9c4c3dc12875587fa2
BLAKE2b-256 84948402a7fb6bdcf3e48c42dc9ddb2f84c16b4114101828e66bf7b2bf1a89f2

See more details on using hashes here.

File details

Details for the file petpypi-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: petpypi-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for petpypi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ed096e0de7d5c2e3874ef405876ea467d15085e9edba4fa0e3da74e88779024
MD5 381955e28e9334faf89dee5328a2f923
BLAKE2b-256 3ef228b8362d77362eb97e96a13e26c9711189fb90895d5ac30bda5003f614a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page