Constructing Modules

Using Ubuntu 20.04 download of Salome-9.9.0. While constructing a module like PYHELLO the following error is obtained:

CMake Error at ~/programs/SALOME-9.9.0-native-UB20.04-SRC/BINARIES-UB20.04/KERNEL/salome_adm/cmake_files/SalomeKERNELConfig.cmake:46 (message):

File or directory
/volatile/projet/salome/jenkins/workspace/SALOMEBuilder/SALOME-9.9.0-native-UB20.04/INSTALL/omniORB
referenced by variable OMNIORB_ROOT_DIR_EXP does not exist !

Call Stack (most recent call first):
~/programs/SALOME-9.9.0-native-UB20.04-SRC/BINARIES-UB20.04/KERNEL/salome_adm/cmake_files/SalomeKERNELConfig.cmake:115 (SET_AND_CHECK)
~/programs/SALOME-9.9.0-native-UB20.04-SRC/BINARIES-UB20.04/CONFIGURATION/cmake/SalomeMacros.cmake:435 (FIND_PACKAGE)
~/programs/SALOME-9.9.0-native-UB20.04-SRC/BINARIES-UB20.04/CONFIGURATION/cmake/FindSalomeKERNEL.cmake:42 (SALOME_FIND_PACKAGE)
CMakeLists.txt:48 (FIND_PACKAGE)

The procedure used to get this error was:

source env_launch.sh
mkdir myPYHELLO_BUILD
mkdir myPYHELLO_INSTALL
cd myPYHELLO_BUILD
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=…/myPYHELLO_INSTALL …/myPYHELLO

The error occurred when running the above cmake command.

Inspecting the file, “~/programs/SALOME-9.9.0-native-UB20.04-SRC/BINARIES-UB20.04/KERNEL/salome_adm/cmake_files/SalomeKERNELConfig.cmake” reveals that all the paths in it are Jenkins paths such as the one above, “/volatile/projet/salome/jenkins/workspace/SALOMEBuilder/SALOME-9.9.0-native-UB20.04/INSTALL/omniORB”

Do I simply replace all the paths manually with the correct paths?

Thanks in advance for any assistance,
Sesqui

Can you try to do the following:

tar zxf SALOME-9.9.0-native-UB20.04-SRC.tar.gz
cd SALOME-9.9.0-native-UB20.04-SRC
chmod +x ./install_bin.sh
./install_bin.sh
./sat/sat prepare SALOME-9.9.0-native -p CONFIGURATION
./sat/sat environ SALOME-9.9.0-native
source ./env_build.sh

then repeat your steps:

mkdir myPYHELLO_BUILD
mkdir myPYHELLO_INSTALL
cd myPYHELLO_BUILD
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=…/myPYHELLO_INSTALL …/myPYHELLO

to see if this helps to resolve the reported issue ?
You can also think of sharing your muPYHELLO package such that others can help.

1 Like

This resolved the issues, many thanks!

Sesqui

After continuing from above and successfully running make and make install, when I go to the the <MYPYHELLO_module_installation_dir> directory and type:

./bin/salome/runMYPYHELLO

I get the following response:

“bash: ./bin/salome/runMYPYHELLO: No such file or directory”

However, I can see the “runMYPYHELLO” file located at that path.

Any ideas as to how to resolve this?

Best regards,

Sesqui

It’s quite hard to guess here. Can you upload your myPyhello module such that others can help. Regards

MYPYHELLO.tgz (125.3 KB)
MYPYHELLO_INSTALL.tgz (254.6 KB)

Attached in the MYPYHELLO source folder as well as the MYPYHELLO_INSTALL folder.
Essentially, MYPYHELLO is a copy of the PYHELLO folder and all of its contents. Only I replaced every instance of “PYHELLO” in it with “MYPYHELLO” hoping to make a new module called “MYPYHELLO” that does everything the “PYHELLO” module does.

Again thank you any kind assistance,

Sesqui

Here is some more info.

When attempting to run MYPYHELLO module from the MYPYHELLO_INSTALL folder I get a “ModuleNotFoundError: No module named ‘omniORB’” error.

OmniORB folder is in the INSTALL folder and ~/programs/SALOME-9.9.0-native/INSTALL/omniORB/lib/python3.8/site-packages

has the CORBA.py module. Here is what terminal shows:

