Skip to content

Commit 00b0630

Browse files
flavius-tsjpark608SJ Park
authored
Publish SDK (#184)
* update README * remove install info from tc readme * TC merge for housekeeping (#44) * add fault status reading * add fault mask configuration * tc module restructuring * update documentation * update decimal bit constants * Tc dev fixes (#36) * refactor fault reading * add human readable Fault printing * add option for less verbose fault reading * filter out normal status Faults * refactor fault masking to set individual masks * Gpio merge for house keeping (#42) * gpio periphery being added * gpio periphery being added * rebase gpio branch * created gpio folder and files and tests * Feature branch git action added, gpio command and constants are added * github action yml changed * testing GPIO * gpio bias keyword takenout * path typeError troubleshooting * gpio in progress #20 * disable push test until fixing the bug * Update gpio.py add all keyword args * Update gpio.py passing arguments without keyword * Update gpio.py * gpio test issue resolved #20 * working on constants * Adc rebased and merge to dev (#43) * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * added workflow for CI, #17 * modifying linting requirements * testing * changed global user and email * user name testing * added constants #17 * adding Methods to ADCCommand class #17 * added write_register method, testing exception as well #17 * added dataclasses for register configurations, tests are added for testing immutable class #17 * added more registers and tests, #17 * modifying linting requirements * testing * changed global user and email * user name testing * modified readme back to original state Co-authored-by: SJ Park <sj@SJs-MacBook-Air.local> * Update README module links (#45) Adding module link to ADC now that it is merged to dev, and updating other links to use relative link (so it links to folders on the same branch as top-level readme they're being accessed from) * refactor utilities to support non Enum set_config args (#47) * refactor utilities to support non Enum set_config args * added gpio_cofings.py to add configuration data class for dac #40 (#46) * added gpio_cofings.py to add configuration data class for dac #40 * changed function description * PR #46 fixes * steven can't write :( * filter_dict by value (#53) * add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow * Pytest fix (#57) * Update adc_commands.py updated adc_command to fix the pytest issue * Update adc_commands.py updated adc_command to fix the pytest issue * Edgepi gpio dac config (#55) * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * filter_dict by value (#53) * add names to test and lint workflows (#56) * add names to test and lint workflows * remove pytest-gpio workflow * added mock for testing I2C * gpio-dac-config being implemented #20, #48, #49, #51, #16 * testing I2C * 1. Added gpio config #48 2. edgepi_gpio init method: instantiate super class when I2C gpio group selected and generate pin list #48 #51 #52 3. I2C mocking class for window and Linux environment, #16 * gpio module configurations packed as enum using enum to check configuration by iterating through the enum class * added mock for testing I2C * combined repetitive dataclass fixed a problem with circular dependency * fixing pytest failures Co-authored-by: flavius-t <77416463+flavius-t@users.noreply.github.com> Co-authored-by: flavius-t <flavius.t@hotmail.com> * TC Open Circuit (#59) * add open fault detection mode config * Fix Linting (#65) * Fix TestPyPi (#66) * TC Compute Conversion Time (#63) * add compute conversion time * refactor single_sample for time delay computation * update time conv docstrings * inflate time delays * TC Set Temperatures (#60) * add temperature setting to set_config * add cold junction temp override method * add temperature input validation * add update_registers_from_dict and test * add temperature range validation by tc type * add custom exceptions, expand tempcode testing * add convert from DecBits to float * add cold-junction overwrite error * TC Integration Tests (#70) * separate tests to unit and integration * add thermocouple integration tests * refactoring to support tc integration testing * Edgepi gpio transfer (#62) * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * fixed I2C.Message Mocking * tested transfer function and it is working * set default in progress #51, #52, #50, #48 * more commands being added added more gpio state parameter in I2C info dataclass * Update edgepi_gpio.py added todo notes * set default in progress * Set default in progress another GPIO config added to I2CpinInfo dataclass adding helper methods read register and map register to dictionary * added reg helper class to generate the register dictionary. added another function to split pin list into two separate lists to check whether the gpio group uses two separate I2C expander * set-default need testing * set default tested * Update edgepi_tc.py the __ was deleted by accident * tests not passing * testing fixed * Update test_edgepi_gpio.py fixed tests * requested changed from Farzad * Todos added * working on todos, changed pin list to be self-explanatory, need to work on __generate_default_reg_dict to be more intuitie * changed naming conventions and using dictionary instead of list for describing pins * fixing pylint * fixing linting issue * fix I2C test and pylint on linux * disabled E1101 to go work around the error from mock class * fixed lint and testing mock * Unit Test Fixes (#74) * separate peripherals testing to unit/integration * testing workflow changes * Edgepi gpio toggle (#75) * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * adding set_gpio function modified set_default and dgenerate default reg dict -instead of using list of dictionary, using dictionary format - set expander pin uses pin_name to set corresponding gpio #49 * clear expander pin * Toggle gpio pin added #49 * pylint passed" * refactored for-loop test for __write_changed_values is not added since the function doesn't return any value and only execute the transaction * Readme added while working on the readme, i realized the order of AO_ENx pins were reversed. the order is fixed now * Update edgepi_gpio.py for loop replaced with a write change value method * Add Test Coverage (#79) * add code coverage to unit test workflow * add workflow status badges * DAC Interface (#77) * add set channel power mode * add set_gain_mode * add software reset * add readback * add code to voltage * integrate with gpio module * Dac calibration (#84) * refactoring calibration parameter dataclass #9 * changed test fixture for dac_command * calibration parameter refactored * dac calibration refactored * Update test_edgepi_dac.py linter fix * added and edited suggested comments * Calibration module (#92) * #83 creating files * adding unittest * Update test_access_eeprom.py * added unittest & i2c transfer return change * adding calibration mapping and class * Update edgepi_calibration.py todo notes added * pylint fix * code review suggestions * Requested PR fixes - Nomenclature files - Reg address name change -> mem_addr - Device address is a constant now - EEPROM class * ADC Interface (#97) * Adding functions to calibration class (#98) * adding helper class for calibration process * adding functions to generate necessary dictionaries * pylint fixes * Update test_adc_state.py (#100) #99 * Get/Set Individual Pin States (#105) * LED Module (#106) * Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix * Issue102 dac (#109) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * adding get_state() dac #102 dac get_state is being added * fixed voltage_to_code and code_to_voltage calculation * passing pytest * changed the key from string name to number * changed get_state function #102 osensa/edgepi-device-manager/issues/3 * pylint fix * Issue103 adc (#110) * adc testing being added * added test * Individual channel modification (#108) * Individual channel modification #103 - Only single pins gets accessed - simplified code calculate for now, calibration to be added * fixed voltage_to_code and code_to_voltage calculation * applying suggested fix * added todo and fixed pylint * used enums for pin names * Update edgepi_adc.py removed clear exapnder to avoid resetting of Ground reference when a new object is instantiated * Update edgepi_adc.py (#115) * Update edgepi_adc.py To Do added * Update edgepi_adc.py have a ruler set for pylint, and still fails on line-too-long :( * Gpio delete set default (#116) * deleting obsolete function * added unit tests for functions changed gpio pin ordering of DAC module * Loading DAC related Calibration parameter from the EEPROM (#114) * dummy functions added for calibration added logger added generate calib dictionary functions , logics to be implemented * unpacking packing added unpacking: from list of parameter that read from eeprom to a single value packing : from a value to a list of bytes to load to the eeprom * calib dictionary generation for dac * loading calib param added and tested * Update test_edgepi_calibration.py updated the unit test for get_calibration_dict. Other module test cases are deleted for now * PR#114 fix - added a dictionary of functions - added more description to the address constants * Remove ADC Init Configs (#119) * remove configs from adc init * rename to private method * Calibration dac (#120) * Update edgepi_dac.py adding calibration classes, need to check dictionary structure. implement DAC_GAIN parameter maybe needed * DAC calibration updated #111 - loading of calibration parameter from eeprom - generation and get calibration dictionary - check dac_gain state before code2voltage or voltage 2code conversion - conversion formula edited to accommodate the calibration param and dac gain state * set/clear internal DAC gain #76 * Update edgepi_dac.py PR #120 suggested fix * constant name change PR #120 suggested fix * ADC Differential Reads, RTD Mode (#118) * remove unused duplicate channel assignment code * fix pytest discovery error * add SPI debugging logs * change rtd_enabled check logic * diff read constants * rtd property check, set diff mode * unit test validate_no_rtd_conflict * unit test select_differential * ignore local test scripts * documentation additions * opcodes for RTD mode * doc updates, pytest config * unit test IDACMUX opcodes * unit test IDACMAG opcodes * fix IDACMAG opcode bug * fix REFMUX opcode bug * expand REFMUX opcode unit tests, renaming * uncomment adc config integration tests * integration test IDACMUX opcodes * integration test IDACMAG opcodes * integration test REFMUX opcodes * integration test select_differential * add idac channel 9 * fix opcode name, failing unit test * add rtd mode enums * add rtd_mode, todos for get_state with caching * rename __get_rtd_en_status * fix rtd_mode logic, unit test * integration test rtd_mode, fix bug * Remap ADC Multiplexers (#122) * mux mapping set mux_n to AINCOM * refactor mux arg handling in __config * refactor None checking, update docstring * remove temporary test fix * remove unnecessary test cases * I2C set_msg function takes list of addresses (#128) * #127 added another type for addr parameter of set_read_msg and set_write_msg to accomodate a list of addresses * | was introduced in python 3.10 but the test automation is using python 3.9 * Calibration suggestion (#129) * Nov1 code review suggestions * refactoring eeprom access module to accomodate the hardware change * EEPROM class is refactored to accomodate the larger memory size #125 * pylint fix * Eeprom protobuf (#131) * protobuf implementation #126 #124 * test added * pylint fix and update dependencies * Update requirements_test.txt * delete Todos * suggested fixes * suggested name fix * generate_calib_param dictionary added (#134) * generate_calib_param dictionary added * pytest fix * suggested fix - calib_params nomenclature - better description for docstring * suggest fix - calib param dataclass formation done in eeprom class - removed redundant methods and tests * ADC Get State (#132) * refactor get_state to EdgePiADC * refactor ADCModes * add get_register_map * use get_register_map for internal register reads * refactor ADCState * use new ADCState for getting state internally * add get mux states * refactor state query constants to module * ADC Calibration (#138) * added eeprom reading to load calibration parameter * diff/individual voltage read calibration handling #133 Co-authored-by: sjpark608 <spark@osensa.com> * fixed typing issue (#136) #135 added test cases for checking the type * Add ADC2 (#139) * add adc-2 to voltage reads, set_config * dac conversion formula change (#146) * dac conversion formula change #143 #144 - added updated serialized file for testing - updated formula for voltage2code code2voltage - updated unittest - added serialized read helper file - deleted outdated dac_calibration files * pylint fix * DAC Enum Args (#152) * refactor user interface to enum channel args * GPIO refactoring in progress (#156) * gpio module refactored #153 * adding test cases fixing typos * gpio module refactor adding edgpi gpio test * fix suggestions * RTD Sampling (#160) * Hardware Tests (#162) * voltage read-write test * add test report to gitignore * custom approx comparator * move adc conversion time tests * update hardware test instructions * move integration tests to new folder * diff voltage tests * add adc_2 diff test * add rtd tests * bypass rtd validation in mux mapping * fix rtd temp calculation bug * GPIO module refactoring intermediate PR (#161) * refactoring generating pin dictionary to have generic dictionary #154 #155 * generic object instantiation #154 #155 * Update test_dac.py dict_pin changed to expander_pin_dict after refactor * lint fix * Gpio refactor 154 (#167) * added gpio exception, gpio write, need some testing on the hardware #166 #154 #155 * added set direction in out function, get direction function * edgepi gpio methods gets enum values typed string * changed function name used in different modules * fixed pytest and pylint issues * added toggle pin * deleted unused module * PR #167 suggested fix - added __pin_name_check() - added more tests * GPIO DOUT pin list re-order (#169) * Update gpio_configs.py Forgotten change * fixed LED integration test * Get State Override Cache (#175) * add override cache to get state * Fix Read Voltage Validation (#176) * fix conv mode validation in read_voltage * Digital input module (#173) * adding din module and tests * Digital input reading #170 * Added test parameters * added exception and testing * digital out module #171 (#172) * Main README Update (#181) * Update README.md * update sdk package naming * update version num * added README and re-naming module (#182) * LED Module README (#183) * Create README.md * Update README.md Co-authored-by: sjpark608 <78987042+sjpark608@users.noreply.github.com> Co-authored-by: SJ Park <sj@SJs-MacBook-Air.local> Co-authored-by: sjpark608 <spark@osensa.com>
1 parent 5e10ef2 commit 00b0630

File tree

137 files changed

+18880
-1041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+18880
-1041
lines changed

.coveragerc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# .coveragerc to control pytest-cov code coverage testing
2+
3+
[run]
4+
branch = True
5+
source = src/edgepi
6+
7+
[report]
8+
show_missing = True
9+
skip_empty = True
10+
11+
[xml]
12+
output = test_cov/coverage.xml

.github/workflows/build-and-publish-TestPyPI.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Build and Publish to TestPyPI
55
on:
66
push:
77
branches:
8-
- 'dev'
8+
- 'staging'
99

1010
jobs:
1111
build-and-publish:
@@ -22,9 +22,14 @@ jobs:
2222
run: |
2323
python -m pip install --upgrade pip
2424
if [ -f requirements_build.txt ]; then python -m pip install -r requirements_build.txt; fi
25+
- name: Bump Patch Number
26+
run: |
27+
if [ -f bump_patch.py ]; then python bump_patch.py; fi
2528
- name: Build Package
2629
run: |
2730
python -m build
28-
- name: Publish Package to TestPyPI
29-
run: |
30-
python -m twine upload --repository testpypi dist/* --verbose
31+
- name: Publish Distribution to TestPyPI
32+
uses: pypa/gh-action-pypi-publish@master
33+
with:
34+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
35+
repository_url: https://test.pypi.org/legacy/

.github/workflows/python-test.yml renamed to .github/workflows/python-integration-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# This workflow will install Python dependencies, run tests using PyTest.
22

3-
name: PyTest
3+
name: PyTest Integration Test
44

55
on:
66
push:
77
branches:
8-
- 'dev'
8+
- 'staging'
99
pull_request:
1010
branches:
11-
- 'dev'
11+
- 'staging'
1212

1313
jobs:
14-
build:
15-
14+
test:
15+
name: Self-Hosted Integration Test
1616
runs-on: self-hosted
1717
strategy:
1818
fail-fast: false
@@ -32,4 +32,4 @@ jobs:
3232
- name: Test with pytest
3333
run: |
3434
source venv_test/bin/activate
35-
pytest ./src/test_edgepi
35+
pytest ./src/tests/integration_tests

.github/workflows/python-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ on:
1111
- 'dev'
1212

1313
jobs:
14-
build:
15-
14+
lint:
15+
name: Linter
1616
runs-on: ubuntu-latest
1717
strategy:
1818
fail-fast: false
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# This workflow will install Python dependencies, run tests using PyTest.
2+
3+
name: PyTest Unit Test
4+
5+
on:
6+
push:
7+
branches:
8+
- 'dev'
9+
pull_request:
10+
branches:
11+
- 'dev'
12+
13+
jobs:
14+
test:
15+
name: Unit Tests
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python-version: ["3.9"]
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install Dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m venv venv_test
33+
source venv_test/bin/activate
34+
python -m pip install pytest
35+
if [ -f requirements_test.txt ]; then pip install -r requirements_test.txt; fi
36+
- name: Test with pytest
37+
run: |
38+
source venv_test/bin/activate
39+
pytest ./src/test_edgepi/unit_tests --cov --cov-report=xml
40+
- name: Code Coverage Summary Report
41+
uses: irongut/CodeCoverageSummary@v1.2.0
42+
with:
43+
filename: test_cov/coverage.xml
44+
badge: true
45+
format: markdown
46+
hide_complexity: true
47+
indicators: true
48+
output: both
49+
- name: Add Coverage PR Comment
50+
uses: marocchino/sticky-pull-request-comment@v2
51+
with:
52+
recreate: true
53+
path: code-coverage-results.md

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,12 @@ dmypy.json
132132

133133
# Pyre type checker
134134
.pyre/
135+
136+
#Mac OS env file
137+
.DS_store
138+
139+
# local test scripts
140+
src/edgepi/scripts
141+
142+
# hardware test reports
143+
tests/reports

.pylintrc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
[MESSAGES CONTROL]
22

3-
disable=trailing-whitespace,
4-
logging-fstring-interpolation,
5-
line-too-long,
6-
invalid-name
3+
disable=logging-fstring-interpolation,
4+
too-many-locals,
5+
too-many-arguments,
6+
fixme,
7+
too-few-public-methods,
8+
duplicate-code
9+
10+
[LOGGING]
11+
12+
# Format style used to check logging format string. `old` means using %
13+
# formatting, while `new` is for `{}` formatting.
14+
logging-format-style=new
15+
16+
[BASIC]
17+
# exclude docstring requirement for test and private functions
18+
no-docstring-rgx=^test_|^_|^fixture
19+
20+
# Good variable names which should always be accepted, separated by a comma
21+
good-names=fd,ch,dr,tc,i
722

823
[REPORTS]
924

README.md

Lines changed: 108 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,117 @@
1-
# edgepi-python-sdk
1+
![Image](https://user-images.githubusercontent.com/3793563/207438826-bb656ca5-f19d-4699-8cb4-35acccb2ce58.svg)
22

3-
## Develop Environment Setup
4-
Two separate virtual environment is needed.
5-
1. venv_build: building environement where the package is compiled and published. import requirements_build.txt for pip dependencies.
6-
2. venv_test
7-
- TDD environment where the package source tree can be tested as bug fix / new features are implemented.The `testPyPi` tries to install the dependency in `testPyPi` instead of actual `PyPi`. Therefore, the `install_requires` option fails to install the required package.
8-
- This environment is also used to test the package after it is published. Install the package using `pip` and run test scripts inside `test` folder. This will import the installed package, not the modules in the `src` directory.
3+
EdgePi is a DIN rail-mounted, Raspberry Pi 4 industrial PC with the features of a Programmable Logic Controller (PLC), and Internet of Things (IoT) cloud edge device. Visit [edgepi.com](https://www.edgepi.com) for more information.
94

10-
## SDK packaging
5+
![](https://github.com/EdgePi-Cloud/edgepi-python-sdk/actions/workflows/python-unit-test.yml/badge.svg)
6+
![](https://github.com/EdgePi-Cloud/edgepi-python-sdk/actions/workflows/python-lint.yml/badge.svg)
7+
[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/EdgePi-Cloud/edgepi-python-sdk/blob/main/LICENSE)
8+
---
9+
# EdgePi SDK
10+
Use our user-friendly Python SDK to control the EdgePi hardware with just a few lines of simple Python Code.
11+
![Image](https://user-images.githubusercontent.com/3793563/207419171-c6d4ad94-edca-4daa-ad78-689c16ade4a7.png)
12+
# How to Use EdgePi SDK
13+
## How to Install
14+
The latest stable release of the EdgePi SDK will be available to be installed via The Python Package Index (PyPi). To install the EdgePi SDK from PyPi via pip, you may use the following command from terminal:
1115

12-
- Use setup.py file to edit meta-data when building/created new package
13-
- run ```python -m build``` command in root directory of the SDK create distribution
14-
- run ```py -m twine upload --repository testpypi dist/* --verbose``` command to upload the distribution to TestPyPi
16+
```
17+
$ python3 -m pip install edgepi-python-sdk
18+
```
19+
## Example Code
20+
The EdgePi SDK provides a wide range of functionality to users, allowing interaction with the many modules onboard the EdgePi. One such module, the ADC, can be used to read voltage continuously from any of the eight EdgePi analog input pins:
21+
22+
```
23+
from edgepi.adc.edgepi_adc import EdgePiADC
24+
from edgepi.adc.adc_constants import ADCChannel, ConvMode, ADCNum
25+
26+
# initialize ADC
27+
edgepi_adc = EdgePiADC()
28+
29+
# configure ADC to sample analog input pin AIN3
30+
edgepi_adc.set_config(adc_1_analog_in=ADCChannel.AIN3, conversion_mode=ConvMode.CONTINUOUS)
31+
32+
# send command to start continuous conversions
33+
edgepi_adc.start_conversions(ADCNum.ADC_1)
34+
35+
# perform 10 voltage reads
36+
for _ in range(10):
37+
out = edgepi_adc.read_voltage(ADCNum.ADC_1)
38+
print(out)
39+
40+
# stop continuous conversions
41+
edgepi_adc.stop_conversions(ADCNum.ADC_1)
42+
```
43+
For further details on this and other modules, please refer to each module's documentation by following the links provided in the `Implemented Modules` section below.
44+
# Implemented Modules
45+
The EdgePi SDK contains modules intended to represent each connected peripheral device onboard the EdgePi. Below is a directory of the currently available modules.
46+
* [Thermocouple](src/edgepi/tc)
47+
* [Digital to Analog Converter (DAC)](src/edgepi/dac)
48+
* [Analog to Digital Converter (ADC)](src/edgepi/adc)
49+
* [LED Array](src/edgepi/led)
50+
* [Digital In (DIN)](src/edgepi/din)
51+
* [Digital Out (DOUT)](src/edgepi/dout)
52+
# Development
53+
Active development SDK versions can be accessed from the following resources:
54+
## Installing from TestPyPi
55+
To install the most recent active development SDK version via [TestPyPi](https://test.pypi.org/project/edgepi-python-sdk/):
56+
```
57+
$ python3 -m pip install -i https://test.pypi.org/simple/ edgepi-python-sdk
58+
```
59+
Previous development SDK versions can also be installed by specifiying the version number:
60+
```
61+
$ python3 -m pip install -i https://test.pypi.org/simple/ edgepi-python-sdk==<version-number>
62+
```
63+
Please refer to [TestPyPi](https://test.pypi.org/project/edgepi-python-sdk/) for available SDK versions.
64+
## Installing from GitHub
65+
To install the SDK via HTTPS from GitHub:
66+
```
67+
$ python3 -m pip install git+https://github.com/EdgePi-Cloud/edgepi-python-sdk.git@<branch-name>
68+
```
69+
70+
# Packaging
71+
To build and publish a new SDK version as a package, a build virtual environment is required. This may be configured as follows:
72+
```
73+
$ cd edgepi-python-sdk
74+
75+
$ python3 -m venv venv_build
1576
16-
__NOTE__ when package structure name, such as folder or module src file name, changes, delete '.egg-info' file and rebuild. This will ensure the file name in compiled package is changed.
77+
$ source venv_build/bin/activate
1778
18-
Change in capitalization in file/folder names are recognized by git
79+
$ python3 -m pip install -r requirements_build.txt
80+
```
81+
With the build environment configured and activated, a new distribution can be built as follows:
82+
```
83+
$ python3 -m build
84+
```
85+
Note, when the package structure changes, such as after renaming the `src` module or other folders, delete the `.egg-info` file from `/src` and rebuild. This will ensure the file names in the compiled package are updated. Also note that changes in file/folder name capitalization are recognized by git. To disable this:
1986
```
2087
git config --global core.ignorecase false
2188
```
2289

23-
## SDK Structure
24-
```
25-
EDGEPI-PYTHON-SDK
26-
├── src
27-
│ └── edgepi
28-
│ ├── __init__.py
29-
│ ├── dac
30-
│ │ ├── __init__.py
31-
│ │ └── ...submodules
32-
│ ├── peripherals
33-
│ │ ├── __init__.py
34-
│ │ └── ...submodules
35-
│ ├── ...subpackages
36-
│ ├── edgepi_dac.py
37-
│ ├── edgepi_adc.py
38-
│ ├── edgepi_tc.py
39-
│ └── ...modules
40-
│ └── test_edgepi
41-
│ ├── __init__.py
42-
│ ├── test_dac
43-
│ │ ├── __init__.py
44-
│ │ └── ...submodules
45-
│ ├── test_peripherals
46-
│ │ ├── __init__.py
47-
│ │ └── ...submodules
48-
│ ├── ...test_subpackages
49-
├── tests
50-
│ ├── test_dac.py
51-
│ ├── test_tc.py
52-
│ └── ...each subpackages
53-
├── readme.md
54-
├── setup.py
55-
└── requirements.txt
56-
```
90+
With the new disbtribution created, you may publish to the official Python package repositories:
91+
92+
To publish to TestPyPi:
93+
```
94+
$ python3 -m twine upload --repository testpypi dist/* --verbose
95+
```
96+
To publish to PyPi:
97+
```
98+
$ python3 -m twine upload dist/* --verbose
99+
```
100+
101+
Both TestPyPi and PyPi will prompt you for authentication. For best practices, use a corresponding TestPyPi or PyPi token to authenticate as follows:
102+
```
103+
name: __token__
104+
password: <token-value>
105+
```
106+
Make sure to include the `pypi-` prefix for your token value.
107+
108+
# Bug Reports / Feature Requests
109+
Use [GitHub Issues Page](https://github.com/EdgePi-Cloud/edgepi-python-sdk/issues) to report any issues or feature requests.
110+
111+
# Get involved
112+
Follow [@edgepi_cloud on Twitter](https://twitter.com/edgepi_cloud/).
113+
Read and subscribe to the [EdgePi blog](https://www.edgepi.com/blog).
114+
If you have a specific question, please check out our [discussion forums](https://www.edgepi.com/forums).
115+
116+
# License
117+
EdgePi SDK is distributed under [MIT License](https://github.com/EdgePi-Cloud/edgepi-python-sdk/blob/main/LICENSE).

bump_patch.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""increment patch number for publishing to TestPyPi"""
2+
3+
import sys
4+
import fileinput
5+
6+
7+
SEARCH_TEXT = "version"
8+
TEST_PYPI_VER_NUM = "TEST_PYPI_VER_NUM"
9+
10+
11+
def bump_version_patch(vers_line: str) -> str:
12+
"""
13+
Increments patch number of a version line taking the format
14+
major.minor.patch
15+
"""
16+
version = vers_line.split('"')[1]
17+
semantic_list = version.split(".")
18+
patch_num = int(semantic_list[2]) + 1
19+
new_ver = semantic_list[0] + "." + semantic_list[1] + "." + str(patch_num)
20+
return line.replace(version, new_ver)
21+
22+
23+
if __name__ == "__main__":
24+
# get current version number
25+
with fileinput.input("./setup.py", inplace=True) as file:
26+
for line in file:
27+
if SEARCH_TEXT in line:
28+
# replace line containing version number
29+
new_line = bump_version_patch(line)
30+
sys.stdout.write(new_line)
31+
else:
32+
# do not modify line
33+
sys.stdout.write(line)
34+
35+
file.close()

pytest.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[pytest]
2+
; faulthandler_timeout=5
3+
; log_cli=TRUE
4+
log_level=INFO
5+
log_format=%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s
6+
# **********************
7+
# These tests rely on python periphery which is not available on Windows, so this causes
8+
# Pytest discovery error. Uncomment below line when using Windows, in order to hide integration and
9+
# hardware tests from Pytest and prevent Pytest discovery errors.
10+
# **********************
11+
; addopts= --ignore=./tests

0 commit comments

Comments
 (0)