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!

CI / CD

PyPI link to PetPy

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.5.tar.gz (45.0 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.5-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: petpypi-0.1.5.tar.gz
  • Upload date:
  • Size: 45.0 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.5.tar.gz
Algorithm Hash digest
SHA256 3e916559998bdf82134629cdc3b5bd88f6b335fb331b401423fc923454b1160d
MD5 2c5f26c76aaaf005f3cc3424d1e5e2ad
BLAKE2b-256 cfde03b9bc6853967aedea062c9ecf4528b8eb8a17be3dca7825b55d427aee7b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: petpypi-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f1db46cb8f2ee43a9b16e7133a9e1601d283e370f8f987a1ae4c17fd1dd9536c
MD5 d8a5a1eb0952a3e7a9951782d17262dd
BLAKE2b-256 a53a37aac4e2b29743bfe54d60dab5819d83d21f5f1da39582b37f2135e2b80c

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