./bin/salome/runMYPYHELLO
Searching for a free port for naming service: ./bin/salome/runMYPYHELLO: 35: let: not found
2810 - Ok
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘CORBA’
./bin/salome/runMYPYHELLO: 44: [[: not found
Traceback (most recent call last):
File “/home/dan/programs/SALOME-9.9.0-native/INSTALL/KERNEL/bin/salome/envSalome.py”, line 36, in
import setenv
File “/home/dan/programs/SALOME-9.9.0-native/INSTALL/KERNEL/bin/salome/setenv.py”, line 26, in
import orbmodule
File “/home/dan/programs/SALOME-9.9.0-native/INSTALL/KERNEL/bin/salome/orbmodule.py”, line 31, in
from omniORB import CORBA
ModuleNotFoundError: No module named ‘omniORB’

Issue still not resolved. Here is more information: I am simply trying to make a module named MYPYHELLO. I copied the PYHELLO package and replaced all instances of PYHELLO with MYPYHELLO.
Running the following commands I get an error: ModuleNotFoundError: No module named ‘omniORB’

cd SALOME-9.9.0
chmod +x ./install_bin.sh
./install_bin.sh
./sat/sat prepare SALOME-9.9.0-native -p CONFIGURATION
./sat/sat environ SALOME-9.9.0-native
source ./env_build.sh

cd MYPYHELLO_BUILD
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=…/MYPYHELLO_INSTALL …/MYPYHELLO_SRC
make
make install

cd …/MYPYHELLO_INSTALL
./bin/salome/runMYPYHELLO

ERROR:

Searching for a free port for naming service: ./bin/salome/runMYPYHELLO: 35: let: not found
2810 - Ok
./bin/salome/runMYPYHELLO: 44: [[: not found
Traceback (most recent call last):
File “~/programs/SALOME-9.9.0/INSTALL/KERNEL/bin/salome/envSalome.py”, line 36, in
import setenv
File “~/programs/SALOME-9.9.0/INSTALL/KERNEL/bin/salome/setenv.py”, line 26, in
import orbmodule
File “~/programs/SALOME-9.9.0/INSTALL/KERNEL/bin/salome/orbmodule.py”, line 31, in
from omniORB import CORBA
ModuleNotFoundError: No module named ‘omniORB’

Any assistance would be greatly appreciated,

Sesqui

Hi,
it seems that documentation needs to be updated here and the approach based on a standalone bash launcher needs to be revisited. We will raise the issue to our core developers.
In the meanwhile find below what you need to do:

first: you need to ensure that rename utility is installed on your Ubuntu 20. if not, simply install it with :
sudo apt install rename

Then run the following command lines:

# 0 - extract SALOME
tar zxf SALOME-9.9.0-native-UB20.04-SRC.tar.gz
cd SALOME-9.9.0-native-UB20.04-SRC
chmod +x ./install_bin.sh

#- 1 -  setup developer mode
./install_bin.sh

# 2 - clone  CONFIGURATION 
./sat/sat prepare SALOME-9.9.0-native -p CONFIGURATION

# 3 - generate environment scripts
./sat/sat environ SALOME-9.9.0-native

# 4 - setup SALOME build environment
source ./env_build.sh

# 5 -  clone the migrated PYHELLO
cd  $PRODUCT_ROOT_DIR/SOURCES
git clone https://git.salome-platform.org/gitpub/samples/pyhello.git MYPYHELLO
cd MYPYHELLO

# 6 -  rename all directories from PYHELLO to MYPYHELLO
find . -execdir rename 's/PYHELLO/MYPYHELLO/' '{}' \+
find . -execdir rename 's/pyhello/mypyhello/' '{}' \+

# 7 - rename all occurences of PYHELLO to MYPYHELLO
find . -type f -exec sed -i 's/PYHELLO/MYPYHELLO/g' {} +
find . -type f -exec sed -i 's/pyhello/mypyhello/g' {} +

# 8 -  build my module MYPYHELLO
mkdir -p $PRODUCT_ROOT_DIR/BUILD/MYPYHELLO
cd $PRODUCT_ROOT_DIR/BUILD/MYPYHELLO
cmake  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PRODUCT_ROOT_DIR/INSTALL/MYPYHELLO $PRODUCT_ROOT_DIR/SOURCES/MYPYHELLO
make
make install

# 9 - generate SALOME launcher.
cd $PRODUCT_ROOT_DIR
./sat/sat launcher SALOME-9.9.0-native 

# 10 -  edit file salome and just before section: # [APPLI variables], add following lines:

    #[MYPYHELLO]
    context.setVariable(r"MYPYHELLO_ROOT_DIR", r"${PRODUCT_ROOT_DIR}/INSTALL/MYPYHELLO", overwrite=True)
    context.addToPath(r"${MYPYHELLO_ROOT_DIR}/bin/salome")
    context.addToLdLibraryPath(r"${MYPYHELLO_ROOT_DIR}/lib/salome")
    context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/bin/salome")
    context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/lib/salome")
    context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/${PYTHON_LIBDIR}/salome")
    appendPath(r"SALOME_MODULES", r"MYPYHELLO",separator=",")
    appendPath(r"SalomeAppConfig", r"${MYPYHELLO_ROOT_DIR}/share/salome/resources/mypyhello",separator=":")

# 11 - Launch SALOME either with your module only or with all modules

cd $PRODUCT_ROOT_DIR
./salome -m MYPYHELLO

Currently the MYPYHELLO that you shared needs to be updated such that runMYPYHELLO can launch you module - this needs to be discussed with experts. But the steps described above should help you to move forward.

If you come to some nice module, I am sure that SALOME community will be happy that you share it with others.
HTH

Thank you for the detailed procedure!
However, even after implementing the procedure I obtain the following error:

$ ./salome -m MYPYHELLO

ERROR:salomeContext:Unexpected error:
Traceback (most recent call last):
File “~/programs/SALOME-9.9.0/INSTALL/SALOME/bin/salome/salomeContext.py”, line 281, in _startSalome
res = getattr(self, command)(options) # run appropriate method
File “~/programs/SALOME-9.9.0/INSTALL/SALOME/bin/salome/salomeContext.py”, line 368, in _sessionless
import setenv
File “~/programs/SALOME-9.9.0/INSTALL/KERNEL/bin/salome/setenv.py”, line 26, in
import orbmodule
File “~/programs/SALOME-9.9.0/INSTALL/KERNEL/bin/salome/orbmodule.py”, line 31, in
from omniORB import CORBA
ModuleNotFoundError: No module named ‘omniORB’

However, I believe the procedure you gave me brings the omniORB binaries over into the INSTALL folder. As a result, it should not be having this issue where it cannot import CORBA.

Any assistance on this matter would be greatly appreciated,

Sesqui

It’s quite hard to guess what could be wrong in your case.
Here is one additional check that you could do.
First ensure that all omniORB shared objects files are found. To check that, run:

./salome context
cd $OMNIORB_ROOT_DIR/lib
ls *.so |xargs  ldd  | grep "not found"
cd $OMNIORB_ROOT_DIR/lib/python3.8/site-packages
ls *.so |xargs  ldd  | grep "not found"

if you find one ‘not found’ library, try to fix it or share the information.
Then, try in a python session to import omniORB. Check that this does not return on error:

python3
import omniORB
print(omniORB.__file__)
from omniORB import CORBA
print(CORBA.__file__)

This should return something like:

/xxxxx/SALOME-9.9.0-native-UB20.04-SRC/INSTALL/omniORB/lib/python3.8/site-packages/omniORB/__init__.py

/xxxxx/SALOME-9.9.0-native-UB20.04-SRC/INSTALL/omniORB/lib/python3.8/site-packages/omniORB/CORBA.py

Thank you for your detailed and useful advice! It passes the following tests:
./salome context
cd $OMNIORB_ROOT_DIR/lib
ls *.so |xargs ldd | grep “not found”
cd $OMNIORB_ROOT_DIR/lib/python3.8/site-packages
ls *.so |xargs ldd | grep “not found”

There were no missing files.

It also passes the test, but only when run while terminal is in the path the above tests left it in (cd $OMNIORB_ROOT_DIR/lib/python3.8/site-packages):

python3
import omniORB
print(omniORB.file)
from omniORB import CORBA
print(CORBA.file)

Running the above import omniORB test with terminal located at cd $OMNIORB_ROOT_DIR/lib fails. It also fails when run with terminal located at SALOME_ROOT_DIR.

Here is the procedure I used to make the MYPYHELLO module and run salome which resulted in getting the no omniORB module found error:
Here is the procedure to follow:

0 - extract SALOME

tar zxf SALOME-9.9.0-native-UB20.04-SRC.tar.gz
cd SALOME-9.9.0-native-UB20.04-SRC
chmod +x ./install_bin.sh

#- 1 - setup developer mode
./install_bin.sh

2 - clone CONFIGURATION

./sat/sat prepare SALOME-9.9.0-native -p CONFIGURATION

3 - generate environment scripts

./sat/sat environ SALOME-9.9.0-native

4 - setup SALOME build environment

source ./env_build.sh

5 - clone the migrated PYHELLO

cd SALOME-9.9.0/SOURCES
git clone https://git.salome-platform.org/gitpub/samples/pyhello.git MYPYHELLO
cd MYPYHELLO

6 - rename all directories from PYHELLO to MYPHELLO

find . -execdir rename ‘s/PYHELLO/MYPYHELLO/’ ‘{}’ +
find . -execdir rename ‘s/pyhello/mypyhello/’ ‘{}’ +

7 - rename all occurences of PYHELLO to MYPHELLO

find . -type f -exec sed -i ‘s/PYHELLO/MYPYHELLO/g’ {} +
find . -type f -exec sed -i ‘s/pyhello/mypyhello/g’ {} +

8 - build my module MYPYHELLO

mkdir -p SALOME-9.9.0/BUILD/MYPYHELLO
cd SALOME-9.9.0/BUILD/MYPYHELLO
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=…/…/INSTALL/MYPYHELLO …/…/SOURCES/MYPYHELLO <–fixes the destination of the INSTALL for MYPYHELLO
make
make install

9 - generate SALOME launcher.

cd SALOME-9.9.0
./sat/sat launcher SALOME-9.9.0-native

10 - edit file salome and just before section: # [APPLI variables], add following lines:

#[MYPYHELLO]
context.setVariable(r"MYPYHELLO_ROOT_DIR", r"SALOME-9.9.0/INSTALL/MYPYHELLO", overwrite=True)
context.addToPath(r"${MYPYHELLO_ROOT_DIR}/bin/salome")
context.addToLdLibraryPath(r"${MYPYHELLO_ROOT_DIR}/lib/salome")
context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/bin/salome")
context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/lib/salome")
context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/${PYTHON_LIBDIR}/salome")
appendPath(r"SALOME_MODULES", r"MYPYHELLO",separator=",")
appendPath(r"SalomeAppConfig", r"${MYPYHELLO_ROOT_DIR}/share/salome/resources/mypyhello",separator=":")

11 - Launch SALOME either with your module only or with all modules

cd SALOME-9.9.0
./salome -m MYPYHELLO

ANALYSIS:

Since “import omniORB” test passes when run from “$OMNIORB_ROOT_DIR/lib/python3.8/site-packages” I noted that the salome launcher defines that path as:

$OMNIORB_ROOT_DIR/lib/${PYTHON_VERSION}/site-packages

But earlier in the salome launcher file it defines ${PYTHON_VERSION} as 2.7, which makes the path to the omniORB = “$OMNIORB_ROOT_DIR/lib/python2.7/site-packages”; which by the way does not exist.

So I changed the salome launcher to define PYTHON_VERSION as 3.8 as follows:

#[Python]
context.setVariable(r"PYTHON_ROOT_DIR", r"/usr", overwrite=True)
context.setVariable(r"PYTHON_INCLUDE", r"/usr/local/include/python2.7", overwrite=True)
context.setVariable(r"PYTHON_VERSION", r"2.7", overwrite=True)
context.setVariable(r"PYTHONBIN", r"/usr/bin/python2", overwrite=True)
context.setVariable(r"PYTHON_LIBDIR", r"lib/python${PYTHON_VERSION}/site-packages", overwrite=True)

Becomes:

#[Python]
context.setVariable(r"PYTHON_ROOT_DIR", r"/usr", overwrite=True)
context.setVariable(r"PYTHON_INCLUDE", r"/usr/local/include/python3.8", overwrite=True)
context.setVariable(r"PYTHON_VERSION", r"3.8", overwrite=True)
context.setVariable(r"PYTHONBIN", r"/usr/bin/python3", overwrite=True)
context.setVariable(r"PYTHON_LIBDIR", r"lib/python${PYTHON_VERSION}/site-packages", overwrite=True)

Now when running “./salome -m MYPYHELLO” salome launches, BUT it is loaded with GEOMETRY, SHAPE, MESH, PARAVIS, etc. Note, none of the premade example modules were loaded. And the MYPYHELLO module is not loaded.

I was under the impression that the only module that would be loaded following the command ./salome -m MYPYHELLO would be MYPYHELLO.

At any rate, hopefully this may prompt further insight/discussion towards resolving this issue.

Best regards,

Sesqui

Hi
the contents of your salome launcher are inconsistent - since one can see “/usr/bin/python2”
Can you confirm that you have python returns version 3
If this is not the case, you can set it up with:

       sudo apt install python-is-python3

Then, in the launcher, you should use

    context.setVariable(r"MYPYHELLO_ROOT_DIR", r"${PRODUCT_ROOT_DIR}/INSTALL/MYPYHELLO", overwrite=True)

instead of:

context.setVariable(r"MYPYHELLO_ROOT_DIR", r"SALOME-9.9.0/INSTALL/MYPYHELLO", overwrite=True)
```

Excellent advise again! This issue has now been fully resolved.
Indeed running

sudo apt install python-is-python3

And correcting the error in context.setVariable making it

context.setVariable(r"MYPYHELLO_ROOT_DIR", r"${PRODUCT_ROOT_DIR}/INSTALL/MYPYHELLO", overwrite=True)

completely resolved the issue. Salome platform now launches with the MYPYHELLO module loaded. The MYPYHELLO module functions the way it is supposed to.

Thank you so very much for your detailed assistance. I believe the resulting overall procedure will assist others in more readily being able to develop and integrate custom modules into Salome!

For ready reference, here is the procedure that worked in all on Ubuntu 20.04 with SALOME-9.9.0:

sudo apt install python-is-python3

sudo apt install rename

0 - extract SALOME
tar zxf SALOME-9.9.0-native-UB20.04-SRC.tar.gz
// Renamed extract folder to "SALOME-9.9.0"
cd SALOME-9.9.0
chmod +x ./install_bin.sh

#- 1 - setup developer mode
./install_bin.sh

2 - clone CONFIGURATION
./sat/sat prepare SALOME-9.9.0-native -p CONFIGURATION

3 - generate environment scripts
./sat/sat environ SALOME-9.9.0-native

4 - setup SALOME build environment
source ./env_build.sh

// Now ${PRODUCT_ROOT_DIR} = path to the SALOME-9.9.0 folder

5 - clone the migrated PYHELLO
cd ${PRODUCT_ROOT_DIR}/SOURCES
git clone https://git.salome-platform.org/gitpub/samples/pyhello.git MYPYHELLO
cd MYPYHELLO

6 - rename all directories from PYHELLO to MYPHELLO
find . -execdir rename 's/PYHELLO/MYPYHELLO/' '{}' \+
find . -execdir rename 's/pyhello/mypyhello/' '{}' \+

7 - rename all occurences of PYHELLO to MYPHELLO
find . -type f -exec sed -i 's/PYHELLO/MYPYHELLO/g' {} +
find . -type f -exec sed -i 's/pyhello/mypyhello/g' {} +

8 - build my module MYPYHELLO
mkdir -p ${PRODUCT_ROOT_DIR}/BUILD/MYPYHELLO
cd ${PRODUCT_ROOT_DIR}/BUILD/MYPYHELLO
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../INSTALL/MYPYHELLO ../../SOURCES/MYPYHELLO 
make
make install

9 - generate SALOME launcher.
cd ${PRODUCT_ROOT_DIR}
./sat/sat launcher SALOME-9.9.0-native

10 - edit file salome and just before section: # [APPLI variables], add following lines:
    #[MYPYHELLO]
    context.setVariable(r"MYPYHELLO_ROOT_DIR", r"${PRODUCT_ROOT_DIR}/INSTALL/MYPYHELLO", overwrite=True)
    context.addToPath(r"${MYPYHELLO_ROOT_DIR}/bin/salome")
    context.addToLdLibraryPath(r"${MYPYHELLO_ROOT_DIR}/lib/salome")
    context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/bin/salome")
    context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/lib/salome")
    context.addToPythonPath(r"${MYPYHELLO_ROOT_DIR}/${PYTHON_LIBDIR}/salome")
    appendPath(r"SALOME_MODULES", r"MYPYHELLO",separator=",")
    appendPath(r"SalomeAppConfig", r"${MYPYHELLO_ROOT_DIR}/share/salome/resources/mypyhello",separator=":")


# 11 - Launch SALOME either with your module only or with all modules

cd ${PRODUCT_ROOT_DIR}
./salome -m MYPYHELLO

Warm regards,

Sesqui

If I wanted to do this on Windows 10, are the bash commands similar? I’m trying to run salome with only shaper and mesh modules from source.