From 56673740767f3274335519177d54fe692b055691 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Tue, 11 Jul 2023 20:41:18 +0100 Subject: [PATCH 1/2] Fix to correctly locate python DLL on MS-Windows Also - Add ci test matrix across different archs, java and python versions. - Fix a test issue with name reference in the python collections lib. --- .github/workflows/test.yml | 52 +++++++++++++++++++++++++++++ .gitignore | 3 +- CHANGELOG.md | 4 +++ src/libpython_clj2/python/info.clj | 8 ++++- test/libpython_clj2/python_test.clj | 2 +- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d79b392 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,52 @@ +name: test + +on: + push: + branches: + - master + paths-ignore: + - '**/README.md' + - '**/CHANGELOG.md' + pull_request: + +jobs: + unit-test: + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + jdk: [8, 17, 19] + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.jdk }} + + - name: Install Clojure + uses: DeLaGuardo/setup-clojure@11.0 + with: + cli: 1.11.1.1347 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install numpy + + - name: Run tests (jdk<17) + if: ${{ matrix.jdk < 17 }} + run: | + clojure -M:test + - name: Run tests (jdk>=17) + if: ${{ matrix.jdk >= 17 }} + run: | + clojure -M:jdk-${{matrix.jdk}}:test diff --git a/.gitignore b/.gitignore index 6bd4f64..476e9bb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ a.out *.iml .lsp .clj-kondo -pregen-ffi-test \ No newline at end of file +pregen-ffi-test +*~ diff --git a/CHANGELOG.md b/CHANGELOG.md index 02545d3..8ff520c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Time for a ChangeLog! +## Unreleased + * Fix issue with locating python dll on MS-Windows + [#246](https://github.com/clj-python/libpython-clj/issues/246). + ## 2.024 * large dtype-next/hamf upgrade. * fix for call-attr (it was broken when using keywords). diff --git a/src/libpython_clj2/python/info.clj b/src/libpython_clj2/python/info.clj index 5667f0b..170be78 100644 --- a/src/libpython_clj2/python/info.clj +++ b/src/libpython_clj2/python/info.clj @@ -96,6 +96,7 @@ print(json.dumps( "Failed to find value python executable. Tried %s" default-python-executables))))) python-home (find-python-home system-info options) + platform (:platform system-info) java-lib-path (java-library-path-addendum python-home) [ver-maj ver-med _ver-min] (:version system-info) lib-version (format "%s.%s" ver-maj ver-med) @@ -105,7 +106,12 @@ print(json.dumps( libnames (concat [libname] ;;Make sure we try without the 'm' suffix (when lib-version - [(str "python" lib-version)]))] + [(str "python" lib-version)]) + ;; The official python dll + ;; does not have a dot in + ;; its name. + (when (= platform "win32") + [(str "python" ver-maj ver-med)]))] (merge system-info {:python-home python-home diff --git a/test/libpython_clj2/python_test.clj b/test/libpython_clj2/python_test.clj index e693169..6f46a39 100644 --- a/test/libpython_clj2/python_test.clj +++ b/test/libpython_clj2/python_test.clj @@ -365,7 +365,7 @@ class Foo: bridged-dict (py/as-python {"a" 1 "b" 2}) bridged-iter (py/as-python (repeat 5 1)) bridged-list (py/as-python (vec (range 10))) - pycol (py/import-module "collections") + pycol (py/import-module "collections.abc") mapping-type (py/get-attr pycol "Mapping") iter-type (py/get-attr pycol "Iterable") sequence-type (py/get-attr pycol "Sequence")] From bb39bdf177b546158bcb150aa762257785611600 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Thu, 13 Jul 2023 21:38:29 +0100 Subject: [PATCH 2/2] revert test suite fix/CI suggestion/.gitignore as suggested To be considered to go to seperate GH issues/PRs instead --- .github/workflows/test.yml | 52 ----------------------------- .gitignore | 3 +- test/libpython_clj2/python_test.clj | 2 +- 3 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index d79b392..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: test - -on: - push: - branches: - - master - paths-ignore: - - '**/README.md' - - '**/CHANGELOG.md' - pull_request: - -jobs: - unit-test: - runs-on: ${{matrix.os}} - strategy: - fail-fast: false - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - jdk: [8, 17, 19] - python-version: ["3.11"] - - steps: - - uses: actions/checkout@v3 - - - name: Set up JDK ${{ matrix.jdk }} - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.jdk }} - - - name: Install Clojure - uses: DeLaGuardo/setup-clojure@11.0 - with: - cli: 1.11.1.1347 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install numpy - - - name: Run tests (jdk<17) - if: ${{ matrix.jdk < 17 }} - run: | - clojure -M:test - - name: Run tests (jdk>=17) - if: ${{ matrix.jdk >= 17 }} - run: | - clojure -M:jdk-${{matrix.jdk}}:test diff --git a/.gitignore b/.gitignore index 476e9bb..6bd4f64 100644 --- a/.gitignore +++ b/.gitignore @@ -20,5 +20,4 @@ a.out *.iml .lsp .clj-kondo -pregen-ffi-test -*~ +pregen-ffi-test \ No newline at end of file diff --git a/test/libpython_clj2/python_test.clj b/test/libpython_clj2/python_test.clj index 6f46a39..e693169 100644 --- a/test/libpython_clj2/python_test.clj +++ b/test/libpython_clj2/python_test.clj @@ -365,7 +365,7 @@ class Foo: bridged-dict (py/as-python {"a" 1 "b" 2}) bridged-iter (py/as-python (repeat 5 1)) bridged-list (py/as-python (vec (range 10))) - pycol (py/import-module "collections.abc") + pycol (py/import-module "collections") mapping-type (py/get-attr pycol "Mapping") iter-type (py/get-attr pycol "Iterable") sequence-type (py/get-attr pycol "Sequence")]