askrobots / PyStructUI
Public
Transform data structures into HTML for any Python web framework. Works with Flask, Django, FastAPI. No templates needed - just data. Switch between Bootstrap, Tailwind, Material UI with one line.
PYPI_PUBLISHING_GUIDE.md · 4.6 KB · 213 lines
Publishing PyStructUI to PyPI
Requirements for PyPI
1. PyPI Account
- Create account at https://pypi.org/account/register/
- Verify email address
- (Optional) Set up 2FA for security
2. Build Tools
pip install --upgrade pip setuptools wheel twine
3. Package Structure ✅ (Already Complete!)
- [x]
setup.pywith all metadata - [x]
README.mdfor long description - [x]
__init__.pywith version - [x] Proper package structure
- [x] License (MIT implied in setup.py)
4. Additional Files Needed
Create LICENSE file
cat > LICENSE << 'EOF'
MIT License
Copyright (c) 2024 PyStructUI Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
EOF
Create MANIFEST.in
cat > MANIFEST.in << 'EOF'
include README.md
include LICENSE
recursive-include pystructui *.py
recursive-include examples *.py
EOF
Create .gitignore
cat > .gitignore << 'EOF'
*.pyc
__pycache__/
build/
dist/
*.egg-info/
.pytest_cache/
.coverage
htmlcov/
.tox/
.env
venv/
EOF
Publishing Steps
1. Test Package Locally
# In pystructui directory
pip install -e .
# Test it works
python -c "from pystructui import render; print(render({'type': 'button', 'text': 'Test'}))"
2. Build Distribution
# Clean any previous builds
rm -rf dist/ build/ *.egg-info
# Build source distribution and wheel
python setup.py sdist bdist_wheel
# Check the distribution
ls dist/
# Should see:
# pystructui-0.1.0-py3-none-any.whl
# pystructui-0.1.0.tar.gz
3. Test with TestPyPI (Optional but Recommended)
# Upload to TestPyPI first
twine upload --repository testpypi dist/*
# Test install from TestPyPI
pip install --index-url https://test.pypi.org/simple/ pystructui
4. Upload to PyPI
# Upload to real PyPI
twine upload dist/*
# You'll be prompted for:
# Username: __token__
# Password: <your-api-token>
5. Create API Token (Recommended)
- Login to https://pypi.org
- Go to Account Settings → API tokens
- Create new API token
- Save it securely
- Use as password with username
__token__
6. Verify Installation
# Install from PyPI
pip install pystructui
# Test it
python -c "from pystructui import render; print('Success!')"
Automation with GitHub Actions
Create .github/workflows/publish.yml:
name: Publish to PyPI
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel twine
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
Version Management
Update version in:
pystructui/__init__.pysetup.py
Follow semantic versioning:
- MAJOR.MINOR.PATCH (e.g., 1.0.0)
- MAJOR: Breaking changes
- MINOR: New features
- PATCH: Bug fixes
Quick Commands to Publish
# Full publishing process
cd /Users/danq/websheet/dbbasic/pystructui
# 1. Add missing files
echo "MIT License..." > LICENSE
echo "include README.md..." > MANIFEST.in
# 2. Build
python setup.py sdist bdist_wheel
# 3. Check package
twine check dist/*
# 4. Upload to PyPI
twine upload dist/*
# 5. Done! Now anyone can:
pip install pystructui
Package Name Availability
✅ Good news! "pystructui" appears to be available on PyPI!
Once published, users worldwide can:
pip install pystructui
And immediately start building web apps without HTML templates!