Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conda path replacement mangling Cantera data directories #30

Closed
speth opened this issue May 31, 2022 · 2 comments · Fixed by #33
Closed

Conda path replacement mangling Cantera data directories #30

speth opened this issue May 31, 2022 · 2 comments · Fixed by #33

Comments

@speth
Copy link
Member

speth commented May 31, 2022

The behavior used by conda to replace paths on the build system with paths corresponding to the installation location is causing some problems with the Cantera data directories. Specifically, from the Python interface:

>>> import cantera as ct
>>> ct.get_data_directories()
['.',
 '/home/speth/miniconda3/envs/ct26/lib/python3.10/site-packages/cantera/data',
 '/home/speth/miniconda3/envs/ct26/share/cantera/data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
]
>>> ct.Solution('spam.yaml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/python/cantera/base.pyx", line 71, in cantera._cantera._SolutionBase.__cinit__
  File "build/python/cantera/base.pyx", line 128, in cantera._cantera._SolutionBase._cinit
  File "build/python/cantera/base.pyx", line 215, in cantera._cantera._SolutionBase._init_yaml
cantera._cantera.CanteraError: 
*******************************************************************************
CanteraError thrown by Application::findInputFile:

Input file spam.yaml not found in directories 
'.', 
'/home/speth/miniconda3/envs/ct26/lib/python3.10/site-packages/cantera/data', 
'/home/speth/miniconda3/envs/ct26/share/cantera/data
>>>

The problem is that the last directory name is padded with null bytes. When this is inserted into the error message printed by findInputFile, the message apparently ends up being treated as a null-terminated string, and gets truncated there.

This problem also affects the conda-forge packages.

Version tested: cantera 2.6.0 py310h6cd0baa_0

@ischoegl
Copy link
Member

ischoegl commented Aug 8, 2022

This may be closed by Cantera/cantera#1358.

@ischoegl
Copy link
Member

ischoegl commented Aug 9, 2022

After building an updated conda package with #33, I get the following:

>>> import cantera as ct
>>> ct.__version__
'3.0.0a2'
>>> ct.data.get_data_directories()
['.', '/opt/conda/envs/ct-test/lib/python3.9/site-packages/cantera/data', '/opt/conda/envs/ct-test/share/cantera/data']
>>> ct.Solution('spam.yaml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/python/cantera/solutionbase.pyx", line 37, in cantera.solutionbase._SolutionBase.__cinit__
  File "build/python/cantera/solutionbase.pyx", line 93, in cantera.solutionbase._SolutionBase._cinit
  File "build/python/cantera/solutionbase.pyx", line 174, in cantera.solutionbase._SolutionBase._init_yaml
cantera._utils.CanteraError: 
*******************************************************************************
CanteraError thrown by Application::findInputFile:

Input file spam.yaml not found in directories 
'.', 
'/opt/conda/envs/ct-test/lib/python3.9/site-packages/cantera/data', 
'/opt/conda/envs/ct-test/share/cantera/data'

To fix this problem, either:
    a) move the missing files into the local directory;
    b) define environment variable CANTERA_DATA to
         point to the directory containing the file.
*******************************************************************************

indicating that this may be indeed fixed.

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 a pull request may close this issue.

2 participants