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!
Instructions for Contributing to PetPy
-
Install Python:
- Make sure you have Python version 3.8 or higher on your computer. If not, you can download it from python.org.
-
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
- First, clone the repository to your local machine:
-
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
- On Windows:
- 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:
-
Install Dependencies:
- Install the required dependencies by running the following command:
pip install -r requirements.txt
- Install the required dependencies by running the following command:
-
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.
- First, make sure pyproject.toml is in the root directory of your project file. Install the build package by running the following command:
-
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/
-
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
- Create a New Branch for each feature or bug fix:
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
- On Windows:
- 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
-
Installation:
- Install the package using pip:
pip install petpy
- Once installed, you can import and use it in your project.
- Install the package using pip:
-
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
- 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.
- Defines a virtual pet with attributes like name, type, emoji, level, experience, health, and mood.
- 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}!")
- Example:
- 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)
- Example:
- get_pet_mood(pet): Returns the pet's mood level with a description.
- Example:
print(get_pet_mood(my_pet))
- Example:
- get_pet_health(pet): Returns the pet's current health level.
- Example:
print(get_pet_health(my_pet))
- Example:
- train_pet(pet_name, skill_name): Trains the pet, boosting experience but reducing mood based on training intensity.
- Example:
train_pet(my_pet)
- Example:
- get_pet_level(pet): Returns the pet's current level and experience.
- Example:
print(get_pet_level(my_pet))
- Example:
- 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.
- Example:
- fight(pet): Engages the pet in a fight with a random outcome based on mood.
- Example:
fight(my_pet)
- Example:
- 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 :("
- Example:
- create_pet(pet_name, pet_type): Creates a new pet and adds it to the global pets dictionary.
- Example Program:
- Here is a sample program demonstrating how to create a pet, interact with it, and display its stats:
- To import the package, use the following code:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e916559998bdf82134629cdc3b5bd88f6b335fb331b401423fc923454b1160d
|
|
| MD5 |
2c5f26c76aaaf005f3cc3424d1e5e2ad
|
|
| BLAKE2b-256 |
cfde03b9bc6853967aedea062c9ecf4528b8eb8a17be3dca7825b55d427aee7b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1db46cb8f2ee43a9b16e7133a9e1601d283e370f8f987a1ae4c17fd1dd9536c
|
|
| MD5 |
d8a5a1eb0952a3e7a9951782d17262dd
|
|
| BLAKE2b-256 |
a53a37aac4e2b29743bfe54d60dab5819d83d21f5f1da39582b37f2135e2b80c
|