openclaw-secure 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openclaw_secure-0.1.0/.gitignore +139 -0
- openclaw_secure-0.1.0/LICENSE +21 -0
- openclaw_secure-0.1.0/PKG-INFO +313 -0
- openclaw_secure-0.1.0/PUBLISH.md +205 -0
- openclaw_secure-0.1.0/README.md +275 -0
- openclaw_secure-0.1.0/SETUP.md +175 -0
- openclaw_secure-0.1.0/pyproject.toml +82 -0
- openclaw_secure-0.1.0/src/openclaw_secure/__init__.py +10 -0
- openclaw_secure-0.1.0/src/openclaw_secure/__main__.py +8 -0
- openclaw_secure-0.1.0/src/openclaw_secure/backup.py +202 -0
- openclaw_secure-0.1.0/src/openclaw_secure/cli.py +648 -0
- openclaw_secure-0.1.0/src/openclaw_secure/controller.py +1173 -0
- openclaw_secure-0.1.0/src/openclaw_secure/detector.py +310 -0
- openclaw_secure-0.1.0/src/openclaw_secure/docker_backend.py +417 -0
- openclaw_secure-0.1.0/tests/__init__.py +1 -0
- openclaw_secure-0.1.0/tests/test_backup.py +63 -0
- openclaw_secure-0.1.0/tests/test_controller.py +35 -0
- openclaw_secure-0.1.0/tests/test_detector.py +55 -0
- openclaw_secure-0.1.0/tests/test_docker_backend.py +37 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.nox/
|
|
42
|
+
.coverage
|
|
43
|
+
.coverage.*
|
|
44
|
+
.cache
|
|
45
|
+
nosetests.xml
|
|
46
|
+
coverage.xml
|
|
47
|
+
*.cover
|
|
48
|
+
*.py,cover
|
|
49
|
+
.hypothesis/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# Translations
|
|
53
|
+
*.mo
|
|
54
|
+
*.pot
|
|
55
|
+
|
|
56
|
+
# Django stuff:
|
|
57
|
+
*.log
|
|
58
|
+
local_settings.py
|
|
59
|
+
db.sqlite3
|
|
60
|
+
db.sqlite3-journal
|
|
61
|
+
|
|
62
|
+
# Flask stuff:
|
|
63
|
+
instance/
|
|
64
|
+
.webassets-cache
|
|
65
|
+
|
|
66
|
+
# Scrapy stuff:
|
|
67
|
+
.scrapy
|
|
68
|
+
|
|
69
|
+
# Sphinx documentation
|
|
70
|
+
docs/_build/
|
|
71
|
+
|
|
72
|
+
# PyBuilder
|
|
73
|
+
target/
|
|
74
|
+
|
|
75
|
+
# Jupyter Notebook
|
|
76
|
+
.ipynb_checkpoints
|
|
77
|
+
|
|
78
|
+
# IPython
|
|
79
|
+
profile_default/
|
|
80
|
+
ipython_config.py
|
|
81
|
+
|
|
82
|
+
# pyenv
|
|
83
|
+
.python-version
|
|
84
|
+
|
|
85
|
+
# pipenv
|
|
86
|
+
Pipfile.lock
|
|
87
|
+
|
|
88
|
+
# PEP 582
|
|
89
|
+
__pypackages__/
|
|
90
|
+
|
|
91
|
+
# Celery stuff
|
|
92
|
+
celerybeat-schedule
|
|
93
|
+
celerybeat.pid
|
|
94
|
+
|
|
95
|
+
# SageMath parsed files
|
|
96
|
+
*.sage.py
|
|
97
|
+
|
|
98
|
+
# Environments
|
|
99
|
+
.env
|
|
100
|
+
.venv
|
|
101
|
+
env/
|
|
102
|
+
venv/
|
|
103
|
+
ENV/
|
|
104
|
+
env.bak/
|
|
105
|
+
venv.bak/
|
|
106
|
+
|
|
107
|
+
# Spyder project settings
|
|
108
|
+
.spyderproject
|
|
109
|
+
.spyproject
|
|
110
|
+
|
|
111
|
+
# Rope project settings
|
|
112
|
+
.ropeproject
|
|
113
|
+
|
|
114
|
+
# mkdocs documentation
|
|
115
|
+
/site
|
|
116
|
+
|
|
117
|
+
# mypy
|
|
118
|
+
.mypy_cache/
|
|
119
|
+
.dmypy.json
|
|
120
|
+
dmypy.json
|
|
121
|
+
|
|
122
|
+
# Pyre type checker
|
|
123
|
+
.pyre/
|
|
124
|
+
|
|
125
|
+
# IDE
|
|
126
|
+
.vscode/
|
|
127
|
+
.idea/
|
|
128
|
+
*.swp
|
|
129
|
+
*.swo
|
|
130
|
+
*~
|
|
131
|
+
|
|
132
|
+
# OS
|
|
133
|
+
.DS_Store
|
|
134
|
+
Thumbs.db
|
|
135
|
+
|
|
136
|
+
# Project specific
|
|
137
|
+
*.tar.gz
|
|
138
|
+
backups/
|
|
139
|
+
test_data/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 OpenClaw Secure Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, so the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openclaw-secure
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Secure mode switcher for OpenClaw - runs your existing installation in a sandboxed Docker container
|
|
5
|
+
Project-URL: Homepage, https://github.com/openclaw/openclaw-secure
|
|
6
|
+
Project-URL: Documentation, https://github.com/openclaw/openclaw-secure#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/openclaw/openclaw-secure
|
|
8
|
+
Project-URL: Issues, https://github.com/openclaw/openclaw-secure/issues
|
|
9
|
+
Author-email: Gerald Enrique Nelson Mc Kenzie <lordxmen2k@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agent,ai,docker,isolation,openclaw,sandbox,security
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Security
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Topic :: System :: Systems Administration
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Requires-Dist: click>=8.0.0
|
|
28
|
+
Requires-Dist: psutil>=5.9.0
|
|
29
|
+
Requires-Dist: pyyaml>=6.0
|
|
30
|
+
Requires-Dist: rich>=13.0.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# OpenClaw Secure
|
|
40
|
+
|
|
41
|
+
[](https://pypi.org/project/openclaw-secure/)
|
|
42
|
+
[](https://www.python.org/downloads/)
|
|
43
|
+
[](https://opensource.org/licenses/MIT)
|
|
44
|
+
[](https://www.docker.com/products/docker-desktop/)
|
|
45
|
+
|
|
46
|
+
Run OpenClaw in a secure, sandboxed Docker container with automatic device pairing and dashboard access.
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
### 1. Install Prerequisites
|
|
51
|
+
|
|
52
|
+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (Windows/Mac) or Docker Engine (Linux)
|
|
53
|
+
- [Python 3.10+](https://www.python.org/downloads/)
|
|
54
|
+
- pip or pipx
|
|
55
|
+
|
|
56
|
+
### 2. Install openclaw-secure
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Using pipx (recommended - isolated environment)
|
|
60
|
+
pipx install openclaw-secure
|
|
61
|
+
|
|
62
|
+
# Using pip
|
|
63
|
+
pip install openclaw-secure
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Enable Secure Mode
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Interactive mode (will ask for config path, port, etc.)
|
|
70
|
+
openclaw-secure enable
|
|
71
|
+
|
|
72
|
+
# Non-interactive mode (uses defaults)
|
|
73
|
+
openclaw-secure enable --yes
|
|
74
|
+
|
|
75
|
+
# With custom config location
|
|
76
|
+
openclaw-secure enable --config "G:\\MyProjects\\openclaw\\config"
|
|
77
|
+
|
|
78
|
+
# With custom port
|
|
79
|
+
openclaw-secure enable --port 8080
|
|
80
|
+
|
|
81
|
+
# Maximum security sandbox
|
|
82
|
+
openclaw-secure enable --sandbox maximum --yes
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### What Happens
|
|
86
|
+
|
|
87
|
+
1. **Detects** your OpenClaw config (or lets you specify location)
|
|
88
|
+
2. **Preserves** all settings, API keys, and models
|
|
89
|
+
3. **Configures** sandbox mode and gateway binding
|
|
90
|
+
4. **Starts** container with port mapping
|
|
91
|
+
5. **Auto-approves** any pending devices
|
|
92
|
+
6. **Opens** browser with authenticated URL
|
|
93
|
+
|
|
94
|
+
### Dashboard Access
|
|
95
|
+
|
|
96
|
+
After enabling, the dashboard URL with token is displayed:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
Click to open: http://127.0.0.1:18789/#token=...
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or get it later:
|
|
103
|
+
```bash
|
|
104
|
+
openclaw-secure dashboard --no-open
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Fresh Install Setup (No Existing OpenClaw)
|
|
108
|
+
|
|
109
|
+
If you don't have OpenClaw installed, `openclaw-secure` can create a fresh config.
|
|
110
|
+
|
|
111
|
+
#### Step 1: Enable Secure Mode
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
openclaw-secure enable --yes
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
When no config is detected, it will create a fresh one automatically (or ask you in interactive mode).
|
|
118
|
+
|
|
119
|
+
#### Step 2: Run Onboard Wizard
|
|
120
|
+
|
|
121
|
+
After the container starts, set up your API keys:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Interactive setup (recommended for first time)
|
|
125
|
+
docker exec -it openclaw-secure openclaw onboard
|
|
126
|
+
|
|
127
|
+
# Or use exec command
|
|
128
|
+
openclaw-secure exec onboard
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
This wizard will guide you through:
|
|
132
|
+
- Adding your AI provider API keys (Anthropic, OpenAI, etc.)
|
|
133
|
+
- Setting your default model
|
|
134
|
+
- Configuring workspace preferences
|
|
135
|
+
|
|
136
|
+
#### Step 3: Verify Setup
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Check version
|
|
140
|
+
openclaw-secure exec --version
|
|
141
|
+
|
|
142
|
+
# List agents
|
|
143
|
+
openclaw-secure exec agents list
|
|
144
|
+
|
|
145
|
+
# Open dashboard to configure API keys via web UI
|
|
146
|
+
openclaw-secure dashboard
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Or use Docker directly for interactive setup:
|
|
150
|
+
```bash
|
|
151
|
+
docker exec -it openclaw-secure openclaw onboard
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Running OpenClaw CLI Commands
|
|
155
|
+
|
|
156
|
+
Execute any OpenClaw command inside the secure container:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# List agents
|
|
160
|
+
openclaw-secure exec agents list
|
|
161
|
+
|
|
162
|
+
# Add an agent
|
|
163
|
+
openclaw-secure exec agents add my-agent
|
|
164
|
+
|
|
165
|
+
# Check OpenClaw version
|
|
166
|
+
openclaw-secure exec --version
|
|
167
|
+
|
|
168
|
+
# Run onboard wizard (interactive - use docker directly)
|
|
169
|
+
docker exec -it openclaw-secure openclaw onboard
|
|
170
|
+
|
|
171
|
+
# Run any command
|
|
172
|
+
docker exec openclaw-secure openclaw <command>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Common CLI Commands
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Check version
|
|
179
|
+
openclaw-secure exec --version
|
|
180
|
+
|
|
181
|
+
# List agents
|
|
182
|
+
openclaw-secure exec agents list
|
|
183
|
+
|
|
184
|
+
# Create new agent
|
|
185
|
+
openclaw-secure exec agents add my-agent
|
|
186
|
+
|
|
187
|
+
# Run onboard wizard (interactive)
|
|
188
|
+
docker exec -it openclaw-secure openclaw onboard
|
|
189
|
+
|
|
190
|
+
# Check container logs
|
|
191
|
+
docker logs openclaw-secure --tail 50
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Device Management
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# List devices
|
|
198
|
+
openclaw-secure devices --list
|
|
199
|
+
|
|
200
|
+
# Approve a pending device
|
|
201
|
+
openclaw-secure devices --approve <device_id>
|
|
202
|
+
|
|
203
|
+
# List with docker directly
|
|
204
|
+
docker exec openclaw-secure openclaw devices list
|
|
205
|
+
|
|
206
|
+
# Approve with docker directly
|
|
207
|
+
docker exec openclaw-secure openclaw devices approve <device_id>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Disable Secure Mode
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
openclaw-secure disable
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
This stops the container and restores your previous OpenClaw setup.
|
|
217
|
+
|
|
218
|
+
## Commands
|
|
219
|
+
|
|
220
|
+
| Command | Description |
|
|
221
|
+
|---------|-------------|
|
|
222
|
+
| `enable` | Start secure container mode |
|
|
223
|
+
| `disable` | Return to normal mode |
|
|
224
|
+
| `status` | Check current mode |
|
|
225
|
+
| `dashboard` | Open dashboard in browser |
|
|
226
|
+
| `devices` | Manage device pairing |
|
|
227
|
+
| `exec` | Run OpenClaw CLI commands inside container |
|
|
228
|
+
| `doctor` | Run diagnostics |
|
|
229
|
+
| `emergency-restore` | Force recovery |
|
|
230
|
+
|
|
231
|
+
## Options
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
openclaw-secure enable [OPTIONS]
|
|
235
|
+
|
|
236
|
+
Options:
|
|
237
|
+
--config PATH Custom config directory
|
|
238
|
+
--port INTEGER Custom port (default: 18789)
|
|
239
|
+
--sandbox [chat-only|maximum|none] Sandbox mode
|
|
240
|
+
--network [none|bridge] Network mode
|
|
241
|
+
--disable-device-auth Skip device pairing (not recommended)
|
|
242
|
+
--yes / -y Non-interactive mode
|
|
243
|
+
--no-backup Skip backup creation
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Prerequisites
|
|
247
|
+
|
|
248
|
+
Before installing `openclaw-secure`, ensure you have the following installed:
|
|
249
|
+
|
|
250
|
+
### Required
|
|
251
|
+
|
|
252
|
+
| Software | Version | Purpose | Download |
|
|
253
|
+
|----------|---------|---------|----------|
|
|
254
|
+
| **Docker Desktop** | Latest | Container runtime | [docker.com](https://www.docker.com/products/docker-desktop/) |
|
|
255
|
+
| **Python** | 3.10+ | Runtime for openclaw-secure | [python.org](https://www.python.org/downloads/) |
|
|
256
|
+
| **pip** or **pipx** | Latest | Package installer | Included with Python |
|
|
257
|
+
|
|
258
|
+
### Optional (for fresh OpenClaw installs)
|
|
259
|
+
|
|
260
|
+
| Software | Purpose |
|
|
261
|
+
|----------|---------|
|
|
262
|
+
| **OpenClaw CLI** | Only needed if you want to run `openclaw` commands locally outside the container |
|
|
263
|
+
|
|
264
|
+
### Platform-Specific Notes
|
|
265
|
+
|
|
266
|
+
**Windows:**
|
|
267
|
+
- Docker Desktop with WSL2 backend recommended
|
|
268
|
+
- Run PowerShell or Command Prompt as Administrator if you encounter permission issues
|
|
269
|
+
|
|
270
|
+
**macOS:**
|
|
271
|
+
- Docker Desktop for Mac (Apple Silicon or Intel)
|
|
272
|
+
- May need to allow Docker in System Preferences > Security & Privacy
|
|
273
|
+
|
|
274
|
+
**Linux:**
|
|
275
|
+
- Docker Engine (Docker Desktop not required)
|
|
276
|
+
- Add your user to the `docker` group: `sudo usermod -aG docker $USER`
|
|
277
|
+
- Log out and back in for group changes to take effect
|
|
278
|
+
|
|
279
|
+
### Verify Installation
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
# Check Docker
|
|
283
|
+
docker --version
|
|
284
|
+
docker ps
|
|
285
|
+
|
|
286
|
+
# Check Python
|
|
287
|
+
python --version
|
|
288
|
+
|
|
289
|
+
# Check pip
|
|
290
|
+
pip --version
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## How It Works
|
|
294
|
+
|
|
295
|
+
1. **Container**: Runs official `ghcr.io/openclaw/openclaw:latest` image
|
|
296
|
+
2. **Port Mapping**: Exposes port 18789 to localhost
|
|
297
|
+
3. **Volume Mounts**:
|
|
298
|
+
- Config directory (read-write for API key updates)
|
|
299
|
+
- Workspace directory
|
|
300
|
+
- Cache directory
|
|
301
|
+
4. **Gateway Binding**: Configures `0.0.0.0` binding for Docker compatibility
|
|
302
|
+
5. **Auto-pairing**: Automatically approves devices on startup
|
|
303
|
+
|
|
304
|
+
## Security Notes
|
|
305
|
+
|
|
306
|
+
- Config files remain editable on your host
|
|
307
|
+
- Device auth is enabled by default (disable with `--disable-device-auth`)
|
|
308
|
+
- Sandbox modes protect your system from AI-generated code
|
|
309
|
+
- Network is isolated (bridge mode) by default
|
|
310
|
+
|
|
311
|
+
## License
|
|
312
|
+
|
|
313
|
+
MIT
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Publishing to PyPI
|
|
2
|
+
|
|
3
|
+
This guide shows how to publish `openclaw-secure` to PyPI.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- PyPI account: https://pypi.org/account/register/
|
|
8
|
+
- API token from PyPI (recommended over password)
|
|
9
|
+
- Project configured in `pyproject.toml`
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### 1. Install Build Tools
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install build twine
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 2. Configure PyPI Credentials
|
|
20
|
+
|
|
21
|
+
**Option A: Using .pypirc file**
|
|
22
|
+
|
|
23
|
+
Create `~/.pypirc` (Linux/Mac) or `%USERPROFILE%\.pypirc` (Windows):
|
|
24
|
+
|
|
25
|
+
```ini
|
|
26
|
+
[pypi]
|
|
27
|
+
username = __token__
|
|
28
|
+
password = pypi-your-api-token-here
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Option B: Using environment variable**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
export PYPI_API_TOKEN="pypi-your-api-token-here"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Build and Publish
|
|
38
|
+
|
|
39
|
+
### Step 1: Update Version
|
|
40
|
+
|
|
41
|
+
Edit `pyproject.toml` and bump the version:
|
|
42
|
+
|
|
43
|
+
```toml
|
|
44
|
+
[project]
|
|
45
|
+
version = "0.1.1" # Increment this
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Step 2: Clean Old Builds
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Remove old build artifacts
|
|
52
|
+
rm -rf dist/ build/ *.egg-info # Linux/Mac
|
|
53
|
+
del /s /q dist\ build\ *.egg-info # Windows
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Step 3: Build Package
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
python -m build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This creates:
|
|
63
|
+
- `dist/openclaw_secure-0.1.1.tar.gz` (source distribution)
|
|
64
|
+
- `dist/openclaw_secure-0.1.1-py3-none-any.whl` (wheel)
|
|
65
|
+
|
|
66
|
+
### Step 4: Verify Build
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
twine check dist/*
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Should output:
|
|
73
|
+
```
|
|
74
|
+
Checking dist/openclaw_secure-0.1.1-py3-none-any.whl: PASSED
|
|
75
|
+
Checking dist/openclaw_secure-0.1.1.tar.gz: PASSED
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Step 5: Test on TestPyPI (Optional but Recommended)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
twine upload --repository testpypi dist/*
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Test installation:
|
|
85
|
+
```bash
|
|
86
|
+
pip install --index-url https://test.pypi.org/simple/ openclaw-secure
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Step 6: Publish to PyPI
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
twine upload dist/*
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Or with explicit credentials:
|
|
96
|
+
```bash
|
|
97
|
+
twine upload -u __token__ -p $PYPI_API_TOKEN dist/*
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Verify Installation
|
|
101
|
+
|
|
102
|
+
After publishing, test the public package:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Create fresh environment
|
|
106
|
+
python -m venv test_env
|
|
107
|
+
source test_env/bin/activate # or test_env\Scripts\activate on Windows
|
|
108
|
+
|
|
109
|
+
# Install from PyPI
|
|
110
|
+
pip install openclaw-secure
|
|
111
|
+
|
|
112
|
+
# Test
|
|
113
|
+
openclaw-secure --version
|
|
114
|
+
openclaw-secure --help
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Publishing with pipx (for users)
|
|
118
|
+
|
|
119
|
+
Once published, users can install with:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Install with pipx (recommended)
|
|
123
|
+
pipx install openclaw-secure
|
|
124
|
+
|
|
125
|
+
# Upgrade
|
|
126
|
+
pipx upgrade openclaw-secure
|
|
127
|
+
|
|
128
|
+
# Uninstall
|
|
129
|
+
pipx uninstall openclaw-secure
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## GitHub Actions (Automated Publishing)
|
|
133
|
+
|
|
134
|
+
Create `.github/workflows/publish.yml`:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
name: Publish to PyPI
|
|
138
|
+
|
|
139
|
+
on:
|
|
140
|
+
release:
|
|
141
|
+
types: [published]
|
|
142
|
+
|
|
143
|
+
jobs:
|
|
144
|
+
deploy:
|
|
145
|
+
runs-on: ubuntu-latest
|
|
146
|
+
steps:
|
|
147
|
+
- uses: actions/checkout@v3
|
|
148
|
+
|
|
149
|
+
- name: Set up Python
|
|
150
|
+
uses: actions/setup-python@v4
|
|
151
|
+
with:
|
|
152
|
+
python-version: '3.10'
|
|
153
|
+
|
|
154
|
+
- name: Install dependencies
|
|
155
|
+
run: |
|
|
156
|
+
python -m pip install --upgrade pip
|
|
157
|
+
pip install build twine
|
|
158
|
+
|
|
159
|
+
- name: Build package
|
|
160
|
+
run: python -m build
|
|
161
|
+
|
|
162
|
+
- name: Publish to PyPI
|
|
163
|
+
env:
|
|
164
|
+
TWINE_USERNAME: __token__
|
|
165
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
166
|
+
run: twine upload dist/*
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Add `PYPI_API_TOKEN` to GitHub repository secrets.
|
|
170
|
+
|
|
171
|
+
## Versioning Guide
|
|
172
|
+
|
|
173
|
+
Follow semantic versioning (MAJOR.MINOR.PATCH):
|
|
174
|
+
|
|
175
|
+
- **MAJOR**: Breaking changes (1.0.0)
|
|
176
|
+
- **MINOR**: New features, backwards compatible (0.2.0)
|
|
177
|
+
- **PATCH**: Bug fixes (0.1.1)
|
|
178
|
+
|
|
179
|
+
## Troubleshooting
|
|
180
|
+
|
|
181
|
+
### "File already exists"
|
|
182
|
+
Version wasn't bumped. Update version in `pyproject.toml`.
|
|
183
|
+
|
|
184
|
+
### "Invalid API Token"
|
|
185
|
+
- Make sure you're using `__token__` as username
|
|
186
|
+
- Token must have "Upload" scope
|
|
187
|
+
|
|
188
|
+
### "Metadata validation failed"
|
|
189
|
+
Run `twine check dist/*` and fix any issues.
|
|
190
|
+
|
|
191
|
+
### Package not found after upload
|
|
192
|
+
Wait 5-10 minutes for PyPI CDN to propagate.
|
|
193
|
+
|
|
194
|
+
## Release Checklist
|
|
195
|
+
|
|
196
|
+
- [ ] Version bumped in `pyproject.toml`
|
|
197
|
+
- [ ] `CHANGELOG.md` updated (if you have one)
|
|
198
|
+
- [ ] README.md is current
|
|
199
|
+
- [ ] Tests pass
|
|
200
|
+
- [ ] Build succeeds (`python -m build`)
|
|
201
|
+
- [ ] Package passes check (`twine check dist/*`)
|
|
202
|
+
- [ ] Published to PyPI (`twine upload dist/*`)
|
|
203
|
+
- [ ] Installation tested (`pip install openclaw-secure`)
|
|
204
|
+
- [ ] Git tag created (`git tag v0.1.1`)
|
|
205
|
+
- [ ] Git tag pushed (`git push origin v0.1.1`)
|