Skip to content

windows 11 fix for nrniv -python#2255

Merged
nrnhines merged 32 commits into
masterfrom
hines/win11-fix
Apr 24, 2024
Merged

windows 11 fix for nrniv -python#2255
nrnhines merged 32 commits into
masterfrom
hines/win11-fix

Conversation

@nrnhines

@nrnhines nrnhines commented Mar 2, 2023

Copy link
Copy Markdown
Member

Replacement of PyRun_InteractiveLoop by PyBytes_Main to avoid the File* arg.
Bug it overcomes is immediate return to terminal when launching nrniv -python due to unknown signal in PyOS_Readline.
The PyBytes_Main strategy was abandoned in favor of code.InteractiveConsole

Replacement of WinExec by CreateProcess (and then wait with WaitForSingleObject)
Bug it overcomes is failure to run by double clicking on hoc file. This bug was fixed in #2279

Started from setup-py-the-one-and-only 7f76358

Want to fix:
[x] NEURONMainMenu/Files/Quit does not exit in the sole circumstance of

nrniv -python
from neuron import h, gui

[x] When PyOS_ReadlineFunctionPointer = nrnpython_getline; the following crashes with MINGW

nrniv -python
from neuron import h, gui
g = h.Graph()
del g

@bbpbuildbot

This comment has been minimized.

@nrnhines nrnhines changed the base branch from setup-py-the-one-and-only to master March 3, 2023 01:51
@bbpbuildbot

This comment has been minimized.

@codecov

codecov Bot commented Mar 3, 2023

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 35.29412% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 67.20%. Comparing base (63053bd) to head (350c964).
Report is 2 commits behind head on master.

Files Patch % Lines
src/nrnpython/nrnpython.cpp 31.25% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2255      +/-   ##
==========================================
- Coverage   67.20%   67.20%   -0.01%     
==========================================
  Files         564      564              
  Lines      104267   104281      +14     
==========================================
+ Hits        70073    70078       +5     
- Misses      34194    34203       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@azure-pipelines

Copy link
Copy Markdown

✔️ 7da1dbb -> Azure artifacts URL

@olupton

olupton commented Mar 3, 2023

Copy link
Copy Markdown
Collaborator

Logfiles from GitLab pipeline #105816 (⛔) have been uploaded here!

Status and direct links:

