471,594 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

where do my python files go in linux?

Hi All,

I am trying to make a debian package. I am following the tutorial by
Horst Jens (http://showmedo.com/videos/video?nam...romSeriesID=37)
and it is very informative. However one thing my app has and his
doesn't, is multiple python files which need to be executed. For
example

{dir}/app
app.py

app.py calls a lot of modules in {dir}/app. Horst says the python file
goes in /usr/bin/app.py which is ok with me, but I have multiple
python files, and I decided to use an app.sh script to call my python
files. In the /usr/bin I do not see subdirs so I assume that is not
really desirable.

Question 1. Where do I put the bulk of python scripts in a normal
linux environment?
Question 2. Should I use *.pyc rather then *.py files to speed up
executing as the user cannot write to /usr/bin or any other dir in the
system and everytime my app runs it will recompile it

Thanks for any advice or maybe a good tutorial how to set up files in
a linux environment

With regards,
- Jorgen
Jan 12 '08 #1
3 1765
On Sat, 12 Jan 2008 12:02:20 +0100, Jorgen Bodde wrote:
I am trying to make a debian package. I am following the tutorial by
Horst Jens
(http://showmedo.com/videos/video?
name=linuxJensMakingDeb&fromSeriesID=37)
and it is very informative. However one thing my app has and his
doesn't, is multiple python files which need to be executed. For example

{dir}/app
app.py

app.py calls a lot of modules in {dir}/app. Horst says the python file
goes in /usr/bin/app.py which is ok with me, but I have multiple python
files, and I decided to use an app.sh script to call my python files. In
the /usr/bin I do not see subdirs so I assume that is not really
desirable.

Question 1. Where do I put the bulk of python scripts in a normal linux
environment?
Question 2. Should I use *.pyc rather then *.py files to speed up
executing as the user cannot write to /usr/bin or any other dir in the
system and everytime my app runs it will recompile it

Thanks for any advice or maybe a good tutorial how to set up files in a
linux environment
On a Debian system:
I would put app.py in /usr/local/bin. I would create the directory
/usr/local/lib/app, and put all other *.py and *.pyc files there. At the
top of app.py, I'd add the following line so that I could import files
directly from /usr/local/lib/app:

sys.path.insert(0,'/usr/local/lib/app')
Alternatively, using your app.sh approach, I'd put app.sh in
/usr/local/bin/, and all *.py and *.pyc files in /usr/local/lib/app. I'd
invoke Python something like this:

PYTHONPATH=/usr/local/lib/app:$PYTHONPATH python -m app

(The -m switch searches the Python path for a module to run.)
If it's more of a library than an application (maybe there is a command
line script, but users could want to import the modules directly), then
I'd stick all the modules in /usr/local/lib/python2.x/site-packages, and
the command line scripts in /usr/local/bin.
Yes, install the *.pyc files. I recommend putting *.py files there as
well, so users can refer to it if there are any problems, but you don't
have to. The Python module compileall is your friend here.
Carl Banks
Jan 12 '08 #2
"Jorgen Bodde" <jo*************@gmail.comwrote:
I am trying to make a debian package. I am following the tutorial by
Horst Jens (http://showmedo.com/videos/video?nam...romSeriesID=37)
and it is very informative. However one thing my app has and his
doesn't, is multiple python files which need to be executed. For
example

{dir}/app
app.py

app.py calls a lot of modules in {dir}/app. Horst says the python file
goes in /usr/bin/app.py which is ok with me, but I have multiple
python files, and I decided to use an app.sh script to call my python
files. In the /usr/bin I do not see subdirs so I assume that is not
really desirable.

Question 1. Where do I put the bulk of python scripts in a normal
linux environment?
Question 2. Should I use *.pyc rather then *.py files to speed up
executing as the user cannot write to /usr/bin or any other dir in the
system and everytime my app runs it will recompile it

Thanks for any advice or maybe a good tutorial how to set up files in
a linux environment
Have look at the Debian Python Policy
(should be in /usr/share/doc/python/python-policy.* on
Debian systems)


>
With regards,
- Jorgen

Florian
--
<http://www.florian-diesch.de/>
-----------------------------------------------------------------------
** Hi! I'm a signature virus! Copy me into your signature, please! **
-----------------------------------------------------------------------
Jan 13 '08 #3
On 2008-01-12, Jorgen Bodde <jo*************@gmail.comwrote:
Question 1. Where do I put the bulk of python scripts in a normal
linux environment?
Question 2. Should I use *.pyc rather then *.py files to speed up
executing as the user cannot write to /usr/bin or any other dir in the
system and everytime my app runs it will recompile it

Thanks for any advice or maybe a good tutorial how to set up files in
a linux environment
Rather than re-inventing the wheel, please have a look at distutils:
http://docs.python.org/lib/module-distutils.html

It does most if not all of the things you want to do.
If you want something more advanced, read about eggs.
Sincerely,
Albert
Jan 14 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Alexander May | last post: by
14 posts views Thread by Jeffrey Barish | last post: by
32 posts views Thread by David Brown | last post: by
7 posts views Thread by Edward Diener | last post: by
7 posts views Thread by Frank Potter | last post: by
2 posts views Thread by enquiring mind | last post: by
10 posts views Thread by sandipm | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.