Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82683

Re: Changing script's search path at install time

Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'argument': 0.05; 'tree': 0.05; 'correct.': 0.07; 'distutils': 0.07; 'modify': 0.07; 'app,': 0.09; 'statements': 0.09; 'subject:script': 0.09; 'python': 0.11; '__init__.py': 0.16; 'imports': 0.16; 'modules,': 0.16; 'stuff.': 0.16; 'subject:install': 0.16; 'subject:search': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'app': 0.19; 'properly': 0.19; 'machine': 0.22; 'import': 0.22; 'tests': 0.22; 'install': 0.23; 'installation': 0.23; 'header:User-Agent:1': 0.23; 'environment': 0.24; 'question': 0.24; 'source': 0.25; 'script': 0.25; 'switch': 0.26; 'code:': 0.26; 'skip:" 20': 0.27; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'easier': 0.31; 'are.': 0.31; 'directory,': 0.31; 'anyone': 0.31; 'there.': 0.32; 'figure': 0.32; 'run': 0.32; 'subject:time': 0.33; 'maybe': 0.34; 'problem': 0.35; "can't": 0.35; 'test': 0.35; 'google': 0.35; 'really': 0.36; 'useful': 0.36; 'should': 0.36; 'searching': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'does': 0.39; 'bad': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'how': 0.40; 'eventually': 0.60; 'name': 0.63; 'such': 0.63; 'received:74.208': 0.68; 'nonsense.': 0.84; 'received:74.208.4.194': 0.84; 'have.': 0.93
Date Fri, 19 Dec 2014 21:17:11 -0500
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Changing script's search path at install time
References <CAH__Yg76OXapo2Q_bFZykgwc+_goEHge5sxdS8nrvHWe6zwv_w@mail.gmail.com>
In-Reply-To <CAH__Yg76OXapo2Q_bFZykgwc+_goEHge5sxdS8nrvHWe6zwv_w@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:R1aYpCooLVdtdDf7v2f5vHlUI6Yy15/gexdZYMOv4gT ztvK91LHsyMx0QHS56ZKuqPKzDz1UhlThHBLgR84Of9qcx8G4L Exq3HZlEi4BDGTTn7Aw13UR/sVb3TaYzF/pnqGyRgO+1scCyKb TFfizfkNUuPsOFDoKqPz+cgUmy9PI1aI+rl096jdrgCaxDBrCU e/SmNHSRmQ84o26ksCPOWMKGKQvLkVHEcarEexaWrpmveYlyix bDOq8Lq1BXOnHRGwBxtRQyPc5hKkWTZT+GmyPgr5nXBqyGtIqA R6m7RVjqcH50FCmK/HGhnIVMHFykfLSHYHdWvgsg/300cHDfUv DTHyETmy0HC5Yp5ni6Z4=
X-UI-Out-Filterresults notjunk:1;
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17065.1419045689.18130.python-list@python.org> (permalink)
Lines 64
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1419045689 news.xs4all.nl 2840 [2001:888:2000:d::a6]:56843
X-Complaints-To abuse@xs4all.nl
Path csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:82683

Show key headers only | View raw


On 12/19/2014 05:51 PM, Mitko Haralanov wrote:
> Hi all,
>
> I have a question regarding installation of Python scripts and modules
> using distutils that I can't find an answer to by searching through Google
> and the Python website. Hopefully, someone on this list might have ideas?
>
> I am writing a Python app, which I would eventually like to install using
> disutils. The app has the current tree strucutre:
>
> <root>
>    |----- myapp.py
>    |----- modules/
>                 |------  lib/
>                           |------  __init__.py
>                           |------  mymodule1.py
>                           |------  mymdule2.py
>                 |------- cmds/
>                           |------  __init__.py
>                           |------  cmds1.py
>
> Naturally, in order for my app to properly import the modules, currently it
> uses the following code:
>
>      import modules.lib.mymodule1
>      import modules.lib.mymodule2
>      import modules.cmds.cmds1

>
> However, when the app gets installed, I would like to install the modules
> to /usr/lib64/pythonX.Y/site-packages/myapp. I know that I can do this by
> using the "package_dir" argument to the "setup()" function in
> distutils.core.
>
> To make development easier I would like to be able to run the myapp.py
> script from the development directory,

Nonsense.  It should have the same structure on your machine as your 
customer will have.  So move the modules to where they're really going 
to be installed, and correct the imports until it tests correct.

> which means that the import
> statements have to remain as they are. The issue is that when the script is
> installed, the import statements will not work anymore since the directory
> name has been changed from "modules" to "myapp".
>
> My problem is that I can't figure out how to modify the myapp.py script to
> switch from "modules.lib.mymodule1" to "myapp.lib.module1" at install time.

Bad idea.

> Does anyone have any useful hints?
>

Yes, develop in the same environment as the customer is going to run. 
If for some reason you cannot, then TEST in the same environment as the 
customer is going to run.  If this confuses your source control, or some 
such other problem, deal with it there.  maybe use symlinks, or use a 
script to "install" the stuff.



-- 
DaveA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Changing script's search path at install time Dave Angel <davea@davea.name> - 2014-12-19 21:17 -0500

csiph-web