Skip to content

Conversation

@mheggelund
Copy link
Contributor

@mheggelund mheggelund commented Nov 14, 2025

Aims to fix problem where jneqsim package became too large

  • Add JAR files as runtime dependencies intead of bundled JAR files

@mheggelund mheggelund marked this pull request as ready for review November 20, 2025 08:29
@mheggelund mheggelund force-pushed the feat/java-as-dependency branch 2 times, most recently from e31f343 to ff5f421 Compare November 21, 2025 13:13
@matsklevstad matsklevstad requested a review from Copilot November 27, 2025 12:29

This comment was marked as resolved.

@matsklevstad
Copy link
Contributor

matsklevstad commented Nov 27, 2025

note: in order to run a specific test pypi version in NeqsimAPI:

uv remove jneqsim


uv add --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "jneqsimsmall==3.1.2" 
# you might get an error but it will take some minutes before the package is available 
# as test.pypi has some kind of cache


uv lock


docker compose up --build

(optional, try to remove the whole .venv aswell: rm -rf .venv )

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MarcusDragsten MarcusDragsten force-pushed the feat/java-as-dependency branch from 117b77c to ce0d3db Compare December 5, 2025 10:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated 13 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 90 to 94
- name: Publish package to TestPyPI
run: hatch publish -r test
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_TOKEN_MAOHE }}
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change: Publishing to TestPyPI instead of PyPI. This appears to be a testing/development change that shouldn't be in a production release. The original code published to PyPI, but now it publishes to TestPyPI with a personal token (TEST_PYPI_TOKEN_MAOHE). This should either be reverted to publish to PyPI, or this should be documented as a temporary testing workflow.

Suggested change
- name: Publish package to TestPyPI
run: hatch publish -r test
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_TOKEN_MAOHE }}
- name: Publish package to PyPI
run: hatch publish
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will change this before merging!

Comment on lines +40 to +54
if JPYPE_AVAILABLE and jpype and not jpype.isJVMStarted():
# We need to start the JVM before importing the neqsim package
try:
jar_path = get_neqsim_jar_path(jpype.getJVMVersion())
jpype.startJVM(classpath=[jar_path])

return str(jar_path)
import jpype.imports

# This is the java package, added to the python scope by "jpype.imports"
neqsim = jpype.JPackage("neqsim")
except Exception as e:
# JVM Start failed, handle gracefully
import warnings

if not jpype.isJVMStarted():
jpype.startJVM()
jar_path = get_neqsim_jar_path(jpype.getJVMVersion())
jpype.addClassPath(jar_path)
import jpype.imports # noqa
warnings.warn(f"Failed to initialize JVM: {e}. NeqSim functionality will not be available.", stacklevel=2)
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JVM lifecycle issue: The code checks not jpype.isJVMStarted() to start the JVM, but JPype JVM can only be started once per process. If the JVM start fails (line 50), subsequent imports of this module won't retry starting the JVM since the check happens at module import time. Also, if another part of the code starts the JVM before this module is imported, the JAR won't be added to the classpath. Consider handling these edge cases or documenting the expected usage pattern.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place we start the JVM

@MarcusDragsten MarcusDragsten changed the title feat: Add JAR files as runtime dependencies to pyhton package. feat: Add JAR files as runtime dependencies to Python package. Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants