Skip to content

Commit 2184a96

Browse files
authored
Merge pull request #88 from claffin/python-package
Update README.md to enhance installation instructions and usage examples for CloudProxy as a Python package. Include details on prerequisites, installation methods, and environment variable setup.
2 parents 8815c89 + 90ac4ed commit 2184a96

File tree

9 files changed

+967
-2
lines changed

9 files changed

+967
-2
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish Python Package
2+
3+
# This workflow is automatically triggered when a GitHub release is created
4+
# by the main.yml workflow. This ensures that the PyPI package is published
5+
# with the same version as the Docker image and GitHub release.
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.x'
19+
- name: Set version from tag
20+
run: |
21+
# Extract version from the GitHub release tag (remove 'v' prefix if present)
22+
# This tag is created by the main.yml workflow
23+
VERSION=${GITHUB_REF#refs/tags/}
24+
VERSION=${VERSION#v}
25+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
26+
echo "Using version: $VERSION from GitHub release"
27+
- name: Update version in pyproject.toml
28+
run: |
29+
# Use sed to update the version in pyproject.toml to match the GitHub release
30+
sed -i "s/version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
31+
cat pyproject.toml | grep version
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install build twine
36+
- name: Build and publish
37+
env:
38+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
39+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
40+
run: |
41+
python -m build
42+
twine check dist/*
43+
twine upload dist/*

MANIFEST.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include LICENSE
2+
include README.md
3+
include cloudproxy/providers/user_data.sh
4+
recursive-exclude cloudproxy-ui *
5+
recursive-exclude tests *
6+
recursive-exclude docs *
7+
recursive-exclude .github *
8+
recursive-exclude venv *
9+
recursive-exclude __pycache__ *
10+
recursive-exclude .pytest_cache *

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,51 @@ To get a local copy up and running follow these simple steps.
8080

8181
### Prerequisites
8282

83-
All you need is:
84-
* Docker
83+
You can use CloudProxy in two ways:
84+
85+
1. **Docker (recommended for running the service)**
86+
* Docker installed on your system
87+
88+
2. **Python Package (for development or integration)**
89+
* Python 3.9 or higher
8590

8691
### Installation
8792

93+
#### As a Python Package
94+
95+
CloudProxy is available as a Python package that you can install directly from PyPI:
96+
97+
```bash
98+
pip install cloudproxy
99+
```
100+
101+
Or install from source:
102+
103+
```bash
104+
# Clone the repository
105+
git clone https://github.com/claffin/cloudproxy.git
106+
cd cloudproxy
107+
108+
# Install in development mode
109+
pip install -e .
110+
111+
# Or build and install
112+
pip install build
113+
python -m build
114+
pip install dist/cloudproxy-0.1.0-py3-none-any.whl
115+
```
116+
117+
Once installed, you can import and use CloudProxy in your Python applications:
118+
119+
```python
120+
from cloudproxy.providers import manager
121+
import cloudproxy.main as cloudproxy
122+
123+
# Setup your environment variables first
124+
# Start the CloudProxy service
125+
cloudproxy.start()
126+
```
127+
88128
#### Environment variables:
89129

90130
Basic authentication is used for proxy access. Configure via environment variables:
@@ -157,6 +197,8 @@ proxies = {
157197
my_request = requests.get("https://api.ipify.org", proxies=proxies)
158198
```
159199

200+
For more detailed examples of using CloudProxy as a Python package, see the [Python Package Usage Guide](docs/python-package-usage.md).
201+
160202
## Multi-Account Provider Support
161203

162204
CloudProxy now supports multiple accounts per provider, allowing you to:

cloudproxy/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python
2+
from cloudproxy.main import start
3+
4+
if __name__ == "__main__":
5+
start()

0 commit comments

Comments
 (0)