Skip to content

Commit 07baa1d

Browse files
Add build and instructions
1 parent 58caf3f commit 07baa1d

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[build-system]
2+
requires = ["hatchling >= 1.26", "hatch-requirements-txt"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "seclab-taskflow-agent"
7+
version = "0.0.1"
8+
dynamic = ["dependencies"]
9+
authors = [
10+
{ name="Example Author", email="[email protected]" },
11+
]
12+
description = "A small example package"
13+
readme = "seclab_taskflow_agent/README.md"
14+
requires-python = ">=3.9"
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"Operating System :: OS Independent",
18+
]
19+
license = "MIT"
20+
license-files = ["seclab_taskflow_agent/LICEN[CS]E*"]
21+
22+
[tool.hatch.metadata.hooks.requirements_txt]
23+
files = ["seclab_taskflow_agent/requirements.txt"]
24+
25+
[tool.hatch.build.targets.wheel]
26+
packages = ["seclab_taskflow_agent"]
27+
28+
[project.urls]
29+
Homepage = "https://github.com/GitHubSecurityLab/seclab-taskflow-agent"
30+
Issues = "https://github.com/GitHubSecurityLab/seclab-taskflow-agent/issues"

release_tools/HOWTO.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,68 @@ server_params:
3333
command: docker
3434
args: ["run", "--entrypoint", "python" "-i", "--rm", "ghcr.io/githubsecuritylab/seclab-taskflow-agent", "toolboxes/mcp_servers/echo/echo.py"]
3535
```
36+
37+
# How to test and release new PyPI package
38+
39+
See [the packaging tutorial](https://packaging.python.org/en/latest/tutorials/packaging-projects/#namespace-packages).
40+
41+
We need all the code to be in a separate directory to build it into a package, so we create a new dir and copy what is need for the build.
42+
43+
For pacakges, only underscores are a allowed as legal python idnetifiers and not dashes, so we need to rename the folder.
44+
```bash
45+
mkdir taskflow-package
46+
cd taskflow-package
47+
git clone https://github.com/GitHubSecurityLab/seclab-taskflow-agent.git
48+
mv seclab-taskflow-agent seclab_taskflow_agent
49+
```
50+
51+
Build instructions are in pyproject.toml, and we also need .gitignore to ignore the `venv`.
52+
```bash
53+
cp seclab_taskflow_agent/pyproject.toml pyproject.toml
54+
cp seclab_taskflow_agent/.gitignore .gitignore
55+
56+
# Create a new python virtual env, activate it, and install the tools for the build.
57+
python -m venv venv
58+
source venv/bin/activate
59+
60+
pip install --upgrade build
61+
pip install hatch-requirements-txt
62+
63+
python -m build
64+
pip install --upgrade twine
65+
66+
```
67+
68+
This will create a `dist` directory with a tar.gz source distribution and whl built distribution.
69+
70+
You can test if the package works without uploading it to PyPI by installing it with the whl. Use ` --force-reinstall` if you made a new version of the package. We use `pydantic_core` in the deps, which doesn't seem to work on some versions of macos due to Rust bindings.
71+
```bash
72+
pip install dist/seclab_taskflow_agent-0.0.1-py3-none-any.whl
73+
```
74+
75+
Create an .env file with `COPILOT_TOKEN`, and run the package with:
76+
```bash
77+
python -m seclab_taskflow_agent -p assistant 'how do modems work'
78+
```
79+
80+
To upload it to TestPyPI (you'll need [an account on testpypi and an API token](https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives)). Note if you then try to download the package from TestPyPI and run it, it won't work, because TestPyPi does not have the dependencies that are required for seclab-taskflow-agent. New packages on TestPyPI are regularly cleared. Test it instead using the wheel, or by using PyPI.
81+
```bash
82+
python -m twine upload --repository testpypi dist/*
83+
```
84+
85+
To upload it on PyPI (you'll need [an account on PyPI and an API token](https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives)). Note you need to update pyproject.toml to a new (higher) version.
86+
```bash
87+
python -m twine upload dist/*
88+
```
89+
90+
Create a fresh venv, and download the package:
91+
```bash
92+
python -m venv .venv
93+
source .venv/bin/activate
94+
pip install seclab-taskflow-agent
95+
```
96+
97+
Create an .env file with `COPILOT_TOKEN`, and run the package with:
98+
```bash
99+
python -m seclab_taskflow_agent -p assistant 'how do modems work'
100+
```

0 commit comments

Comments
 (0)