Skip to content

Commit

Permalink
Merge pull request #86 from fslaborg/python
Browse files Browse the repository at this point in the history
Python Integration
  • Loading branch information
HLWeil committed Mar 7, 2024
2 parents b99cd4e + b85ca85 commit d652834
Show file tree
Hide file tree
Showing 95 changed files with 1,356 additions and 430 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
},
"fable": {
"version": "4.1.3",
"version": "4.13.0",
"commands": [
"fable"
]
Expand Down
67 changes: 41 additions & 26 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,63 @@ on:
branches: [ main ]

jobs:
build-and-test-linux:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

# SETUP .NET
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x.x
- name: Restore fable
run: dotnet tool restore

# SETUP NODE
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16
- name: install node modules
run: npm install
- name: make script executable
run: chmod u+x build.sh
- name: Build and test dotnet
working-directory: ./
run: ./build.sh runtests

build-and-test-windows:

runs-on: windows-latest
run: npm install --ignore-scripts

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x.x
- name: Restore fable
run: dotnet tool restore
- name: Setup Node.js environment
uses: actions/setup-node@v3
# SETUP PYTHON
- name: Setup Python
uses: actions/setup-python@v5
with:
node-version: 16
- name: install node modules
run: npm install
- name: Build and test dotnet
python-version: '3.11'
- name: Setup Virtual Environment
run: python -m venv .venv
- name: Setup Poetry Windows
if: matrix.os == 'windows-latest'
run: |
.\.venv\Scripts\python.exe -m pip install -U pip setuptools
.\.venv\Scripts\python.exe -m pip install poetry
.\.venv\Scripts\python.exe -m poetry install --no-root
- name: Setup Poetry Unix
if: matrix.os == 'ubuntu-latest'
run: |
./.venv/bin/python -m pip install -U pip setuptools
./.venv/bin/python -m pip install poetry
./.venv/bin/python -m poetry install --no-root
# BUILD
- name: make script executable
if: matrix.os == 'ubuntu-latest'
run: chmod u+x build.sh
- name: Test (Unix)
if: matrix.os == 'ubuntu-latest'
working-directory: ./
run: ./build.cmd runtests
run: ./build.sh runtests
- name: Test (Windows)
if: matrix.os == 'windows-latest'
run: .\build.cmd runtests
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,15 @@ tmp/
output/
.fsdocs/
/tests/FsSpreadsheet.JsNativeTests/fable/**/*.js
**/TestFiles/WRITE_*.xlsx
/tests/FsSpreadsheet.Net.Tests/TestFiles/WRITE_*.xlsx
/tests/JS/TestFiles/WRITE_*.xlsx
/tests/TestUtils/TestFiles/TestWorkbook_FsSpreadsheet_WRITE.*.xlsx
/js
**/py/**
/.venv
/tests/FsSpreadsheet.Tests/js
/tests/JS/fable
/tests/JS/FsSpreadsheet.Exceljs
/tests/FsSpreadsheet.Exceljs.Tests/js
/tests/JS/FsSpreadsheet.Js
/tests/FsSpreadsheet.Js.Tests/js
/dist
/tests/TestUtils/TestFiles/Scripts/fable
153 changes: 92 additions & 61 deletions FsSpreadsheet.sln

Large diffs are not rendered by default.

45 changes: 34 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FsSpreadsheet
# FsSpreadsheet
Spreadsheet creation and manipulation in FSharp

## DSL
Expand Down Expand Up @@ -65,28 +65,51 @@ tables
```


## Develop
## Development

### Build QuickStart
### Requirements

If not already done,
1. install .NET SDK
2. install Node.js
- [nodejs and npm](https://nodejs.org/en/download)
- verify with `node --version` (Tested with v18.16.1)
- verify with `npm --version` (Tested with v9.2.0)
- [.NET SDK](https://dotnet.microsoft.com/en-us/download)
- verify with `dotnet --version` (Tested with 7.0.306)
- [Python](https://www.python.org/downloads/)
- verify with `py --version` (Tested with 3.12.2)

### Local Setup

1. Setup dotnet tools

`dotnet tool restore`

2. Install NPM dependencies

`npm install`

3. Setup python environment

`py -m venv .venv`

4. Install [Poetry](https://python-poetry.org/) and dependencies

1. `.\.venv\Scripts\python.exe -m pip install -U pip setuptools`
2. `.\.venv\Scripts\python.exe -m pip install poetry`
3. `.\.venv\Scripts\python.exe -m poetry install --no-root`

Verify correct setup with `./build.cmd runtests`

In any shell, run
1. `dotnet tool restore`
4. `npm install`
5. `build.cmd <target>` where `<target>` may be
- if `<target>` is empty, it just runs dotnet build after cleaning everything
- `runtests` to run unit tests
- `runtestsjs` to only run JS unit tests
- `runtestsdotnet` to only run .NET unit tests
- `runtestpy` to only run Python unit tests
- `releasenotes semver:<version>` where `<version>` may be `major`, `minor`, or `patch` to update RELEASE_NOTES.md
- `pack` to create a NuGet release
- `packprelease` to create a NuGet prerelease
- `builddocs` to create docs
- `builddocsprerelease` to create prerelease docs
- `watchdocs` to create docs and run them locally
- `watchdocsprelease` to create prerelease docs and run them locally
- `publishnuget` to create a NuGet release and publish it
- `publishnugetprelease` to create a NuGet prerelease and publish it
- `release` to create a NuGet, NPM, PyPI and GitHub release
18 changes: 15 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### 5.2.0+bbba6d4 (Released 2024-2-23)
* Additions:
* [[#bbba6d4](https://github.com/CSBiology/FsSpreadsheet/commit/bbba6d4ab819900f5188af3b5663d4744061991a)] start setup of python package
* [[#80dd1b6](https://github.com/CSBiology/FsSpreadsheet/commit/80dd1b608e46e7cda7646ea7c39619c0c7738f8e)] add tests for python xlsx io
* [[#992fa5a](https://github.com/CSBiology/FsSpreadsheet/commit/992fa5ac485313efc71285347b156b83614585d0)] add python xlsx io support
* [[#ddcc16d](https://github.com/CSBiology/FsSpreadsheet/commit/ddcc16dbdc51da516f53cbc3192d114584bd73fb)] add runtestspy target
* [[#d69288a](https://github.com/CSBiology/FsSpreadsheet/commit/d69288a33f1a259987cf4c229671723eaaf5beb2)] switch to pyxpecto for testing
* [[#2b88258](https://github.com/CSBiology/FsSpreadsheet/commit/2b882586b12aae0500eaad98d01603521dfee26f)] small speed improvement of reader by skipping sst include on opendocument cell
* Bugfixes:
* [[#b35f309](https://github.com/CSBiology/FsSpreadsheet/commit/b35f30908a4a68d8e3870c30cb8ace2dde748a7b)] finalize python xlsx io test and fixes
* [[#a55336e](https://github.com/CSBiology/FsSpreadsheet/commit/a55336ec03d5d2f1a254d2908d06d9b5381c7d55)] fix python xlsx io for default formats

### 5.1.3+a260549 (Released 2024-2-13)
* Additions:
* [[#a260549](https://github.com/CSBiology/FsSpreadsheet/commit/a26054928881975896f2c07926261091979216a4)] update tests to change in empty workbook handling
Expand Down Expand Up @@ -42,7 +54,7 @@
* [[#c5bf348](https://github.com/CSBiology/FsSpreadsheet/commit/c5bf34808d105723738dde53e6cb778a2b97da3e)] Finish io tests :heavy_check_mark:
* [[#80f7632](https://github.com/CSBiology/FsSpreadsheet/commit/80f7632b2a4865951f144fc271e02a2ee4f6989c)] Improve DateTime numberFormat recognition
* [[#baa88ce](https://github.com/CSBiology/FsSpreadsheet/commit/baa88ceb185c43302c8e7742ba8fe1afab893739)] update libre test file
* [[#9805811](https://github.com/CSBiology/FsSpreadsheet/commit/980581193cdcceaa80cd87f91e86121726c1046f)] Setup current FsSpreadsheet.Exceljs write for defaultio tests :construction:
* [[#9805811](https://github.com/CSBiology/FsSpreadsheet/commit/980581193cdcceaa80cd87f91e86121726c1046f)] Setup current FsSpreadsheet.Js write for defaultio tests :construction:
* [[#05e0ca4](https://github.com/CSBiology/FsSpreadsheet/commit/05e0ca492e3ae54cdaf6fdec4c19c1296614e565)] update gitignore
* [[#2b99506](https://github.com/CSBiology/FsSpreadsheet/commit/2b99506e9abafd7d579d8e3f09fb59d7e20a8398)] Further work on #71 change FsCell.Value to obj :boom:
* [[#546e029](https://github.com/CSBiology/FsSpreadsheet/commit/546e02962c5d18127e143d85705523a4163d63c2)] add stylesheet helper functions
Expand Down Expand Up @@ -112,11 +124,11 @@
* [[#95c5d16](https://github.com/CSBiology/FsSpreadsheet/commit/95c5d167403cb5a3323782b2e6895c66c9f1ebd8)] Push WIP state
* [[#58b57ae](https://github.com/CSBiology/FsSpreadsheet/commit/58b57ae74d7d5d98e6146c75ce31eb819c0ed5d9)] Start refactoring to resizeArray :hammer:#53
* [[#5ed3752](https://github.com/CSBiology/FsSpreadsheet/commit/5ed37521a61683dfb6f6240a1c807474f50b9574)] Specify code snippet
* [[#4a9ff2e](https://github.com/CSBiology/FsSpreadsheet/commit/4a9ff2e91cf16c3d7d5587937f9c97d0c348e967)] Initiate test setup for FsSpreadsheet.Exceljs
* [[#4a9ff2e](https://github.com/CSBiology/FsSpreadsheet/commit/4a9ff2e91cf16c3d7d5587937f9c97d0c348e967)] Initiate test setup for FsSpreadsheet.Js
* [[#d785795](https://github.com/CSBiology/FsSpreadsheet/commit/d785795061967c0206855983eebf49f1f182fe86)] Finish Api for both f# fable access and js native :sparkles:
* [[#1456337](https://github.com/CSBiology/FsSpreadsheet/commit/1456337f88c8af863fb24bf134a93580ef5ed8b6)] update gitignore
* [[#97f712c](https://github.com/CSBiology/FsSpreadsheet/commit/97f712cfe1d8422835a50c0186e28fc5cd2fcc4a)] setup msbuild
* [[#efa9815](https://github.com/CSBiology/FsSpreadsheet/commit/efa981573a24015d110a70c2e306e2678a5a36d5)] Init FsSpreadsheet.Exceljs and add Fable.Exceljs dependency
* [[#efa9815](https://github.com/CSBiology/FsSpreadsheet/commit/efa981573a24015d110a70c2e306e2678a5a36d5)] Init FsSpreadsheet.Js and add Fable.Exceljs dependency
* [[#c4fdce6](https://github.com/CSBiology/FsSpreadsheet/commit/c4fdce69ea59a6a7da12fd190249a8e2f8d43136)] improve testsuit
* [[#33eb847](https://github.com/CSBiology/FsSpreadsheet/commit/33eb84701d24d145cef5801966bf25844a8a7931)] cleanup test tasks
* [[#3116aae](https://github.com/CSBiology/FsSpreadsheet/commit/3116aae6831fddcccc552d9d68b1bf4a565578ec)] Add dotnet tool femto
Expand Down
4 changes: 4 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
@echo off

set PYTHONIOENCODING=utf-8
dotnet tool restore
cls
dotnet run --project ./build/build.fsproj %*
10 changes: 9 additions & 1 deletion build/BasicTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ module Helper =

createProcess npmPath

let python =
if System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows) then
Fake.Core.Trace.log "Detected Windows System."
createProcess (__SOURCE_DIRECTORY__.Replace(@"\build",@"\.venv\Scripts\python.exe"))
else
Fake.Core.Trace.log "Detected Unix System."
createProcess (__SOURCE_DIRECTORY__.Replace(@"/build",@"/.venv/bin/python"))

let run proc arg dir =
proc arg dir
|> Proc.run
Expand All @@ -117,7 +125,7 @@ let clean = BuildTask.create "Clean" [] {
++ "src/**/obj"
++ "tests/**/bin"
++ "tests/**/obj"
++ "pkg"
++ "dist"
|> Shell.cleanDirs
}

Expand Down
2 changes: 1 addition & 1 deletion build/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open ReleaseTasks
let _release =
BuildTask.createEmpty
"Release"
[clean; build; runTests; pack; buildDocs; createTag; publishNuget; publishNPM; releaseDocs]
[clean; build; runTests; pack; buildDocs; createTag; publishNuget; publishNPM; publishPyPi; releaseDocs]

/// Full release of nuget package, git tag, and documentation for the prerelease version.
let _preRelease =
Expand Down
Loading

0 comments on commit d652834

Please sign in to comment.