* [✅](https://bbpgitlab.epfl.ch/hpc/cellular/nrn/-/jobs/581438) [mac_m1_cmake_build: [cmake, ON, OFF, OFF, address]](https://gist.githubusercontent.com/bbpbuildbot/4220f59c833ab74c08dfc6afcaa467ba/raw/bb817c61fa372630759dd62415d916635f7e53b9/mac-m1-cmake-build-cmake-on-off-off-address.txt)

* [⛔](https://bbpgitlab.epfl.ch/hpc/cellular/nrn/-/jobs/581439) [spack_setup](https://gist.githubusercontent.com/bbpbuildbot/4220f59c833ab74c08dfc6afcaa467ba/raw/de0b5b407d02fcb26860fce797086b9f5a34a6a9/spack-setup.txt)

Just to say we have some internal updates ongoing at the moment, so everything except the M1 build in the gitlab pipeline will most likely fail for the next 1+ days...

@alexsavulescu alexsavulescu changed the base branch from master to setup-py-the-one-and-only March 3, 2023 08:54
@alexsavulescu

Copy link
Copy Markdown
Member

I've rebased the PR on top of setup-py-the-one-and-only. That should go in soon (waiting for BBP CI updates before merging, all in line)

@azure-pipelines

Copy link
Copy Markdown

✔️ 7da1dbb -> Azure artifacts URL

@nrnhines

nrnhines commented Mar 3, 2023

Copy link
Copy Markdown
Member Author

The reason I changed the base branch to master is so I could get a working setup.exe artifact for use by Michele in his course.
(some of the students have Windows 11). (I wasn't able to find an artifact when the base branch was setup-py-the-one-and-only.)
Anyway, it was ok to switch back because I now do have the artifact.

@nrnhines nrnhines marked this pull request as draft March 3, 2023 17:33
@nrnhines

nrnhines commented Mar 3, 2023

Copy link
Copy Markdown
Member Author

The fix for nrniv -python introduces problems as serious as what it was intended to fix. Apparently, Py_BytesMain calls Py_Finalize before returning and that causes a segfault during nrniv cleanup even before I get to a second Py_Finalize

Program received signal SIGSEGV, Segmentation fault.
PyThreadState_New (interp=0x0) at Python/pystate.c:684

Maybe the fix is just as simple as avoiding all Py calls after return from Py_BytesMain, but my reading further suggests it is completely unexpected by Python developers that one would even do Py calls or Py_Initialize before calling Py_BytesMain ( https://bugs.python.org/issue34008 ) so maybe it is prudent to avoid that as a replacement for PyRun_InteractiveLoop.

I'd like to keep PyRun_InteractiveLoop but the problem is that I cannot find a way to get a FILE* from python given a file descriptor. Note that

PyObject *PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd)

does not return FILE*

Edit: Hmm. Looks like it may suffice to just call Py_Initialize() after return from Py_BytesMain. Further testing needed.

 Library dependencies do not satisfy target MacOS version 10.15
 wheel/neuron/.dylibs/Python has a minimum target of 11.0
 (but don't know how to do that for just Python38)
@azure-pipelines

Copy link
Copy Markdown

✔️ 40d6321 -> Azure artifacts URL

@bbpbuildbot

This comment has been minimized.

@nrnhines nrnhines requested a review from pramodk March 25, 2024 11:06
@nrnhines

nrnhines commented Mar 25, 2024

Copy link
Copy Markdown
Member Author

Is failing test:neuron:nmodl:nvhpc:omp:legacy
something we need to worry about? Did I recently ask this question in another PR? Well, something similar
#2598 (comment)
but I guess not since this failing CI mentions.

95% tests passed, 17 tests failed out of 373

Some (all?) of those seem to be out of memory issues. Can we restart just the test:neuron:nmodl:nvhpc:omp:legacy ?

@azure-pipelines

Copy link
Copy Markdown

✔️ e046d04 -> Azure artifacts URL

@azure-pipelines

Copy link
Copy Markdown

✔️ 9700129 -> Azure artifacts URL

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@azure-pipelines

Copy link
Copy Markdown

✔️ b1a657e -> Azure artifacts URL

@bbpbuildbot

This comment has been minimized.

@azure-pipelines

Copy link
Copy Markdown

✔️ f87173f -> Azure artifacts URL

Solves the MINGW crashing and quit problem when launching nrniv
and trying to use nrnpython_getline for readline behavior.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
3 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@azure-pipelines

Copy link
Copy Markdown

✔️ 350c964 -> Azure artifacts URL

@nrnhines

nrnhines commented Apr 22, 2024

Copy link
Copy Markdown
Member Author

@neuroman314 @ramcdougal I think this PR is ready to merge. But it would be good to try it out (on a windows machine) to verify that https://github.com/neuronsimulator/nrn/actions/runs/8786668302/ works in the context of the upcoming June course.
For windows 11, I have verified that launching python, nrniv, and nrniv -python from a bash and powershell terminal work with respect to

from neuron import h, gui
g = h.Graph()
del g # the graph should be closed without crashing
# NEURONMainMenu/File/Quit works

Note that on my windows 11 virtualbox guest, there is no readline when launchng python12 but readline works properly with nrniv and nrniv -python

I have not tested with windows10.
edit
I tested with windows10 and the above installer works properly. Note that it was somewhat painful to install as extracting the above zip file (to get the exe) caused the windows virus defender to complain and the exe would be removed after a few seconds. I had to

Turn off Defender antivirus protection in Windows Security
Select Start and type "Windows Security" to search for that app.
Select the Windows Security app from the search results, go to Virus & threat protection, and under Virus & threat protection settings select Manage settings.
Switch Real-time protection to Off.

Also the name of the file nrn-nightly-AMD64.exe does not indicate the version. But these issues are out of scope of this PR and can be considered later.

@nrnhines nrnhines requested a review from alkino April 23, 2024 13:45

@pramodk pramodk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As you have tested this, good to merge IMO.

@nrnhines nrnhines merged commit 2dd4518 into master Apr 24, 2024
@nrnhines nrnhines deleted the hines/win11-fix branch April 24, 2024 23:32
nrnhines added a commit that referenced this pull request Jul 5, 2024
* Compiling required pre-pr release/8.2 include order.
@heerener heerener mentioned this pull request Jul 24, 2024
27 tasks
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.

5 participants