Skip to content

Commit

Permalink
fix: fix ci/cd pipeline for publihsing
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckland committed May 26, 2024
1 parent a2b8333 commit 92aaf59
Show file tree
Hide file tree
Showing 12 changed files with 1,476 additions and 169 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/python-build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# maturin generate-ci github
#
name: CI
name: Python CI

on:
push:
Expand Down Expand Up @@ -133,6 +133,7 @@ jobs:
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
MATURIN_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: Rust CI
on:
push:
tags:
Expand Down
13 changes: 3 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ["doc/*", "assets/*", "test/*"]
[features]
default = ["cli"]
spreadsheets = ["dep:calamine"]
# python = ["dep:pyo3", "dep:pythonize"]
python = ["dep:pyo3", "dep:pythonize"]
cli = ["spreadsheets", "dep:docopt"]

[lib]
Expand All @@ -33,18 +33,11 @@ csv = "1.3.0"
thiserror = "1.0.59"
docopt = { version = "1.0.0", optional = true }
calamine = { version = "0.24", optional = true }

# pyo3 = { version = "0.21.2", features = [
# "extension-module",
# "generate-import-lib",
# ], optional = true }
# pythonize = { version = "0.21.1", optional = true }

pyo3 = { version = "0.21.2", features = [
"extension-module",
"generate-import-lib",
]}
pythonize = { version = "0.21.1"}
], optional = true }
pythonize = { version = "0.21.1", optional = true }


[dependencies.linked-hash-map]
Expand Down
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
The tools is primarly centered around getting tabular data (spreadsheets, CSVs)
into Markdown.

It is split into 3 separate crates.
It is a library and a CLI. The library is both Rust, and a Python lib.
The library, if you need spreadsheet support, then add the `spreadsheets` feature.

1. `madato` - this library, which has YAML support
2. `madato_cal` - which provides support for reading and writing XLS and ODS Spreadsheets
3. `madato_cmd` - providing a helpful command line tool of the above
```
madato = { version = "0", features = ["spreadsheets"] }
```

1. `madato (library)` - this library, which has YAML support
2. `feature = "spreadsheets"` - which provides support for reading and writing XLS and ODS Spreadsheets
3. `madato (cli)` - providing a helpful command line tool of the above
4. The full library is available as a python module

# Details

Expand Down Expand Up @@ -94,9 +101,20 @@ madato uses:

* I have found that copying the "table" I want from a website: HTML, to a spreadsheet, then through `madato` gives an excellent Markdown table of the original.

## Rust API

## JS API
## Python

```
pip install madato
# py
from IPython.display import display, Markdown
import madato
display(Markdown(madato.spreadsheet_to_md("../test/Financial Sample.xlsx")
print(madato.spreadsheet_to_md(str(my_sample_spreadsheet)))
```
* For more examples see [pysource/tests](pysource/tests)

## More Commandline

Expand Down Expand Up @@ -163,7 +181,9 @@ If you omit the sheet name, it will dump all sheets into an order map of array o
* `[X]` Native Binary Command Line (windows, linux, osx)
* `[X]` Read an XLSX file and produce a Markdown Table
* `[X]` Read an ODS file and produce a Markdown Table
* `[ ]` Read a CSV, TSV, PSV (etc) file and produce a Markdown Table
* `[X]` Read a CSV
* `[X]` Published as a Python Module
* `[ ]` TSV, PSV (etc) file and produce a Markdown Table
* `[ ]` Support Nested Structures in the YAML input
* `[ ]` Read a Markdown File, and select the "table" and turn it back into YAML

Expand Down
1,440 changes: 1,421 additions & 19 deletions examples/sample_notebook.ipynb

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions madato_cmd/Cargo.toml

This file was deleted.

21 changes: 0 additions & 21 deletions madato_py/Cargo.toml

This file was deleted.

7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,9 @@ Changelog = 'https://github.com/inosion/madato/releases'


[tool.maturin]
# module-name = "madato.madato"
bindings = 'pyo3'
python-source = "pysource"
features = ["pyo3/extension-module"]

# include = [
# { format = "sdist", path = "Cargo.lock" },
# ]
features = ["pyo3/extension-module", "python"]

[tool.pytest.ini_options]
testpaths = "pysource/tests"
Expand Down
81 changes: 0 additions & 81 deletions pysource/madato/madato.pyi

This file was deleted.

10 changes: 9 additions & 1 deletion pysource/tests/test_csv.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# csv_file_to_md
# csv_to_md
# spreadsheet_to_csv
# spreadsheet_to_csv

from madato import csv_to_md

def test_csv_to_md(artists_csv_str):
headers = """| name |age|genre|albums_sold|hometown |active| label |"""
md = csv_to_md(artists_csv_str)
assert md.startswith(headers)

11 changes: 11 additions & 0 deletions pysource/tests/test_xlsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest
from pathlib import Path
from madato import spreadsheet_to_md


def test_xlsx_to_md():
this_dir = Path(__file__).parent
my_sample_spreadsheet = this_dir / Path("../../test/Financial Sample.xlsx")
md = spreadsheet_to_md(str(my_sample_spreadsheet))
headers = "| Segment | Country | Product |Discount Band|Units Sold|Manufacturing Price|Sale Price|Gross Sales| Discounts | Sales | COGS | Profit |Date |Month Number|Month Name|Year|"
assert md.startswith(headers)
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod yaml;
#[cfg(feature = "spreadsheets")]
pub mod cal;

#[cfg(feature = "python")]
pub mod py;

use indexmap::IndexSet;
Expand Down

0 comments on commit 92aaf59

Please sign in to comment.