What you consider a "best way to deploy linux python app"? I don't want
to install library modules into user's site-packages, so distutils is no
help. Currently, I change sys.path (adding directory where library
modules are stored) and I ask users to install application into /opt
hierarchy, but I don't think it's optimal.
--
Jarek Zgoda http://jpa.berlios.de/ 8 2051
> What you consider a "best way to deploy linux python app"? I don't want to install library modules into user's site-packages, so distutils is no help.
Yes, I agree. I've noticed that. It seems to me that the only
appropriate thing to install in site-packages are libraries to be used
to basically extend pythong -- not applications.
Currently, I change sys.path (adding directory where library modules are stored) and I ask users to install application into /opt hierarchy, but I don't think it's optimal.
My opinion. You can install it where you want. Typically either /opt
or /usr/local depending if you want to do a merged or separate install.
I would layout the package according the the GNU Standard Directory
structure, and consistent with the Linux Standard Base (or HFS). That I
think would mean that you'd put the modules into
${exec_prefix}/lib/mypackage-xx.yy.zz and then symlink any launch code
to the appropriate bin/ directory.
I would then reset sys.path to be the right thing in the startup module
- essentially the launcher. There are couple of way to do this -- the
installer can modify the python or sh launch code to hard wire the
install location or you can do like Gnome does -- have a script that is
in the path named mypackage-config where you can lookup the setup.
One thing I've always wonders was -- Is there a way for a python module
to tell where it's file is located??? If you could do this it might
also be possible to have a python script reset sys.path based on it's
own location.
Rob
Robert M. Emmons <Ro********@cs. com> pisze: One thing I've always wonders was -- Is there a way for a python module to tell where it's file is located??? If you could do this it might also be possible to have a python script reset sys.path based on it's own location.
import sys, os
me = os.path.abspath (sys.argv[0])
--
Jarek Zgoda http://jpa.berlios.de/
Robert M. Emmons wrote: One thing I've always wonders was -- Is there a way for a python module to tell where it's file is located???**If* you*could*do*th is*it*might also be possible to have a python script reset sys.path based on it's own location.
One way of doing this is:
import os, sys
directory, filename = os.path.split(_ _file__)
sys.path.append (directory)
-------
Jeffrey
On 2004-09-05, Jarek Zgoda <jz****@gazeta. usun.pl> wrote: Robert M. Emmons <Ro********@cs. com> pisze:
One thing I've always wonders was -- Is there a way for a python module to tell where it's file is located??? If you could do this it might also be possible to have a python script reset sys.path based on it's own location.
import sys, os
me = os.path.abspath (sys.argv[0])
That's only mostly reliable. Nothing in Linux/Unix actually requires that
argv[0] be the program's path. It is the convention to pass that as
argv[0], but there may be corner cases where it doesn't work.
--
Grant Edwards grante Yow! I had pancake makeup
at for brunch!
visi.com
Grant Edwards <gr****@visi.co m> pisze: import sys, os
me = os.path.abspath (sys.argv[0])
That's only mostly reliable. Nothing in Linux/Unix actually requires that argv[0] be the program's path. It is the convention to pass that as argv[0], but there may be corner cases where it doesn't work.
Based on Python docs:
"""
argv
The list of command line arguments passed to a Python script.
argv[0] is the script name (it is operating system dependent whether
this is a full pathname or not). If the command was executed using
the -c command line option to the interpreter, argv[0] is set to the
string '-c'. If no script name was passed to the Python interpreter,
argv has zero length.
""" http://docs.python.org/lib/module-sys.html
In my opinion, this would be enough to get full path of currently
running program, if run from script. Are there any caveats (except this
"-c" option, which I don't count, as is not relevant in most cases)?
--
Jarek Zgoda http://jpa.berlios.de/
Jarek Zgoda <jz****@gazeta. usun.pl> wrote in message news:<ch******* ***@nemesis.new s.tpi.pl>... Grant Edwards <gr****@visi.co m> pisze:
import sys, os
me = os.path.abspath (sys.argv[0])
That's only mostly reliable. Nothing in Linux/Unix actually requires that argv[0] be the program's path. It is the convention to pass that as argv[0], but there may be corner cases where it doesn't work.
Based on Python docs:
""" argv
The list of command line arguments passed to a Python script. argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the -c command line option to the interpreter, argv[0] is set to the string '-c'. If no script name was passed to the Python interpreter, argv has zero length. """
http://docs.python.org/lib/module-sys.html
In my opinion, this would be enough to get full path of currently running program, if run from script. Are there any caveats (except this "-c" option, which I don't count, as is not relevant in most cases)?
If you use a symbolic link to start the program sys.argv[0] will
return the location of the link instead of the path to your
application file I think. Anyway you can get the directory of the
application file with sys.path[0] if you need it.
However, why not just put all application files into one directory
(like /usr/local/share/yourApp or /opt/lib/myApp or something) and
start it from a link from /usr/local/bin (or /opt/bin) to your app's
main program file instead of messing around with sys.path , at least
it's the easiest solution and I don't really see the benefit of
putting the files into different directories unless you have modules
other people might want to use, in which case python's site-packages
directory would probably be the preferred location.
Just a personal opinion of course.
Regards
Michael
Robert M. Emmons <Ro********@cs. com> wrote:
... One thing I've always wonders was -- Is there a way for a python module to tell where it's file is located??? If you could do this it might
Piece of cake: the key part of this recipe is
def whereami(): return sys.modules[__name__].__file__
then you can os.path.abspath this filename string as you wish.
Here's a more complete example foo.py:
#!/usr/bin/env python
import sys, os
def whereami(): return os.path.abspath (sys.modules[__name__].__file__)
if __name__ == '__main__': print whereami()
Put this anywhere on your $PATH, chmod +x it, and try out what you see
by executing it as the main script from various locations... should work
pretty reliably.
also be possible to have a python script reset sys.path based on it's own location.
Sure, that shouldn't be impossible.
Alex
Alex Martelli wrote: Robert M. Emmons <Ro********@cs. com> wrote: ...
One thing I've always wonders was -- Is there a way for a python module to tell where it's file is located??? If you could do this it might
Piece of cake: the key part of this recipe is def whereami(): return sys.modules[__name__].__file__ then you can os.path.abspath this filename string as you wish.
That only seems to work for python 2.3 or later
One thing to consider when wondering where to put system wide
modules is that you have to worry about the python version
changing underneath you. This is because *.py[oc]
are not compatibile across minor version changes.
I.E. if one has pyc files in /usr/lib/site-python
and python 2.3 is installed subsequently on the system
then the modules probably will cause problems.
That is why py[co] files are installed in
version specific directories like:
/usr/lib/python2.2/site-packages/app/
Pádraig. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Google Mike |
last post by:
On Linux, I need to ask what your favorite installation options are for
a PHP app as a kind of poll. In this first part, I discuss the Install
Wizard choices. In Part 2, I discuss the database configuration
choices.
Consider SugarCRM. It's really an SDK that you customize. Knowing that,
you might want to download about 4 to 30 different PHP/CRM products,
try out which one you like, and then try to customize 3-4 of your top
choices,...
|
by: Andy Grayson |
last post by:
Hi, I am not sure this is the right group to ask as I think the problem is Linux
related but I have had no joy from Linux groups
I am new to both Linux and Programming, I am learning as I go
but have become stuck.
I am trying to create a web application with Visual Basic.NET 2003 for initial
deployment on my suse 9 based web server
When I try to create a new ASP.NET application in visual basic I get a message
|
by: Mart |
last post by:
Hi,
I have just written (my first) VB.net app using MS Visual Basic 2005
Express Edition Beta. It is fairly simple, it reads some configuration
data from an XML file then opens a new window containing a WebBrowser
object.
This all works fine and I'm happy with my app so I want to 'publish' to
a setup file so that others can install it, but when I publish it a get
the following errors:
|
by: Josef Brunner |
last post by:
Hi,
I published my application (VS 2005) and am now trying to install it when I
get this error message. It worked before...even on a different machine.
Here is the detailed description:
PLATFORM VERSION INFO
Windows : 5.1.2600.131072 (Win32NT)
Common Language Runtime : 2.0.50727.42
|
by: Michael Kalika |
last post by:
Hi,
We have developed a VSTO 2005 Excel application and we would like to
leverage ClickOnce deployment mechanism for distribution of this
application.
How can we do that? I was digging in MSDN for VSTO & ClickOnce documentation
and did not find anything. I've noticed that there is an option to
publish the project, but when I do that and then run the application from
Web it throws us security errors like:
| |
by: Tifer |
last post by:
Hello,
I am building my first .Net Application. The first couple of Publish
and Installs I did went fine. But after a couple of builds, I get a
modal dialogue box error every time upon trying to install using the
setup.exe. Title is "Cannot Start Application" and it says:
====================
Cannot download the application. The application is missing required
files. Contact application vendor for assistance.
|
by: sezanawa |
last post by:
Hi Guys,
I am new to java deployment things. Specially for desktop applications. I used to work with J2EE and i did deployment only for web projects.
Now i have developed a small desktop application. Its based on java swing. My application gonna serve on windows and linux systems. Now i want to deploy my application along with all libraries etc.
Simply i dont know how to do that. I googled for such a thing but no success. Can i pack my...
|
by: coopdog |
last post by:
This is a new issue as of an install to sp1 on vb express 2005. When I publish the application to my drive then I try to install it is wants to be installed from the same location as it was originally install.
Any help would be great it is a real pain having to uninstall then install this update.
Also all users are admins.
Thanks
Mike
|
by: Andrus |
last post by:
I created .NET 3.5 SP1 Winforms application setup by pressing publish button
in VCSE 2008 SP1
Running created setup.exe in same computer causes error below "Reference in
the manifest does not match the identity of the downloaded
assembly RdlDesigner.exe."
and application is not installed.
RDLDesigner.exe file is application created using VCSE 2008
How to fix ?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |