Project

General

Profile

Feature #2203

Restructure the code into Python packages

Added by Parag Mhashilkar about 9 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Douglas Strain
Category:
-
Target version:
Start date:
11/23/2011
Due date:
% Done:

0%

Estimated time:
Stakeholders:
Duration:

Description

Useful when rpm puts the files in system areas

History

#1 Updated by Douglas Strain almost 9 years ago

I've decided to do this only in the master branch and will start once we have a glideinwms meeting because I want to discuss this transition.

#2 Updated by Burt Holzman over 8 years ago

  • Target version set to v3_1

#3 Updated by Igor Sfiligoi almost 8 years ago

Using syntax like this
from glideinwms.lib import cgWParams
is bad.

It effectively makes it impossible to have a test instance called
glideinwms.v2_6_2
on a system, and expect it to work.

#4 Updated by Burt Holzman almost 8 years ago

Hi Igor,

This is standard python packaging syntax. Use PYTHONPATH to do what you want.

#5 Updated by Igor Sfiligoi almost 8 years ago

How would I make it work?
What should I put in the PYTHONPATH to get cgWParams.py loaded?

Igor

#6 Updated by Douglas Strain almost 8 years ago

Here's a simple example of two versions of cgWParams.py used with a different PYTHONPATH:

[dstrain@dhcp-131-225-82-213 test]$ mkdir -p test1/glideinwms/lib/
[dstrain@dhcp-131-225-82-213 test]$ mkdir -p test2/glideinwms/lib/
[dstrain@dhcp-131-225-82-213 test]$ echo "print \"test1\"" > test1/glideinwms/lib/cgWParams.py
[dstrain@dhcp-131-225-82-213 test]$ echo "print \"test2\"" > test2/glideinwms/lib/cgWParams.py
[dstrain@dhcp-131-225-82-213 test]$ pwd
/home/dstrain/test
[dstrain@dhcp-131-225-82-213 test]$ touch test1/glideinwms/__init__.py
[dstrain@dhcp-131-225-82-213 test]$ touch test2/glideinwms/__init__.py
[dstrain@dhcp-131-225-82-213 test]$ touch test1/glideinwms/lib/__init__.py
[dstrain@dhcp-131-225-82-213 test]$ touch test2/glideinwms/lib/__init__.py
[dstrain@dhcp-131-225-82-213 test]$ export PYTHONPATH=/home/dstrain/test/test1
[dstrain@dhcp-131-225-82-213 test]$ python
Python 2.4.3 (#1, Sep 20 2011, 06:04:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from glideinwms.lib import cgWParams

test1

[dstrain@dhcp-131-225-82-213 test]$ export PYTHONPATH=/home/dstrain/test/test2
[dstrain@dhcp-131-225-82-213 test]$ python
Python 2.4.3 (#1, Sep 20 2011, 06:04:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from glideinwms.lib import cgWParams

test2

#7 Updated by Douglas Strain almost 8 years ago

  • Status changed from New to Feedback
  • Assignee changed from Douglas Strain to Parag Mhashilkar
  • Target version changed from v3_1 to v2_7_x

Ok, this is all set and ready in branch_v2plus_2203. There are 8 commits and they all start with "GlideinWMS Packaging 2203:".

This changes all the imports to use standard python modules and sub-modules. I omitted moving the bin files to a "bin/" directory, since I thought that was more confusing than how we have it now.

I also added a PYTHONPATH variable to be added into factory.sh/frontend.sh for the ini installer and profile.d for the Q&A installer. This should deprecate the need for the sys.path hacks in the beginning of many of the executable python programs. However, I decided to fix those to work and leave them in there for now, since people may not reinstall (for instance, if they just swap out the source when they upgrade, or if they only create_glidein again).

I have not yet done this work for master branch yet.

#8 Updated by Douglas Strain almost 8 years ago

I have also cherry-picked these changes into branch_master_2203. This needs to be tested and reviewed as well.

#9 Updated by Parag Mhashilkar almost 8 years ago

  • Target version changed from v2_7_x to v2_7

#10 Updated by Parag Mhashilkar almost 8 years ago

  • Assignee changed from Parag Mhashilkar to Douglas Strain

I fixed some of the imports in branch_master_2203. Can you please look it and merge the changes to v2plus as well? Rest of the imports look ok to merge

#11 Updated by Douglas Strain almost 8 years ago

  • Status changed from Feedback to Resolved

This has been merged into branch_v2plus and master. Marking it as resolved.

#12 Updated by Parag Mhashilkar over 7 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF