Skip to content

Commit 4488f90

Browse files
committed
MOD: Convert Python library to Poetry
1 parent 4f2ee5c commit 4488f90

File tree

13 files changed

+107
-223
lines changed

13 files changed

+107
-223
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name: release
22

3-
# Release Python client library on successful completion of the `test` workflow
4-
53
on:
64
workflow_run:
75
workflows:
@@ -20,29 +18,22 @@ jobs:
2018

2119
steps:
2220
- uses: actions/checkout@v3
23-
with:
24-
fetch-depth: 2
2521

26-
# Python setup
2722
- name: Set up Python environment
2823
uses: actions/setup-python@v4
2924
with:
3025
python-version: "3.10"
3126

32-
# Install dependencies
33-
- name: Install dependencies
27+
- name: Install poetry
3428
run: |
35-
python -m pip install --upgrade pip setuptools wheel
36-
scripts/build.sh
29+
python -m pip install --upgrade pip poetry==1.3.2
3730
38-
# Set release output variables
39-
- name: Set output
31+
- name: Prepare release
4032
id: vars
4133
run: |
42-
echo "::set-output name=tag_name::v$(python setup.py --version)"
43-
echo "::set-output name=release_name::$(python setup.py --version)"
34+
echo "tag_name=v$(poetry version -s)" >> $GITHUB_ENV
35+
echo "release_name=$(poetry version)" >> $GITHUB_ENV
4436
45-
# Create GitHub release
4637
- name: Create release
4738
id: create-release
4839
uses: actions/create-release@v1
@@ -58,110 +49,44 @@ jobs:
5849

5950
publish-sdist:
6051
needs: [tag-release]
61-
name: publish-sdist - Python 3.10 (ubuntu-latest)
52+
name: publish - Python 3.10 (ubuntu-latest)
6253
runs-on: ubuntu-latest
6354

6455
steps:
6556
- uses: actions/checkout@v3
6657

67-
# Python setup
6858
- name: Set up Python environment
6959
uses: actions/setup-python@v4
7060
with:
7161
python-version: "3.10"
7262

