ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
22 stars 32 forks source link

Placeholder bin/omero? #156

Open joshmoore opened 4 years ago

joshmoore commented 4 years ago

Looking at the generated bin/omero from https://github.com/ome/ansible-role-omero-server/pull/40:

#!/opt/omero/server/venv3/bin/python

import os
from subprocess import run
import sys

if not os.getenv('OMERODIR'):
    os.environ['OMERODIR'] = '/opt/omero/server/OMERO.server'

current_path = os.getenv('PATH', '')
venv_bin = '/opt/omero/server/venv3/bin'
if not current_path.startswith(venv_bin + os.pathsep):
    os.environ['PATH'] = '{}{}{}'.format(venv_bin, os.pathsep, current_path)

p = run(['/opt/omero/server/venv3/bin/omero'] + sys.argv[1:])
sys.exit(p.returncode)

is there a simplified version of this that might be valuable in ome/openmicroscopy to delegate to venv3/bin/omero? (Ignoring the question of Windows for second).

The three lines that need discussing are:

#!/opt/omero/server/venv3/bin/python

Use /usr/bin/env python?

os.environ['OMERODIR'] = '/opt/omero/server/OMERO.server'

Suggest failing if unset?

venv_bin = '/opt/omero/server/venv3/bin' ... p = run(['/opt/omero/server/venv3/bin/omero'] + sys.argv[1:])

Is this solvable?

cc: @manics @jburel @will-moore

manics commented 4 years ago

The idea of the script was be a wrapper so a user doesn't need to activate the venv nor set OMERODIR. If you take both those out the script doesn't do anything.

joshmoore commented 4 years ago

It could minimally be a learning instrument.

joshmoore commented 4 years ago

OMERODIR, of course, could still be set by dirname $(dirname exe)...

manics commented 4 years ago

Shall we close this? If you're using Ansible you get a wrapper, if you're not then there's a non-negligible chance you'll install the virtualenv and OMERO.server in some non-standard location, which means it's not possible to autodetect the locations.