1. OpenREM
  2. OpenREM
  3. OpenREM
  4. Issues

Issues

Issue #99 resolved

Scripts path manipulation doesn't work for Ubuntu system wide installs

Ed McDonagh
created an issue

Doesn't take account of use of dist-packages in place of site-packages.

Comments (23)

  1. Ed McDonagh reporter

    Removed the sys.path manipulation code from the import scripts again, as per 70888d1 and ref #73. This was reverted in fce9dd302bda and 15001b9222dd for #83 due to extraction scripts not functioning in virtualenv on linux. The existing code wouldn't work with debian installs due to assumption of site-packages instead of dist-packages. However, it seems that the correct thing to do would be to do: from openrem.remapp.extractors import rdsr, hence this commit. I think this will then break the openrem.settings finding, but this should be dealt with in the extractor codes, not here. We'll probably need to set the DJANGO_SETTINGS_MODULE to openrem.openrem.settings and then we'll not need the openrem_settings code at all. Refs #99.

    → <<cset 4220f2d82b54>>

  2. Ed McDonagh reporter

    Tested using ubuntu virtualenv install. rdsr script doesn't attempt to do anything to the path, but relies on site-packages or dist-packages being on the python path so that openrem.remapp.extractors.rdsr can be imported. rdsr.py now sets the DJANGO_SETTINGS_MODULE to openrem.openrem.settings instead of openrem.settings, and doesn't make use of the name_of_project function, which is no longer relevant as openrem is packaged as the application rather than remapp. Needs testing outside of virtualenv on Ubuntu, and in and out on Windows. Other scripts need to be changed in the same way. Refs #99.

    → <<cset b06f914db404>>

  3. Ed McDonagh reporter

    openrem_settings still needed to put the openrem folder on the path to allow

    from remapp.models import General_study_module_attributes
    

    else that would have to be changed to openrem.remapp.models throughout.

  4. Ed McDonagh reporter

    Made necessary changes to mam.py and ct_philips.py. Left ptsizecsv2db.py for now as the develop version has changed too significantly since this branch was created, so this needs to be done after the merge. Refs #99.

    → <<cset e9eb89729517>>

  5. Ed McDonagh reporter

    Testing in a virtualenv in Windows was very confusing as the python path seemed to include the system site-packages :-(

    Once that was sorted it out, the proposed changes didn't quite work for the extractors:

    • If the openrem folder is put on the path and DJANGO_SETTINGS_MODULE is set to openrem.openrem.settings
      • from django.db import models will fail
      • from remapp.models import General_study_module_attributes will succeed
    • If the openrem folder is not put on the path and DJANGO_SETTINGS_MODULE is set to openrem.openrem.settings
      • from django.db import models will succeed
      • from remapp.models import General_study_module_attributes will fail
    • If the openrem folder is put on the path and DJANGO_SETTINGS_MODULE is set to openrem.settings
      • from django.db import models will succeed
      • from remapp.models import General_study_module_attributes will succeed

    I now need to see if this configuration works for Ubuntu system install and linux virtualenv installs.

  6. Ed McDonagh reporter

    Modified rdsr.py to set the DJANGO_SETTINGS_MODULE to openrem.settings as the project folder is on the path, and in the Windows virtualenv openrem.openrem.settings failed to import if the project was on the path. Refs #99.

    → <<cset 042d912e8239>>

  7. Ed McDonagh reporter

    The format that worked for rdsr in a virtualenv on Windows doesn't work for Ubuntu in a virtual machine. django.db requires openren.openrem.settings, even with the project on the path. Tried adding a try except Import Error but it failed somewhere in the remapp.models. Settled on setting DJANGO_SETTINGS_MODULE to openrem.openrem.settings and importing django.db.models, then adding the projec to the path and importing rempapp.models.General_study_module_attributes. Needs testing in Windows again. Refs #99.

    → <<cset 6d8a7f75dad8>>

  8. Ed McDonagh reporter

    Tested in Windows using a virtualenv. Now established that for Windows virtualenv:

    • Must call python to get the virtualenv version rather than the system version
    • Scripts do have path to virtualenv python, but it is ignored

    In terms of the change to setting the DJANGO_SETTINGS_MODULE and importing django.models before putting the project on the path and importing remapp.models, that seemed to work.

    Now need to test with system wide installs on Windows and Ubuntu, and make the same edits to the other extractor files.

  9. Log in to comment