diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2304a4..19c4447 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,10 +12,12 @@ jobs: platform: [windows-latest, macos-latest, ubuntu-latest] runs-on: ${{matrix.platform}} + env: + GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v3 with: - submodules: true + submodules: recursive - uses: messense/maturin-action@v1 with: command: build diff --git a/.github/workflows/test_pr.yml b/.github/workflows/test_pr.yml index 4980c22..26bb377 100644 --- a/.github/workflows/test_pr.yml +++ b/.github/workflows/test_pr.yml @@ -21,6 +21,8 @@ jobs: permissions: actions: write + env: + GH_TOKEN: ${{ github.token }} steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.11.0 @@ -29,7 +31,7 @@ jobs: - uses: actions/checkout@v3 with: - submodules: true + submodules: recursive - name: Set up Python ${{ matrix.python }} uses: actions/setup-python@v4 @@ -39,7 +41,7 @@ jobs: - name: Install run: | pip install --upgrade pip - pip install -e .[testing] + pip install -e '.[testing]' - name: Test run: | diff --git a/.github/workflows/test_pr_dcam.yml b/.github/workflows/test_pr_dcam.yml index e84cc55..7eac130 100644 --- a/.github/workflows/test_pr_dcam.yml +++ b/.github/workflows/test_pr_dcam.yml @@ -19,6 +19,8 @@ jobs: permissions: actions: write + env: + GH_TOKEN: ${{ github.token }} steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.11.0 @@ -27,7 +29,7 @@ jobs: - uses: actions/checkout@v3 with: - submodules: true + submodules: recursive - name: Get CMake 3.24 uses: lukka/get-cmake@latest diff --git a/.github/workflows/test_pr_egrabber.yml b/.github/workflows/test_pr_egrabber.yml index 6385eb6..7482484 100644 --- a/.github/workflows/test_pr_egrabber.yml +++ b/.github/workflows/test_pr_egrabber.yml @@ -19,6 +19,8 @@ jobs: permissions: actions: write + env: + GH_TOKEN: ${{ github.token }} steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.11.0 @@ -27,7 +29,7 @@ jobs: - uses: actions/checkout@v3 with: - submodules: true + submodules: recursive - name: Get CMake 3.24 uses: lukka/get-cmake@latest diff --git a/.github/workflows/test_typing.yml b/.github/workflows/test_typing.yml index 826697d..5e38b91 100644 --- a/.github/workflows/test_typing.yml +++ b/.github/workflows/test_typing.yml @@ -8,10 +8,12 @@ on: jobs: typing: runs-on: windows-latest + env: + GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v3 with: - submodules: true + submodules: recursive - name: Set up Python 3.10 uses: actions/setup-python@v4 diff --git a/.gitignore b/.gitignore index b5e740d..64e3b95 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ Testing *.zarr *.tif *.json +Cargo.lock # Byte-compiled / optimized / DLL files __pycache__/ @@ -82,3 +83,6 @@ docs/_build/ # mypy stubgen out/ + +# dotenv +.env \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index af99c36..dd334aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,15 +2,3 @@ path = acquire-video-runtime url = ../acquire-video-runtime.git branch = main -[submodule "acquire-driver-zarr"] - path = acquire-driver-zarr - url = ../acquire-driver-zarr.git -[submodule "acquire-driver-hdcam"] - path = acquire-driver-hdcam - url = ../acquire-driver-hdcam -[submodule "acquire-driver-egrabber"] - path = acquire-driver-egrabber - url = ../acquire-driver-egrabber -[submodule "acquire-driver-common"] - path = acquire-driver-common - url = ../acquire-driver-common diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 0bca340..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,582 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "acquire-python" -version = "0.1.0" -dependencies = [ - "anyhow", - "bindgen", - "cmake", - "log", - "numpy", - "parking_lot", - "pyo3", - "pyo3-log", - "pythonize", - "serde", -] - -[[package]] -name = "anyhow" -version = "1.0.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" - -[[package]] -name = "arc-swap" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bindgen" -version = "0.64.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" -dependencies = [ - "bitflags", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn", - "which", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "cc" -version = "1.0.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clang-sys" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" -dependencies = [ - "glob", - "libc", - "libloading", -] - -[[package]] -name = "cmake" -version = "0.1.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" -dependencies = [ - "cc", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - -[[package]] -name = "indoc" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a0bd019339e5d968b37855180087b7b9d512c5046fbd244cf8c95687927d6e" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - -[[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "libloading" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "lock_api" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "matrixmultiply" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" -dependencies = [ - "rawpointer", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "ndarray" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec23e6762830658d2b3d385a75aa212af2f67a4586d4442907144f3bb6a1ca8" -dependencies = [ - "matrixmultiply", - "num-complex", - "num-integer", - "num-traits", - "rawpointer", -] - -[[package]] -name = "nom" -version = "7.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "num-complex" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "numpy" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0fee4571867d318651c24f4a570c3f18408cf95f16ccb576b3ce85496a46e" -dependencies = [ - "libc", - "ndarray", - "num-complex", - "num-integer", - "num-traits", - "pyo3", - "rustc-hash", -] - -[[package]] -name = "once_cell" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "proc-macro2" -version = "1.0.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "pyo3" -version = "0.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b1ac5b3731ba34fdaa9785f8d74d17448cd18f30cf19e0c7e7b1fdb5272109" -dependencies = [ - "anyhow", - "cfg-if", - "indoc", - "libc", - "memoffset", - "parking_lot", - "pyo3-build-config", - "pyo3-ffi", - "pyo3-macros", - "serde", - "unindent", -] - -[[package]] -name = "pyo3-build-config" -version = "0.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" -dependencies = [ - "once_cell", - "target-lexicon", -] - -[[package]] -name = "pyo3-ffi" -version = "0.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" -dependencies = [ - "libc", - "pyo3-build-config", -] - -[[package]] -name = "pyo3-log" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9c8b57fe71fb5dcf38970ebedc2b1531cf1c14b1b9b4c560a182a57e115575c" -dependencies = [ - "arc-swap", - "log", - "pyo3", -] - -[[package]] -name = "pyo3-macros" -version = "0.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d39c55dab3fc5a4b25bbd1ac10a2da452c4aca13bb450f22818a002e29648d" -dependencies = [ - "proc-macro2", - "pyo3-macros-backend", - "quote", - "syn", -] - -[[package]] -name = "pyo3-macros-backend" -version = "0.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pythonize" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a0e1bbcd2a3856284bf4f4ef09ccb1157e9467847792754556f153ea3fe6b42" -dependencies = [ - "pyo3", - "serde", -] - -[[package]] -name = "quote" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "redox_syscall" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "serde" -version = "1.0.137" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.137" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "shlex" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" - -[[package]] -name = "smallvec" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "target-lexicon" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" - -[[package]] -name = "unicode-ident" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" - -[[package]] -name = "unindent" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52fee519a3e570f7df377a06a1a7775cdbfb7aa460be7e08de2b1f0e69973a44" - -[[package]] -name = "which" -version = "4.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" -dependencies = [ - "either", - "lazy_static", - "libc", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" diff --git a/Cargo.toml b/Cargo.toml index 9a70ce1..662d797 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,9 +4,6 @@ authors = ["Nathan Clack "] version = "0.1.0" edition = "2021" -[package.metadata.maturin] -python-source = "python" - [lib] name = "acquire" crate-type = ["cdylib"] @@ -27,5 +24,10 @@ serde = { version = "1.0", features = ["derive"] } pythonize = "0.18" [build-dependencies] -bindgen = "0.64" +bindgen = "0.65" cmake = "0.1" +dotenv = "0.15" +http = "0.2" +reqwest = { version = "0.11", features = ["blocking", "json"] } +serde = { version = "1.0", features = ["derive"] } +zip-extract = "0.1" diff --git a/README.md b/README.md index b7de322..c91d0c3 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,19 @@ conda create --name acquire python=3.11 conda activate acquire ``` +The build script also looks for a GitHub personal access token in the environment variable `GH_TOKEN`. +You can set this on the command line, or in a .env file in the root directory of this repository. +Your .env file might look like, for example: + +```dotenv +GH_TOKEN=[your token here] +``` + ## Build ```bash -git submodule update --init +git submodule update --init --recursive cd acquire-video-runtime -git submodule update --init pip install build python -m build ``` diff --git a/acquire-driver-common b/acquire-driver-common deleted file mode 160000 index 4159c15..0000000 --- a/acquire-driver-common +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4159c15297010d517461fa4be163109fd05f12e8 diff --git a/acquire-driver-egrabber b/acquire-driver-egrabber deleted file mode 160000 index 4ecf6c2..0000000 --- a/acquire-driver-egrabber +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4ecf6c23b03a006a945e5b514c96a719f063f63e diff --git a/acquire-driver-hdcam b/acquire-driver-hdcam deleted file mode 160000 index e1bbec5..0000000 --- a/acquire-driver-hdcam +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e1bbec5756b60314c1fc0dbaabf910a2bf9eb2dc diff --git a/acquire-driver-zarr b/acquire-driver-zarr deleted file mode 160000 index f9ac6f7..0000000 --- a/acquire-driver-zarr +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f9ac6f729810136bc96311ca001474e0c9a89f43 diff --git a/acquire-video-runtime b/acquire-video-runtime index 45d41ca..9b9c215 160000 --- a/acquire-video-runtime +++ b/acquire-video-runtime @@ -1 +1 @@ -Subproject commit 45d41ca26ef2435ef225d21dcd5ea6fa470251f3 +Subproject commit 9b9c215938f7cc61057cfc620dc15b0a49dfeb0d diff --git a/build.rs b/build.rs index a485705..5bd6054 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,48 @@ +use dotenv::dotenv; +use serde::Deserialize; +use std::env; +use std::io::{prelude::*, Cursor}; + +/// Component of the `Artifact` JSON object returned from the GitHub API. +#[allow(dead_code)] +#[derive(Deserialize, Clone)] +struct WorkFlowRun { + id: i128, + repository_id: i128, + head_repository_id: i128, + head_branch: String, + head_sha: String, +} + +/// Metadata for a build artifact from given commit to a given repository, returned from GitHub API. +#[allow(dead_code)] +#[derive(Deserialize, Clone)] +struct Artifact { + id: i128, + node_id: String, + name: String, + size_in_bytes: i64, + url: String, + archive_download_url: String, + expired: bool, + created_at: String, + updated_at: String, + expires_at: String, + workflow_run: WorkFlowRun, +} + +/// List of build artifacts for a given repository, returned from GitHub API. +#[allow(dead_code)] +#[derive(Deserialize, Clone)] +struct ArtifactsResponse { + total_count: u32, + artifacts: Vec, +} + fn main() { - let dst = cmake::Config::new("acquire-video-runtime") + dotenv().ok(); + + let dst = dbg!(cmake::Config::new("acquire-video-runtime") .target("acquire-video-runtime") .profile("RelWithDebInfo") .static_crt(true) @@ -7,12 +50,29 @@ fn main() { .define("NO_UNIT_TESTS", "TRUE") .define("NO_EXAMPLES", "TRUE") .define("CMAKE_OSX_DEPLOYMENT_TARGET", "10.15") - .build(); + .build()); - build_acquire_driver(&dst, "acquire-driver-common"); - build_acquire_driver(&dst, "acquire-driver-egrabber"); - build_acquire_driver(&dst, "acquire-driver-hdcam"); - build_acquire_driver(&dst, "acquire-driver-zarr"); + let out = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); + fetch_acquire_driver( + &out, + "acquire-driver-common", + "f0b1a585b40ba320445acc6142c3196fe0260702", + ); + fetch_acquire_driver( + &out, + "acquire-driver-zarr", + "202c87b87f1f69df3f01ee0c0b47023a9982dfb5", + ); + fetch_acquire_driver( + &out, + "acquire-driver-egrabber", + "5d420b4f26479ce4c4fa329342fd0fe77642842e", + ); + fetch_acquire_driver( + &out, + "acquire-driver-hdcam", + "d94ee9bc023d6f7943e2340d74de974d1e2c5726", + ); println!("cargo:rustc-link-search=native={}/lib", dst.display()); println!("cargo:rustc-link-lib=static=acquire-video-runtime"); @@ -33,23 +93,36 @@ fn main() { .generate() .expect("Unable to generate bindings"); - let out = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); bindings .write_to_file(out.join("bindings.rs")) .expect("Failed to write bindings."); } -fn build_acquire_driver(dst: &std::path::PathBuf, name: &str) { - cmake::Config::new(name) - .target(name) - .profile("RelWithDebInfo") - .static_crt(true) - .define("NOTEST", "TRUE") - .define("NO_UNIT_TESTS", "TRUE") - .define("NO_EXAMPLES", "TRUE") - .define("CMAKE_OSX_DEPLOYMENT_TARGET", "10.15") - .build(); - copy_acquire_driver(dst, name); +fn fetch_acquire_driver(dst: &std::path::PathBuf, name: &str, sha: &str) { + let build = if cfg!(target_os = "windows") { + if name.ends_with("egrabber") || name.ends_with("hdcam") { + "Release binaries" + } else { + "windows-latest Release binaries" + } + } else if cfg!(target_os = "macos") { + "macos-latest Release binaries" + } else if cfg!(target_os = "linux") { + "ubuntu-latest Release binaries" + } else { + panic!("Unknown target os") + }; + + let token = env::var("GH_TOKEN") + .expect("Could not find environment variable GH_TOKEN.") + .to_owned(); + + let artifact = fetch_driver_artifact_metadata(name, build, sha, token.as_str()); + let extracted_archive_path = + fetch_and_extract_artifact_archive(&dst, &artifact, token.as_str()); + extract_inner_archive(dst, &extracted_archive_path); + + copy_acquire_driver(&dst, name); } fn copy_acquire_driver(dst: &std::path::PathBuf, name: &str) { @@ -69,5 +142,89 @@ fn copy_acquire_driver(dst: &std::path::PathBuf, name: &str) { format!("{}/lib/{lib}", dst.display()), format!("python/acquire/{lib}"), ) - .expect(&format!("Failed to copy {lib} to python folder.")); + .expect(&format!( + "Failed to copy {}/lib/{lib} to python folder.", + dst.display() + )); +} + +fn fetch_driver_artifact_metadata(name: &str, build: &str, sha: &str, token: &str) -> Artifact { + let client = reqwest::blocking::Client::builder() + .user_agent("acquire-project/builder") + .build() + .unwrap(); + + // list out build artifacts for this driver + let uri = format!("https://github.com/gitapi/repos/acquire-project/{name}/actions/artifacts"); + + let request = client + .get(uri) + .header("Accept", "application/vnd.github+json") + .header("X-GitHub-Api-Version", "2022-11-28") + .header("Authorization", format!("Bearer {token}")); + + let response = match request.send() { + Ok(r) => r, + Err(err) => panic!("HTTP request for {} failed, got {}", name, err), + }; + + let artifacts = response.json::().unwrap().artifacts; + + artifacts + .iter() + .filter(|a| a.workflow_run.head_sha == sha) + .find(|a| a.name == build) + .expect( + format!( + "Could not find an artifact with sha {} and name '{}' for driver {}", + sha, build, name + ) + .as_str(), + ) + .to_owned() +} + +fn fetch_and_extract_artifact_archive( + dst: &std::path::PathBuf, + artifact: &Artifact, + token: &str, +) -> std::path::PathBuf { + let client = reqwest::blocking::Client::builder() + .user_agent("acquire-project/builder") + .build() + .unwrap(); + + let request = client + .get(&artifact.archive_download_url) + .header("Accept", "application/vnd.github+json") + .header("X-GitHub-Api-Version", "2022-11-28") + .header("Authorization", format!("Bearer {token}")); + + let archive = match request.send() { + Ok(r) => r.bytes().unwrap(), + Err(err) => panic!("HTTP request for {} failed, got {}", &artifact.name, err), + }; + + let target_dir = std::path::PathBuf::from(dst.join(&artifact.name)); + zip_extract::extract(Cursor::new(archive), &target_dir, true).unwrap(); + + target_dir +} + +fn extract_inner_archive(dst: &std::path::PathBuf, extracted_archive_path: &std::path::PathBuf) { + let dir_iterator = std::fs::read_dir(extracted_archive_path).unwrap(); + let dir_entry = dir_iterator.last().unwrap().expect( + format!( + "No entries in {}", + extracted_archive_path.as_path().to_str().unwrap() + ) + .as_str(), + ); + + let inner_path = extracted_archive_path.join(dir_entry.file_name()); + let mut inner_file = std::fs::File::open(&inner_path).unwrap(); + + let mut bytes = vec![]; + inner_file.read_to_end(&mut bytes).unwrap(); + zip_extract::extract(Cursor::new(bytes), &dst, true).unwrap(); } diff --git a/pyproject.toml b/pyproject.toml index ba21315..2becc59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,11 @@ acquire-python = [ "acquire.pyi", ] +[tool.maturin] +python-source = "python" +python-packages = ["acquire"] +include = ["**/*/*.so", "**/*/*.dll"] + [tool.black] target-version = ['py39', 'py310', 'py311'] line-length = 79 diff --git a/python/acquire/acquire.pyi b/python/acquire/acquire.pyi index df9b8ea..998faaa 100644 --- a/python/acquire/acquire.pyi +++ b/python/acquire/acquire.pyi @@ -112,20 +112,18 @@ class Direction: def __lt__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... +@final class InputTriggers: acquisition_start: Trigger exposure: Trigger frame_start: Trigger - @classmethod - def __init__(cls, *args: None, **kwargs: Any) -> None: ... def dict(self) -> Dict[str, Any]: ... +@final class OutputTriggers: exposure: Trigger frame_start: Trigger trigger_wait: Trigger - @classmethod - def __init__(cls, *args: None, **kwargs: Any) -> None: ... def dict(self) -> Dict[str, Any]: ... @final @@ -146,7 +144,7 @@ class Properties: class Runtime: def __init__(self, *args: None, **kwargs: Any) -> None: ... def device_manager(self) -> DeviceManager: ... - def get_available_data(self, stream_id: int) -> AvailableData: ... + def get_available_data(self, istream: int) -> AvailableData: ... def get_configuration(self) -> Properties: ... def get_state(self) -> DeviceState: ... def set_configuration(self, properties: Properties) -> Properties: ... @@ -179,11 +177,6 @@ class SampleType: def __lt__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... -@final -class Signals: - identifier: Optional[DeviceIdentifier] - settings: SignalProperties - def dict(self) -> Dict[str, Any]: ... @final class SignalIOKind: diff --git a/src/camera.rs b/src/camera.rs index 801308b..0f5a881 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -128,16 +128,22 @@ pub struct CameraProperties { shape: (u32, u32), #[pyo3(get, set)] - input_triggers: InputTriggers, + input_triggers: Py, #[pyo3(get, set)] - output_triggers: OutputTriggers, + output_triggers: Py, } impl_plain_old_dict!(CameraProperties); impl Default for CameraProperties { fn default() -> Self { + let (input_triggers, output_triggers) = Python::with_gil(|py| { + ( + Py::new(py, InputTriggers::default()).unwrap(), + Py::new(py, OutputTriggers::default()).unwrap(), + ) + }); Self { exposure_time_us: Default::default(), line_interval_us: Default::default(), @@ -146,8 +152,8 @@ impl Default for CameraProperties { pixel_type: Default::default(), offset: Default::default(), shape: (1920, 1080), - input_triggers: Default::default(), - output_triggers: Default::default(), + input_triggers, + output_triggers, } } } @@ -156,6 +162,11 @@ impl TryFrom for CameraProperties { type Error = anyhow::Error; fn try_from(value: capi::CameraProperties) -> Result { + let (input_triggers, output_triggers) = Python::with_gil(|py| -> PyResult<_> { + let tr_in: InputTriggers = value.input_triggers.try_into()?; + let tr_out: OutputTriggers = value.output_triggers.try_into()?; + Ok((Py::new(py, tr_in)?, Py::new(py, tr_out)?)) + })?; Ok(CameraProperties { exposure_time_us: value.exposure_time_us, line_interval_us: value.line_interval_us, @@ -164,8 +175,8 @@ impl TryFrom for CameraProperties { pixel_type: value.pixel_type.try_into()?, offset: (value.offset.x, value.offset.y), shape: (value.shape.x, value.shape.y), - input_triggers: value.input_triggers.try_into()?, - output_triggers: value.output_triggers.try_into()?, + input_triggers, + output_triggers, }) } } @@ -182,6 +193,11 @@ impl TryFrom<&CameraProperties> for capi::CameraProperties { x: src.shape.0, y: src.shape.1, }; + let (input_triggers, output_triggers) = Python::with_gil(|py| -> PyResult<_> { + let input_triggers: InputTriggers = src.input_triggers.extract(py)?; + let output_triggers: OutputTriggers = src.output_triggers.extract(py)?; + Ok((input_triggers, output_triggers)) + })?; Ok(capi::CameraProperties { exposure_time_us: src.exposure_time_us, line_interval_us: src.line_interval_us, @@ -190,8 +206,8 @@ impl TryFrom<&CameraProperties> for capi::CameraProperties { pixel_type: src.pixel_type.into(), offset, shape, - input_triggers: src.input_triggers.as_ref().try_into()?, - output_triggers: src.output_triggers.as_ref().try_into()?, + input_triggers: (&input_triggers).try_into()?, + output_triggers: (&output_triggers).try_into()?, }) } } diff --git a/tests/test_dcam.py b/tests/test_dcam.py index 729fdee..d51537a 100644 --- a/tests/test_dcam.py +++ b/tests/test_dcam.py @@ -2,7 +2,7 @@ import acquire import pytest -from acquire import DeviceKind, SampleType, TriggerEvent +from acquire import DeviceKind, SampleType @pytest.fixture(scope="module") @@ -33,14 +33,10 @@ def test_ext_triggering(runtime: acquire.Runtime): # Set the camera here so we can query it's triggering capabilities. # This comes in the form of the returned properties. - p = runtime.set_configuration(p) - - p.video[0].camera.settings.triggers[1].enable = True - p.video[0].camera.settings.triggers[1].event = TriggerEvent.FrameStart + p.video[0].camera.settings.input_triggers.frame_start = acquire.Trigger( + enable=True, line=0, edge="Rising" + ) # Call set_configuration() again to apply the trigger properties p = runtime.set_configuration(p) - - assert p.video[0].camera.settings.triggers[1].enable is True - assert ( - p.video[0].camera.settings.triggers[1].event == TriggerEvent.FrameStart - ) + # Check that it was accepted + assert p.video[0].camera.settings.input_triggers.frame_start.enable is True diff --git a/tests/test_egrabber.py b/tests/test_egrabber.py index 4e0bf9f..713084e 100644 --- a/tests/test_egrabber.py +++ b/tests/test_egrabber.py @@ -4,7 +4,7 @@ import acquire import pytest from acquire import DeviceKind, SampleType -from acquire.acquire import TriggerEdge +from acquire.acquire import SignalIOKind, Trigger, TriggerEdge @pytest.fixture(scope="module") @@ -62,40 +62,39 @@ def test_vieworks_configure_triggering(runtime: acquire.Runtime): p = runtime.set_configuration(p) - # There are two defined lines: Line0, and Software - assert len(p.video[0].camera.settings.triggers) == 2 - # When the camera is first selected, triggers should be disabled - assert not p.video[0].camera.settings.triggers[0].enable - assert not p.video[0].camera.settings.triggers[1].enable + assert not p.video[0].camera.settings.input_triggers.frame_start.enable # # Enable Line0: # # There's really own two things to set. On the VP-151MX, there's only # one kind of event that can be triggered - the frame exposure start. - p.video[0].camera.settings.triggers[0].enable = True - p.video[0].camera.settings.triggers[0].edge = TriggerEdge.Rising + p.video[0].camera.settings.input_triggers.frame_start = Trigger( + enable=True, line=0, edge="Rising" + ) + assert p.video[0].camera.settings.input_triggers.frame_start.enable p = runtime.set_configuration(p) - assert p.video[0].camera.settings.triggers[0].enable - assert not p.video[0].camera.settings.triggers[1].enable + assert p.video[0].camera.settings.input_triggers.frame_start.enable + assert p.video[0].camera.settings.input_triggers.frame_start.line == 0 # # Enable Software triggering: # # There's really own two things to set. On the VP-151MX, there's only # one kind of event that can be triggered - the frame exposure start. - p.video[0].camera.settings.triggers[1].enable = True - p.video[0].camera.settings.triggers[1].edge = TriggerEdge.Rising + p.video[0].camera.settings.input_triggers.frame_start = Trigger( + enable=True, line=1, edge="Rising" + ) p = runtime.set_configuration(p) - assert not p.video[0].camera.settings.triggers[0].enable - assert p.video[0].camera.settings.triggers[1].enable + + assert p.video[0].camera.settings.input_triggers.frame_start.enable + assert p.video[0].camera.settings.input_triggers.frame_start.line == 1 # # Disable triggering: # - p.video[0].camera.settings.triggers[0].enable = False - p.video[0].camera.settings.triggers[1].enable = False + p.video[0].camera.settings.input_triggers.frame_start.enable = False p = runtime.set_configuration(p)