Skip to content

Commit 3d1452f

Browse files
MHHukiewitzhoh
andauthored
Use Hatch for Project Management (aleph-im#111)
* Setup hatch for project & dependencies management * Fix build targets * Add Mike as author * Remove unneeded files * Add missing configs from setup.py * Update README.md to reflect latest changes and use hatch in setup * Add Flake8-pyproject plugin to enable flake8 configuration through pyproject.toml; Add ethereum deps to "testing" deps; Update workflows to only use `pip install -e .[testing]` * Revert faulty formatting * Move mypy.ini to pyproject.toml and make it lean * Remove need for mypy.ini in workflow * Fix mypy config * Adding py.typed marker and automatically install type stubs when running mypy * Use LICENCE.txt file in pyproject.toml * Add classifiers * Use VCS version (git tag) * Add envs for testing and linting * Merge optional encryption dependencies from aleph-im#110 * Fix test and coverage; remove need for docker files in pytest workflow * Fix workflows * Further improve hatch scripts and workflows * Fix python-version matrix * Fix missing test dependencies * Fix missing test dependencies for Python 3.12 and further improve workflow * Remove Python 3.12 from supported versions * Update pyproject.toml Co-authored-by: Hugo Herter <[email protected]> * Update pyproject.toml Co-authored-by: Hugo Herter <[email protected]> * Unify script/env names to equal aleph-vm conventions * Fix codecov action param * Add coverage.py for the codecov action --------- Co-authored-by: Hugo Herter <[email protected]>
1 parent 8503c3b commit 3d1452f

19 files changed

+340
-591
lines changed

Diff for: .coveragerc

-31
This file was deleted.

Diff for: .github/workflows/build-wheels.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ${{ matrix.os }}
1717

1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
2020

2121
- name: Workaround github issue https://github.com/actions/runner-images/issues/7192
2222
if: startsWith(matrix.os, 'ubuntu-')
@@ -29,7 +29,7 @@ jobs:
2929
python-version: 3.11
3030

3131
- name: Cache dependencies
32-
uses: actions/cache@v3
32+
uses: actions/cache@v4
3333
with:
3434
path: ~/.cache/pip
3535
key: ${{ runner.os }}-build-wheels-${{ hashFiles('setup.cfg', 'setup.py') }}

Diff for: .github/workflows/code-quality.yml

+11-26
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,26 @@ jobs:
1111
runs-on: ubuntu-22.04
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515

1616
- name: Workaround github issue https://github.com/actions/runner-images/issues/7192
1717
run: sudo echo RESET grub-efi/install_devices | sudo debconf-communicate grub-pc
1818

19+
- name: Install pip and hatch
20+
run: |
21+
sudo apt-get install -y python3-pip
22+
pip3 install hatch
23+
1924
- name: Cache dependencies
20-
uses: actions/cache@v3
25+
uses: actions/cache@v4
2126
with:
2227
path: ~/.cache/pip
23-
key: ${{ runner.os }}-code-quality-${{ hashFiles('setup.cfg', 'setup.py') }}
28+
key: ${{ runner.os }}-code-quality-${{ hashFiles('pyproject.toml') }}
2429
restore-keys: |
2530
${{ runner.os }}-code-quality-
2631
2732
- name: Install required system packages only for Ubuntu Linux
28-
run: |
29-
sudo apt-get update
30-
sudo apt-get -y upgrade
31-
sudo apt-get install -y libsecp256k1-dev
32-
33-
- name: Install required Python packages
34-
run: |
35-
python3 -m pip install -e .[testing,ethereum]
36-
37-
- name: Test with Black
38-
run: |
39-
black --check ./src/ ./tests/ ./examples/
40-
41-
- name: Test with isort
42-
run: |
43-
isort --check-only ./src/ ./tests/ ./examples/
33+
run: sudo apt-get install -y libsecp256k1-dev
4434

45-
- name: Test with MyPy
46-
run: |
47-
mypy --config-file ./mypy.ini ./src/ ./tests/ ./examples/
48-
49-
- name: Test with flake8
50-
run: |
51-
flake8 ./src/ ./tests/ ./examples/
35+
- name: Run Hatch lint
36+
run: hatch run linting:all

Diff for: .github/workflows/pytest-docker.yml

-38
This file was deleted.

Diff for: .github/workflows/pytest.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test/Coverage with Python
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- run: sudo apt-get install -y python3-pip libsecp256k1-dev
24+
- run: python -m pip install --upgrade pip hatch coverage
25+
- run: hatch run testing:test
26+
if: matrix.python-version != '3.11'
27+
- run: hatch run testing:cov
28+
if: matrix.python-version == '3.11'
29+
- uses: codecov/[email protected]
30+
if: matrix.python-version == '3.11'
31+
with:
32+
token: ${{ secrets.CODECOV_TOKEN }}
33+
slug: aleph-im/aleph-sdk-python

Diff for: AUTHORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Contributors
55
* Henry Taieb <[email protected]>
66
* Hugo Herter <[email protected]>
77
* Moshe Malawach <[email protected]>
8+
* Mike Hukiewitz <[email protected]>

Diff for: CHANGELOG.rst

-8
This file was deleted.

Diff for: README.md

+53-9
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ Python SDK for the Aleph.im network, next generation network of decentralized bi
55
Development follows the [Aleph Whitepaper](https://github.com/aleph-im/aleph-whitepaper).
66

77
## Documentation
8-
Documentation (albeit still vastly incomplete as it is a work in progress) can be found at [http://aleph-sdk-python.readthedocs.io/](http://aleph-sdk-python.readthedocs.io/) or built from this repo with:
8+
The latest documentation, albeit incomplete, is available at [https://docs.aleph.im/libraries/python-sdk/](https://docs.aleph.im/libraries/python-sdk/).
99

10-
```shell
11-
$ python setup.py docs
12-
```
10+
For the full documentation, please refer to the docstrings in the source code.
1311

1412
## Requirements
1513
### Linux
@@ -31,18 +29,64 @@ $ brew install libsecp256k1
3129
Using pip and [PyPI](https://pypi.org/project/aleph-sdk-python/):
3230

3331
```shell
34-
$ pip install aleph-sdk-python[ethereum,solana,tezos]
32+
$ pip install aleph-sdk-python
33+
```
34+
35+
### Additional dependencies
36+
Some functionalities require additional dependencies. They can be installed like this:
37+
38+
```shell
39+
$ pip install aleph-sdk-python[ethereum, dns]
3540
```
3641

42+
The following extra dependencies are available:
43+
- `ethereum` for Ethereum and Ethereum-compatible chains
44+
- `solana` for Solana accounts and signatures
45+
- `cosmos` for Substrate/Cosmos accounts and signatures
46+
- `nuls2` for NULS2 accounts and signatures
47+
- `polkadot` for Polkadot accounts and signatures
48+
- `ledger` for Ledger hardware wallet support, see [Usage with LedgerHQ hardware](#usage-with-ledgerhq-hardware)
49+
- `mqtt` for MQTT-related functionalities, see [examples/mqtt.py](examples/mqtt.py)
50+
- `docs` for building the documentation, see [Documentation](#documentation)
51+
- `dns` for DNS-related functionalities
52+
- `all` installs all extra dependencies
53+
54+
3755
## Installation for development
38-
To install from source and still be able to modify the source code:
56+
Setup a virtual environment using [hatch](https://hatch.pypa.io/):
57+
```shell
58+
$ hatch shell
59+
```
60+
61+
Then install the SDK from source with all extra dependencies:
3962

4063
```shell
41-
$ pip install -e .[testing]
64+
$ pip install -e .[all]
4265
```
43-
or
66+
67+
### Running tests & Hatch scripts
68+
You can use the test env defined for hatch to run the tests:
69+
70+
```shell
71+
$ hatch run test:run
72+
```
73+
74+
See `hatch env show` for more information about all the environments and their scripts.
75+
76+
### Generating the documentation [DEPRECATED]
77+
The documentation is built using [Sphinx](https://www.sphinx-doc.org/).
78+
79+
To build the documentation, install the SDK with the `docs` extra dependencies:
80+
81+
```shell
82+
$ pip install -e .[docs]
83+
```
84+
85+
Then build the documentation:
86+
4487
```shell
45-
$ python setup.py develop
88+
$ cd docs
89+
$ make html
4690
```
4791

4892
## Usage with LedgerHQ hardware

Diff for: docker/python-3.10.dockerfile

-39
This file was deleted.

Diff for: docker/python-3.11.dockerfile

-39
This file was deleted.

Diff for: docker/python-3.9.dockerfile

-39
This file was deleted.

0 commit comments

Comments
 (0)