73-
# Install release dependencies
74-
- name: Install release dependencies
63+
- name: Install poetry
7564
run: |
76-
python -m pip install --upgrade pip setuptools wheel twine
77-
pip install -r requirements.txt
78-
pip install -r requirements_dev.txt
79-
80-
# Create distribution
81-
- name: Package for release
82-
run: python setup.py sdist
65+
python -m pip install --upgrade pip poetry==1.3.2
8366
84-
# Set release output variables
85-
- name: Set output
86-
id: vars
67+
- name: Build
8768
run: |
88-
echo "::set-output name=asset_path::$(find ./dist -mindepth 1 -print -quit)"
89-
cd dist
90-
echo "::set-output name=asset_name::$(printf '%s\0' * | awk 'BEGIN{RS="\0"} {print; exit}')"
91-
92-
# Upload release asset
93-
- name: Upload release asset
94-
id: upload-release-asset
95-
uses: actions/upload-release-asset@v1
96-
env:
97-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98-
ASSET_PATH: ${{ steps.vars.outputs.asset_path }}
99-
ASSET_NAME: ${{ steps.vars.outputs.asset_name }}
100-
with:
101-
upload_url: ${{ needs.tag-release.outputs.upload_url }}
102-
asset_path: ${{ env.ASSET_PATH }}
103-
asset_name: ${{ env.ASSET_NAME }}
104-
asset_content_type: application/zip
105-
106-
# Publish to PyPI
107-
- name: Publish to PyPI
108-
id: publish-to-pypi
109-
env:
110-
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
111-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
112-
run: twine upload dist/*
113-
114-
publish-wheel:
115-
needs: [tag-release]
116-
name: publish-wheel - Python 3.10 (ubuntu-latest)
117-
runs-on: ubuntu-latest
118-
119-
steps:
120-
- uses: actions/checkout@v3
121-
122-
# Python setup
123-
- name: Set up Python environment
124-
uses: actions/setup-python@v4
125-
with:
126-
python-version: "3.10"
127-
128-
# Install release dependencies
129-
- name: Install release dependencies
130-
run: |
131-
python -m pip install --upgrade pip setuptools wheel twine
132-
pip install -r requirements.txt
133-
pip install -r requirements_dev.txt
134-
135-
# Create distribution
136-
- name: Package for release
137-
run: python setup.py bdist_wheel
69+
poetry build
13870
139-
# Set release output variables
140-
- name: Set output
71+
- name: Prepare artifacts
14172
id: vars
14273
run: |
143-
echo "::set-output name=asset_path::$(find ./dist -mindepth 1 -print -quit)"
144-
cd dist
145-
echo "::set-output name=asset_name::$(printf '%s\0' * | awk 'BEGIN{RS="\0"} {print; exit}')"
74+
echo "asset_path=$(find ./dist -mindepth 1 -print -quit)" >> $GITHUB_ENV
75+
echo "asset_name=databento-*.tar.gz,databento-*.whl" >> $GITHUB_ENV
14676
147-
# Upload release asset
14877
- name: Upload release asset
14978
id: upload-release-asset
15079
uses: actions/upload-release-asset@v1
15180
env:
15281
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153-
ASSET_PATH: ${{ steps.vars.outputs.asset_path }}
154-
ASSET_NAME: ${{ steps.vars.outputs.asset_name }}
15582
with:
15683
upload_url: ${{ needs.tag-release.outputs.upload_url }}
15784
asset_path: ${{ env.ASSET_PATH }}
15885
asset_name: ${{ env.ASSET_NAME }}
15986
asset_content_type: application/zip
16087

161-
# Publish to PyPI
16288
- name: Publish to PyPI
16389
id: publish-to-pypi
16490
env:
165-
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
166-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
167-
run: twine upload dist/*
91+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
92+
run: poetry publish

.github/workflows/test.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name: test
22

3-
# Test the Python client library
4-
53
on:
64
push:
75
branches: [main, dev]
@@ -19,18 +17,25 @@ jobs:
1917
steps:
2018
- uses: actions/checkout@v3
2119

22-
# Python setup
2320
- name: Set up Python environment
2421
uses: actions/setup-python@v4
2522
with:
2623
python-version: ${{ matrix.python-version }}
2724

28-
- name: Install
29-
run: |
30-
python -m pip install --upgrade pip setuptools wheel
31-
scripts/build.sh
25+
- name: Install poetry
26+
run: python -m pip install --upgrade pip poetry==1.3.2
27+
28+
- name: Load cached venv
29+
id: cached-poetry-dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: .venv
33+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
34+
35+
- name: Install dependencies
36+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
37+
run: scripts/build.sh
3238

33-
# Run tests
3439
- name: Run tests in release mode
3540
if: ${{ github.ref == 'refs/heads/main' }}
3641
run: scripts/test.sh --release

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ You can find our full client API reference on the [Historical Reference](https:/
2828

2929
## Requirements
3030
The library is fully compatible with the latest distribution of Anaconda 3.7 and above.
31-
The minimum dependencies as found in the `requirements.txt` are also listed below:
32-
- Python (>=3.7)
33-
- aiohttp (>=3.7.2,<4.0.0)
34-
- databento-dbn (==0.6.1)
35-
- numpy (>=1.17.0)
36-
- pandas (>=1.1.3)
37-
- requests (>=2.24.0)
38-
- zstandard (>=0.21.0)
31+
The minimum dependencies as found in the `pyproject.toml` are also listed below:
32+
- python = "^3.7"
33+
- aiohttp = "^3.7.2"
34+
- databento-dbn = "0.6.1"
35+
- numpy= ">=1.17.0"
36+
- pandas = ">=1.1.3"
37+
- requests = ">=2.24.0"
38+
- zstandard = ">=0.20.0"
3939

4040
## Installation
4141
To install the latest stable version of the package from PyPI:

mypy.ini

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

pyproject.toml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[tool.poetry]
2+
name = "databento"
3+
version = "0.13.0"
4+
description = "Official Python client library for Databento"
5+
authors = [
6+
"Databento <[email protected]>",
7+
]
8+
license = "Apache License 2.0"
9+
packages = [{include = "databento"}]
10+
classifiers = [
11+
"Development Status :: 4 - Beta",
12+
"Operating System :: OS Independent",
13+
"Topic :: Software Development :: Libraries",
14+
"Topic :: Software Development :: Libraries :: Python Modules",
15+
"Topic :: Office/Business :: Financial",
16+
"Topic :: Office/Business :: Financial :: Investment",
17+
]
18+
readme = "README.md"
19+
documentation = "https://docs.databento.com"
20+
homepage = "https://databento.com"
21+
repository = "https://github.com/databento/databento-python"
22+
23+
[tool.poetry.urls]
24+
"Bug Tracker" = "https://github.com/databento/databento-python/issues"
25+
26+
[tool.poetry.dependencies]
27+
python = "^3.7"
28+
aiohttp = "^3.7.2"
29+
databento-dbn = "0.6.1"
30+
numpy= ">=1.17.0"
31+
pandas = ">=1.1.3"
32+
requests = ">=2.24.0"
33+
zstandard = ">=0.20.0"
34+
35+
[tool.poetry.group.dev.dependencies]
36+
mypy = "1.2.0"
37+
pytest = ">=7.3.1"
38+
pytest-asyncio = ">=0.21.0"
39+
pytest-mock = ">=3.10.0"
40+
types-requests = "^2.30.0.0"
41+
42+
[build-system]
43+
requires = ["poetry-core"]
44+
build-backend = "poetry.core.masonry.api"
45+
46+
[tool.mypy]
47+
python_version = 3.7
48+
disallow_untyped_defs = true
49+
disallow_any_generics = true
50+
disallow_subclassing_any = true
51+
ignore_missing_imports = true
52+
namespace_packages = true
53+
no_strict_optional = true
54+
warn_no_return = true
55+
warn_unused_configs = true
56+
warn_unused_ignores = true
57+
58+
[tool.pytest.ini_options]
59+
testpaths = ["tests"]
60+
addopts = "--asyncio-mode auto"

requirements_dev.txt

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

scripts/build.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
#! /usr/bin/env bash
2-
set -e
3-
pip3 install -r requirements.txt
4-
pip3 install -r requirements_dev.txt
5-
pip3 install .
2+
poetry install --with=dev --no-interaction --no-root

scripts/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#! /usr/bin/env bash
22
echo $(mypy --version)
33
echo Running mypy...
4-
mypy databento examples tests --config-file mypy.ini
4+
poetry run mypy databento examples tests

scripts/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /usr/bin/env bash
2-
pytest tests . $@
2+
poetry run pytest tests . $@

0 commit comments

Comments
 (0)