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


Groups > comp.lang.python > #82681

Changing script's search path at install time

Return-Path <m.haralanov@gmail.com>
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; 'distutils': 0.07; 'modify': 0.07; 'app,': 0.09; 'statements': 0.09; 'subject:script': 0.09; 'python': 0.11; '__init__.py': 0.16; 'modules,': 0.16; 'subject:install': 0.16; 'subject:search': 0.16; 'all,': 0.19; 'app': 0.19; 'properly': 0.19; 'import': 0.22; 'install': 0.23; 'installation': 0.23; 'question': 0.24; 'script': 0.25; 'switch': 0.26; 'code:': 0.26; 'skip:" 20': 0.27; 'gets': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'easier': 0.31; 'are.': 0.31; 'directory,': 0.31; 'anyone': 0.31; 'figure': 0.32; 'run': 0.32; 'skip:& 30': 0.33; 'subject:time': 0.33; 'problem': 0.35; "can't": 0.35; 'received:google.com': 0.35; 'google': 0.35; '8bit%:9': 0.36; 'useful': 0.36; 'searching': 0.37; 'list': 0.37; 'skip:& 10': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'skip:& 20': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'how': 0.40; 'eventually': 0.60; 'skip:\xc2 10': 0.60; 'name': 0.63; '8bit%:27': 0.74
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=hIxjlrmSPQwd7yDlZ+DhQqTvpSo1WtTRHo1uXQlpFPA=; b=QLB8Ln3jCkxmOHI1mTCS/OlsgOxbx2JbuEvGq7rrAIWGcGb/bUKRbAzdi8MqvQuoWQ LYISdAh8VDlM05xXRwT/T1Rt371afncPo/gascDv8fS7nlrZFmnW7OAFcJWUc5q7XTQE KR93GQsWKXxWhFV3i/NF1/CA1MWl3w/pq1zirXuxLqozEwZxB3jTucQcKfDeVCG9ockf 0HkXB+M4kj/ZlAlsycQWSORAUQRHZtmd5YKVC6TAMcTaIUOiRR0V9+4Ouo8/jXEZU598 5tiMxt399Nsm+/W3KiWUnJKVVoQFCVvFprdc3TreeqicEiWG4vfBIRlFSSrzdhRdpZl5 I9zg==
MIME-Version 1.0
X-Received by 10.181.23.199 with SMTP id ic7mr9847787wid.18.1419029475404; Fri, 19 Dec 2014 14:51:15 -0800 (PST)
Date Fri, 19 Dec 2014 14:51:15 -0800
Subject Changing script's search path at install time
From Mitko Haralanov <m.haralanov@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=001a1136dd4cceb219050a998bf2
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.17062.1419040705.18130.python-list@python.org> (permalink)
Lines 89
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1419040705 news.xs4all.nl 2875 [2001:888:2000:d::a6]:42278
X-Complaints-To abuse@xs4all.nl
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!feed.ac-versailles.fr!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:82681

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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, 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.
Does anyone have any useful hints?

Thank you,
- Mitko

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


Thread

Changing script's search path at install time Mitko Haralanov <m.haralanov@gmail.com> - 2014-12-19 14:51 -0800
  Re: Changing script's search path at install time sohcahtoa82@gmail.com - 2014-12-19 18:18 -0800
  Re: Changing script's search path at install time Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-20 21:07 +1100

csiph-web