Skip to content

Commit 650466a

Browse files
committed
prepared repo with package for meta-api. README updated.
1 parent fc76a83 commit 650466a

File tree

12 files changed

+129
-157
lines changed

12 files changed

+129
-157
lines changed

.bumpversion.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.3
2+
current_version = 0.0.1
33
commit = True
44
tag = True
55
tag_name = {new_version}
@@ -27,6 +27,6 @@ replace = version = {new_version}
2727
search = Version: "{current_version}"
2828
replace = Version: "{new_version}"
2929

30-
[bumpversion:file:templatepy/__init__.py]
30+
[bumpversion:file:sensapex_api/__init__.py]
3131
search = __version__ = "{current_version}"
3232
replace = __version__ = "{new_version}"

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: reorder-python-imports
66
- repo: https://github.com/ambv/black
7-
rev: 21.12b0
7+
rev: 22.3.0
88
hooks:
99
- id: black
1010
- repo: https://github.com/pre-commit/pre-commit-hooks

README.md

Lines changed: 32 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -14,136 +14,54 @@
1414

1515
[Zenodo]: https://zenodo.org
1616

17+
[umsdk]: https://github.com/sensapex/umsdk
18+
[sensapex-py]: https://github.com/sensapex/sensapex-py
19+
1720
[//]: # (Badges)
21+
[//]: # ([![DOI](https://zenodo.org/badge/370470893.svg)](https://zenodo.org/badge/latestdoi/370470893))
22+
[//]: # ([![PyPI](https://img.shields.io/pypi/v/templatepy.svg)](https://pypi.org/project/templatepy))
23+
[//]: # ([![Wheel](https://img.shields.io/pypi/wheel/templatepy.svg)](https://pypi.org/project/templatepy))
24+
[//]: # (![CI](https://github.com/larsrollik/sensapex_api/workflows/tests/badge.svg))
1825

19-
[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/larsrollik/templatepy/blob/main/CONTRIBUTING.md)
20-
[![DOI](https://zenodo.org/badge/370470893.svg)](https://zenodo.org/badge/latestdoi/370470893)
21-
[![Website](https://img.shields.io/website?up_message=online&url=https%3A%2F%2Fgithub.com/larsrollik/templatepy)](https://github.com/larsrollik/templatepy)
22-
[![PyPI](https://img.shields.io/pypi/v/templatepy.svg)](https://pypi.org/project/templatepy)
23-
[![Wheel](https://img.shields.io/pypi/wheel/templatepy.svg)](https://pypi.org/project/templatepy)
24-
![CI](https://github.com/larsrollik/templatepy/workflows/tests/badge.svg)
26+
[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/larsrollik/sensapex_api/blob/main/CONTRIBUTING.md)
27+
[![Website](https://img.shields.io/website?up_message=online&url=https%3A%2F%2Fgithub.com/larsrollik/sensapex_api)](https://github.com/larsrollik/sensapex_api)
2528
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
2629
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
2730

2831

29-
# templatepy
30-
Template repo for python repositories & PyPi integration
32+
# sensapex-api
33+
Meta-API for Sensapex Manipulators from uMx family.
3134
---
32-
**Version: "0.0.3"**
33-
34-
35-
## Usage
36-
1. **Change** files according to overview in `TODO` below
37-
2. **Develop** package...
38-
3. **Install** package:
39-
- static/normal install: `pip install .`
40-
- editable install:`pip install -e .`
41-
- dev install: `pip install -e .[dev]` (some terminals require to escape brackets with ` \ ` as `\[`, esp. zsh)
42-
43-
44-
45-
## File overview
46-
47-
48-
#### General
49-
- `LICENSE`: license text
50-
51-
- `README.md`: [Github-flavored markdown] file
52-
53-
- `templatepy`: placeholder folder for any python package that is configured for install via `setup.cfg` and `pyproject.toml`
54-
- `__init__.py`: contains basic package info and example function that is called by console entrypoint (see `setup.cfg`)
55-
- `example.data.file.config`: a file to demonstrate that data files are included based on `setup.cfg` criteria
56-
- `example.data.file.test-extension-yu48`: a file to demonstrate data exclusion via `setup.py`
57-
58-
59-
#### Testing
60-
- `tests`: placeholder folder for unit/integration tests and associated data
61-
- `pytest.ini`: config for testing framework with `pytest` and `coverage` plugin (`pytest-cov`)
62-
63-
64-
#### Packaging system (see: [packaging] and [setup.cfg])
65-
- `MANIFEST.in`: [manifest] file describes included/excluded files for build
35+
**Version: "0.0.1"**
6636

67-
- `pyproject.toml`:
68-
- specifies build system: this replaces the usual `setup.py` architecture for setuptools
69-
- config for [black] code formatter
37+
This is a meta-API for the Sensapex Python API, which is in turn a binding for the underlying C library.
7038

71-
- `setup.cfg`:
72-
- package specification and install dependencies
73-
- config for `flake8` formatting (see pre-commit)
39+
See underlying library and sources from Sensapex here:
40+
- [umsdk] library
41+
- [sensapex-py]
7442

75-
- `setup.py`: legacy file (see notes on new build-system below)
43+
## Functionality
44+
- Set relative zero position for one or all axes
45+
- Convenience methods to move signle axes (instead of giving vector for all axis, even if only intending to move one axis)
7646

47+
-> See `examples` folder for usage of the relative positioning on one or all axes.
7748

78-
#### Code maintenance (linting/formatting/github)
79-
- `.pre-commit-config.yaml`: use [pre-commit] to run code formatting (e.g. with [black] and `flake8`) and PEP compliance checks
80-
- Install pre-commit hook with `pre-commit install` (Note: only installs it in the current virtual environment)
81-
- Run it manually with `pre-commit run --all` or leave it to run on commit (requires to re-stage changed files!)
82-
83-
- `.github`: folder that contains github automation workflows and issues templates
84-
85-
- `.gitignore`: ignored files/folders in git tools
86-
87-
- `.bumpversion.cfg`: config for [bump2version]
88-
89-
90-
## TODO for **adapting** template to new project
91-
92-
- [ ] Change package name:
93-
- (1) `templatepy` folder
94-
- (2) README.md
95-
- (3) `name` argument in `setup.cfg`
96-
- (4) `.github/workflows` files
97-
- (5) `setup.cfg`: `[bumpversion:file:templatepy/__init__.py]`
98-
- [ ] Change details about project author, etc. in `setup.cfg`, `README.md`, and `templatepy/__init__.py`
99-
- [ ] Change license holder in `LICENSE`
100-
- [ ] Change `README` badge paths at top
101-
- [ ] Verify inclusions/exclusions of installable files/folders in `MANIFEST.in` and `setup.cfg`
102-
- [ ] Check `.gitignore` contains relevant criteria
103-
- [ ] Add all version string locations to `setup.cfg`/bump2version field.
104-
- Use same syntax as for `[bumpversion:file:PACKAGEFOLDER/__init__.py]` line to describe how to find version on version increment
105-
- [ ] To upload to [pypi]: see below for workflow
106-
- [ ] To upload to [Zenodo] if repo is a publication:
107-
- (1) Connect Zenodo to Github account
108-
- (2) Flip switch on zenodo view of repo - **NOTE**: Zenodo can only copy from **public** repos
109-
- (3) Create new release version of github repo (manual or via `.github/workflows/CI.yaml`)
110-
- (4) Wait! Zenodo view with DOI assignment should update within about a minute
111-
- (5) Add DOI badge to `README` file
112-
113-
114-
115-
## Workflow for (automatically) uploading package to [pypi] or [test.pypi]
116-
- (1) On [pypi], make new API key for repo or general
117-
- (2) On [Github](https://github.com/larsrollik/templatepy/settings/secrets/actions/new), in repository settings add a new **actions secret** named `TWINE_API_KEY` and copy in the pypi API key
118-
- (3) Create a new [release](https://github.com/larsrollik/templatepy/releases/new) manually on github or by triggering the github workflow with a version without release extension (e.g. `x.y.z`)
119-
120-
121-
122-
## Notes
123-
124-
#### New(er) build system with `pyproject.toml` and `setup.cfg`
125-
- `pip`
126-
- tested with `pip install . --use-feature=in-tree-build` for forward-compatibility with `pip 21.3`
127-
- keeping empty `setup.py` for enabling install in editable mode `-e` as this still requires such a file
128-
- added `wheel` as build-system dependency for compatibility with pip that does not implement `PEP 517`
129-
- `setup.cfg`/`setup.py` might be fully replaced with `pyproject.toml`. [See this discussion](https://stackoverflow.com/questions/44878600/is-setup-cfg-deprecated) about [PEP-426](https://peps.python.org/pep-0426/), [PEP-517](https://peps.python.org/pep-0517), [PEP-518](https://peps.python.org/pep-0518)
49+
## Install
50+
1. Clone repo: `git clone https://github.com/larsrollik/sensapex-api.git`
51+
2. Install package: `pip install sensapex-api`
52+
3. Install sensapex UM SDK library
53+
1. Follow method in original repo: [umsdk] library
54+
2. or use version of `install_lib.sh` script (in this repo)
13055

56+
## Dependencies
57+
- [sensapex-py] package that can be installed from [sensapex-py] or via `pip install sensapex`
58+
- [umsdk] library
13159

13260
## Contributing
13361
Contributions are very welcome!
13462
Please see the [contribution guidelines](https://github.com/larsrollik/templatepy/blob/main/CONTRIBUTING.md) or check out the [issues](https://github.com/larsrollik/templatepy/issues)
13563

13664
## License
137-
This software is released under the **[BSD 3-Clause License](https://github.com/larsrollik/templatepy/blob/main/LICENSE)**
138-
139-
140-
```shell
141-
wget -q -O tmp.zip http://dist.sensapex.com/misc/um-sdk/latest/umsdk-1_022-src.zip \
142-
&& unzip tmp.zip \
143-
&& rm tmp.zip \
144-
&& cd umsdk-1_022/src/lib/ \
145-
&& make -f Makefile.linux
146-
147-
sudo make -f Makefile.linux install
148-
echo $PWD
149-
```
65+
This software is released under the **[BSD 3-Clause License](https://github.com/larsrollik/templatepy/blob/main/LICENSE)**.
66+
67+
This code is an abstraction layer on top of the MIT-licensed [sensapex-py] and the [umsdk].

examples/relative_zero_all_axes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import logging
2+
import time
3+
4+
from sensapex_api.manipulator import SensapexManipulator
5+
6+
logging.getLogger().setLevel("DEBUG")
7+
8+
9+
def print_positions(s):
10+
print("origin ", s._relative_zero)
11+
print("position", s.position)
12+
print("relative", s.relative_zero)
13+
14+
15+
if __name__ == "__main__":
16+
s = SensapexManipulator(device_id=1)
17+
s.set_relative_zero_all()
18+
19+
print_positions(s)
20+
s.set_axis_position_relative(-1, -2000, 500)
21+
time.sleep(5)
22+
print_positions(s)

examples/relative_zero_one_axis.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import logging
2+
import time
3+
4+
from sensapex_api.manipulator import SensapexManipulator
5+
6+
logging.getLogger().setLevel("DEBUG")
7+
8+
9+
def print_positions(s):
10+
print("origin ", s._relative_zero)
11+
print("position", s.position)
12+
print("relative", s.relative_zero)
13+
14+
15+
if __name__ == "__main__":
16+
s = SensapexManipulator(device_id=1)
17+
s.set_relative_zero_axis(-1)
18+
19+
print_positions(s)
20+
s.set_axis_position_relative(-1, -2000, 500)
21+
time.sleep(5)
22+
print_positions(s)

install_lib.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
wget -q -O tmp.zip http://dist.sensapex.com/misc/um-sdk/latest/umsdk-1_022-src.zip \
3+
&& unzip tmp.zip \
4+
&& rm tmp.zip
5+
6+
cd umsdk-1_022/src/lib/ \
7+
&& make -f Makefile.linux
8+
9+
sudo make -f Makefile.linux install
10+
echo $PWD

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
addopts = --cov=templatepy
2+
addopts = --cov=sensapex_api

sensapex-api/__init__.py

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

sensapex_api/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__author__ = "Lars B. Rollik"
2+
__version__ = "0.0.1"
3+
4+
5+
from sensapex_api.cli import run_cli as run

sensapex_api/cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from argparse import ArgumentParser
2+
3+
4+
def run_cli():
5+
NotImplementedError("CLI not yet implemented")
6+
7+
8+
if __name__ == "__main__":
9+
run_cli()

0 commit comments

Comments
 (0)