Skip to content

Commit f84c0bc

Browse files
create package
1 parent a95cd56 commit f84c0bc

21 files changed

+105
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.DS_Store
33
__pycache__
44
py_venv
5+
dist

README.md

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,30 @@ This library provides authentication, API, and control utilities for **FarmBot s
3030
* [Developer Info](#toolbox-developer-info)
3131
* [Formatting message broker messages](#formatting-message-broker-messages)
3232

33-
## :computer: Installation (Mac OS)
33+
## :computer: Installation
3434

35-
To set up the project locally, follow these steps:
35+
To use the sidecar starter pack, follow these steps:
3636

37-
(1) Clone the repository.
38-
```bash
39-
git clone https://github.com/FarmBot-Labs/sidecar-starter-pack
40-
```
41-
42-
(2) Navigate to the project directory.
43-
```bash
44-
cd sidecar-starter-pack
45-
```
46-
47-
(3) Create a virtual environment.
37+
(1) Create a virtual environment.
4838
```bash
4939
python -m venv py_venv
5040
```
5141

52-
(4) Activate the virtual environment.
42+
(2) Activate the virtual environment.
5343
```bash
5444
source py_venv/bin/activate
5545
```
5646

57-
(5) Install the required libraries within venv:
47+
(3) Install the farmbot-sidecar-starter-pack library within the virtual environment:
5848
```bash
59-
python -m pip install requests paho-mqtt
49+
python -m pip install farmbot-sidecar-starter-pack
6050
```
6151

6252
## :seedling: Getting Started
6353

64-
Import `main` and create an instance of the Farmbot class:
54+
Import `farmbot_sidecar_starter_pack` and create an instance of the Farmbot class:
6555
```python
66-
from main import Farmbot
56+
from farmbot_sidecar_starter_pack import Farmbot
6757
bot = Farmbot()
6858
```
6959

@@ -301,11 +291,48 @@ message = {
301291

302292
### Local development
303293

304-
If you are working on the sidecar-starter-pack itself, ensure any changes pass all tests before submitting a pull request.
294+
If you are working on the sidecar-starter-pack itself,
295+
296+
(1) Clone the repository.
297+
```bash
298+
git clone https://github.com/FarmBot-Labs/sidecar-starter-pack
299+
```
300+
301+
(2) Navigate to the project directory.
302+
```bash
303+
cd sidecar-starter-pack
304+
```
305+
306+
(3) Create a virtual environment.
307+
```bash
308+
python -m venv py_venv
309+
```
310+
311+
(4) Activate the virtual environment.
312+
```bash
313+
source py_venv/bin/activate
314+
```
315+
316+
(5) Install the required libraries within the virtual environment:
317+
```bash
318+
python -m pip install requests paho-mqtt coverage
319+
```
320+
321+
Ensure any changes pass all tests before submitting a pull request.
305322

306323
```bash
307-
python -m pip install coverage
308324
coverage run -m unittest discover
325+
coverage html
309326
```
310327

311-
Additionally, you can check for test coverage by running `coverage html` and opening `htmlcov/index.html` in a browser.
328+
You can review test coverage by opening `htmlcov/index.html` in a browser.
329+
330+
### Uploading package to PyPI (For FarmBot employees)
331+
332+
Follow [this tutorial](https://packaging.python.org/en/latest/tutorials/packaging-projects/).
333+
```bash
334+
python -m pip install --upgrade pip build twine
335+
rm dist/*
336+
python -m build
337+
python -m twine upload dist/*
338+
```

__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/copy_plants_to_new_account.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
# Note: It will not copy any associated water, height, or spread curves ids
33
# because they will not exist in the target account.
44

5-
# Add parent directory to Python path to allow `python examples/copy_plants_to_new_account.py`
6-
# `python -m examples.copy_plants_to_new_account` will work without this.
7-
import os
8-
import sys
9-
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
10-
sys.path.append(parent_dir)
11-
12-
from main import Farmbot
5+
from farmbot_sidecar_starter_pack import Farmbot
136
from time import sleep
147

158
source = Farmbot()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""
2+
Initialization for main module.
3+
"""
4+
5+
from .main import Farmbot, VERSION
6+
7+
__version__ = VERSION
File renamed without changes.
File renamed without changes.
File renamed without changes.

main.py renamed to farmbot_sidecar_starter_pack/main.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22
Farmbot class.
33
"""
44

5-
from state import State
6-
from functions.api import ApiConnect
7-
from functions.basic_commands import BasicCommands
8-
from functions.broker import BrokerConnect
9-
from functions.camera import Camera
10-
from functions.information import Information
11-
from functions.jobs import JobHandling
12-
from functions.messages import MessageHandling
13-
from functions.movements import MovementControls
14-
from functions.peripherals import Peripherals
15-
from functions.resources import Resources
16-
from functions.tools import ToolControls
5+
from .state import State
6+
from .functions.api import ApiConnect
7+
from .functions.basic_commands import BasicCommands
8+
from .functions.broker import BrokerConnect
9+
from .functions.camera import Camera
10+
from .functions.information import Information
11+
from .functions.jobs import JobHandling
12+
from .functions.messages import MessageHandling
13+
from .functions.movements import MovementControls
14+
from .functions.peripherals import Peripherals
15+
from .functions.resources import Resources
16+
from .functions.tools import ToolControls
17+
18+
VERSION = "1.1.1"
1719

1820
class Farmbot():
1921
"""Farmbot class."""
22+
__version__ = VERSION
23+
2024
def __init__(self):
2125
self.state = State()
2226

File renamed without changes.

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "farmbot_sidecar_starter_pack"
7+
dynamic = ["version"]
8+
License = "MIT"
9+
authors = [
10+
{name = "FarmBot Inc."},
11+
]
12+
keywords = ["farmbot", "sidecar"]
13+
description = "FarmBot Sidecar Starter Pack"
14+
readme = "README.md"
15+
requires-python = ">=3.8"
16+
classifiers = [
17+
"Programming Language :: Python :: 3",
18+
"License :: OSI Approved :: MIT License",
19+
"Operating System :: OS Independent",
20+
]
21+
dependencies = [
22+
"requests",
23+
"paho-mqtt",
24+
]
25+
26+
[project.urls]
27+
homepage = "https://github.com/FarmBot-Labs/sidecar-starter-pack"
28+
issues = "https://github.com/FarmBot-Labs/sidecar-starter-pack/issues"
29+
30+
[tool.hatch.version]
31+
path = "farmbot_sidecar_starter_pack/main.py"

tests/tests_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from unittest.mock import Mock, patch, call
88
import requests
99

10-
from main import Farmbot
10+
from farmbot_sidecar_starter_pack import Farmbot
1111

1212
MOCK_TOKEN = {
1313
'token': {

0 commit comments

Comments
 (0)