Closed cdholmes closed 4 years ago
Does your system also have the pncgen.py script installed? If so, my guess is that implementation is not subject to the same issue. I will need to update all the old style scripts.
I don't think the warning is coming from duplicate script copies. I have a local copy of the PseudoNetCDF git repository. That repository is not in my python path. I install PseudoNetCDF using
pip install /local/path/to/pseudonetcdf/git/repository
The pncgen.py script is then located in
ROOT/envs/pseudonetcdf/lib/python3.7/site-packages/PseudoNetCDF/
That should be the only copy that python finds when I run the pncgen command.
Relevant parts of my python environment are Anaconda 2020.02 netcdf4 1.5.3
This isn't a duplication issue. In fact, the extra copies I am referring to are not duplicates.
In PseudoNetCDF, there is one pncgen
and two pncgen.py
. The first pncgen.py
is in the lib folder you pasted. The pncgen
and second pncgen.py
are stored in the scripts
repo folder and in the bin
pathway after installation (which pncgen
and which pncgen.py
). The pncgen
in bin
is a bash script, while the pngen.py
is a python script.
$pncgen.py -f ffi1001 infile.ict outfile.nc
Try re-running the exact same linux command with .py
added to pncgen. It should work without warning. Mine did.
The plan was to deprecate the pncgen/pncdump
in favor of the .py
versions. This has two benefits. First, it gets rid of the warning and somewhat version specific implementation of python -m
. Second, they work on windows just as well as on mac/linux/unix.
Do you think we should add a deprecation warning to the bash versions?
You are correct. Invoking $pncgen.py -f ffi1001 infile.ict outfile.nc
avoids the warning. Thanks for the explanation.
You could get rid of the bash version and make a softlink pncgen -> pncgen.py. The user would get the same current behavior. With that approach a deprecation warning may be unnecessary, but I'll leave that up to you.
Great idea. Do github softlinks work on windows?
I'm not a windows user, so I can't help there.
If the links are created by setup.py with os.symlink()
that might be another approach.
Updated in pull request #99
Closing issue.
pncgen generates a RuntimeWarning when invoked as $pncgen -f ffi1001 infile.ict outfile.nc
The warning is... PATH/lib/python3.7/runpy.py:125: RuntimeWarning: 'PseudoNetCDF.pncgen' found in sys.modules after import of package 'PseudoNetCDF', but prior to execution of 'PseudoNetCDF.pncgen'; this may result in unpredictable behaviour
The output file appears to be OK. This warning likely occurs when ingesting other file types, although I have not tested. The warning appears to be related to a change introduced in Python 3.5 and discussed in this stackoverflow thread.