Installation
This guide covers different ways to install and set up Purepy.
Requirements
- Python 3.8 or higher
- pip (Python package installer)
Installation Methods
1. Install from PyPI (Recommended)
The easiest way to install Purepy is using pip:
pip install yonlj-purepy2. Install from Source
If you want the latest development version:
git clone https://github.com/YonLJ/purepy.git
cd purepy
pip install -e .3. Install in Virtual Environment (Recommended)
It's recommended to use a virtual environment:
# Create virtual environment
python -m venv purepy-env
# Activate virtual environment
# On Windows:
purepy-env\Scripts\activate
# On macOS/Linux:
source purepy-env/bin/activate
# Install Purepy
pip install yonlj-purepyVerify Installation
After installation, verify that Purepy is working correctly:
# test_purepy.py
from pure.html import div, h1, p
def test_installation():
element = div(
h1('Purepy Installation Test'),
p('If you can see this, Purepy is working correctly!')
).class_name('test-container')
print("HTML Output:")
element.to_print()
# Save to file
element.to_save('test.html')
print("\nHTML file saved as 'test.html'")
if __name__ == "__main__":
test_installation()Run the test:
python test_purepy.pyExpected output:
<div class="test-container">
<h1>Purepy Installation Test</h1>
<p>If you can see this, Purepy is working correctly!</p>
</div>Development Setup
If you plan to contribute to Purepy or need the development version:
1. Clone the Repository
git clone https://github.com/YonLJ/purepy.git
cd purepy2. Create Development Environment
python -m venv dev-env
source dev-env/bin/activate # On Windows: dev-env\Scripts\activate3. Install in Development Mode
pip install -e .4. Install Development Dependencies
pip install -r requirements-dev.txt # If available5. Run Tests
python -m pytest tests/ # If tests are availableIDE Setup
Visual Studio Code
For the best development experience with VS Code:
- Install the Python extension
- Set up your virtual environment
- Configure Python interpreter
Create .vscode/settings.json:
{
"python.defaultInterpreterPath": "./purepy-env/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black"
}PyCharm
- Open your project in PyCharm
- Go to File → Settings → Project → Python Interpreter
- Add your virtual environment interpreter
- Enable code completion and type hints
Project Structure
When starting a new Purepy project, consider this structure:
my-purepy-project/
├── src/
│ ├── components/
│ │ ├── __init__.py
│ │ ├── header.py
│ │ ├── footer.py
│ │ └── card.py
│ ├── pages/
│ │ ├── __init__.py
│ │ ├── home.py
│ │ └── about.py
│ └── utils/
│ ├── __init__.py
│ └── helpers.py
├── output/
├── static/
│ ├── css/
│ ├── js/
│ └── images/
├── requirements.txt
└── main.pyExample requirements.txt:
purepy>=1.0.0Example main.py:
from src.pages.home import create_home_page
from src.pages.about import create_about_page
def build_site():
# Generate pages
home = create_home_page()
about = create_about_page()
# Save pages
home.to_save('output/index.html')
about.to_save('output/about.html')
print("Site built successfully!")
if __name__ == "__main__":
build_site()Common Issues
Import Errors
If you get import errors:
# Wrong
from purepy.html import div # This won't work
# Correct
from pure.html import divModule Not Found
If you get "Module not found" errors:
- Ensure Purepy is installed:
pip list | grep purepy - Check your Python path:
python -c "import sys; print(sys.path)" - Verify virtual environment is activated
Permission Errors
On some systems, you might need to use pip install --user purepy or run with elevated privileges.
Updating Purepy
To update to the latest version:
pip install --upgrade purepyTo check your current version:
import pure
print(pure.__version__) # If version info is availableUninstalling
To remove Purepy:
pip uninstall purepyNext Steps
Now that Purepy is installed:
- Getting Started - Create your first Purepy application
- Basic Usage - Learn the core concepts
- API Reference - Explore all available features
Getting Help
If you encounter issues:
- Check the documentation
- Search existing GitHub issues
- Create a new issue if needed
System Requirements
Minimum Requirements
- Python 3.8+
- 50MB disk space
- Any operating system (Windows, macOS, Linux)
Recommended Requirements
- Python 3.9+
- Virtual environment
- Code editor with Python support
- Git (for development)