Hi folks,
Running Python 2.5 on both a Windows XP laptop, and an Ubuntu Linux
7.04 desktop.
I've gotten tired of maintaining multiple copies of my personal
modules that I use over and over. I have copies of these files in the
same directory as the main program I happen to be working on at the
time. I've also downloaded FANN, and want to use its Python
bindings. FANN does not seem to build automatically, like wxWidgets
did.
These two issues have led me to examine exactly how the import
statement works, how the PYTHONPATH environment variable is
constructed, and how to change it.
On Windows I found a solution that works, but which may be a kludge.
In the Python "site-packages" folder, I added a sub-folder called "my-
packages". Then I created a text file, "my-packages.pth", containing
the single line, "my-packages." Finally, I moved my common personal
modules into the my-packages folder and deleted all of my clumsy
duplicates. Import statements now work for all of my files on the
Windows box, great!
I then tried to use this same strategy in Linux, and saw that I don't
automatically have the privileges needed to alter the site-packages
folder. On my Windows box, my default account has Administrator
privileges. On Linux I can, of course, use sudo to modify the site-
packages folder. But the fact that I would have to use sudo has me
asking -- is there something inappropriate, or unsafe in my approach?
I want to know what is the *recommended* way to integrate my own
personal modules with Python. Thanks! 5 2412
John Ladasky <la*****@my-deja.comwrites:
I want to know what is the *recommended* way to integrate my own
personal modules with Python. Thanks!
You want the 'distutils' documentation
<URL:http://www.python.org/doc/lib/module-distutilsand the documents
that it references, which will lead you to write a 'setup.py' module
for your package.
Then, it's a matter of running 'python ./setup.py install' to install
your package on a particular system.
--
\ "I hope if dogs ever take over the world, and they chose a |
`\ king, they don't just go by size, because I bet there are some |
_o__) Chihuahuas with some good ideas." -- Jack Handey |
Ben Finney
On Jun 3, 6:52 pm, Ben Finney <bignose+hates-s...@benfinney.id.au>
wrote:
John Ladasky <lada...@my-deja.comwrites:
I want to know what is the *recommended* way to integrate my own
personal modules with Python. Thanks!
You want the 'distutils' documentation
<URL:http://www.python.org/doc/lib/module-distutilsand the documents
that it references, which will lead you to write a 'setup.py' module
for your package.
Many thanks, Ben, distutils was exactly what I needed. It was a
little strange to grasp the concept that I would be "distributing" my
module to myself -- but once I got over that mental hurdle, it worked
perfectly.
On Tue, 03 Jun 2008 17:57:07 -0700, John Ladasky wrote:
Hi folks,
Running Python 2.5 on both a Windows XP laptop, and an Ubuntu Linux
7.04 desktop.
I've gotten tired of maintaining multiple copies of my personal
modules that I use over and over. I have copies of these files in the
same directory as the main program I happen to be working on at the
time.
I just make some directory outside of the python source, say
/usr/local/lib/python. I then add that to my PYTHONPATH.
Now the permissions are not a problem, and the libs are
automatically available to any version of python on the system.
** Posted from http://www.teranews.com **
"John Ladasky" <la*****@my-deja.comwrote in message
news:49**********************************@m44g2000 hsc.googlegroups.com...
| On Windows I found a solution that works, but which may be a kludge.
| In the Python "site-packages" folder, I added a sub-folder called "my-
| packages". Then I created a text file, "my-packages.pth", containing
| the single line, "my-packages." Finally, I moved my common personal
| modules into the my-packages folder and deleted all of my clumsy
| duplicates. Import statements now work for all of my files on the
| Windows box, great!
|
| I then tried to use this same strategy in Linux, and saw that I don't
| automatically have the privileges needed to alter the site-packages
| folder. On my Windows box, my default account has Administrator
| privileges.
If you do the Windows install for all users, all users can add packages to
site-packages -- as long as adding the package directory comprises the
whole installation process and no registry fiddling is required.
John Ladasky <la*****@my-deja.comwrote in
news:49**********************************@m44g2000 hsc.googlegroups.
com:
Hi folks,
Running Python 2.5 on both a Windows XP laptop, and an Ubuntu
Linux 7.04 desktop.
I've gotten tired of maintaining multiple copies of my personal
modules that I use over and over. I have copies of these files
in the same directory as the main program I happen to be working
on at the time. I've also downloaded FANN, and want to use its
Python bindings. FANN does not seem to build automatically,
like wxWidgets did.
These two issues have led me to examine exactly how the import
statement works, how the PYTHONPATH environment variable is
constructed, and how to change it.
On Windows I found a solution that works, but which may be a
kludge. In the Python "site-packages" folder, I added a
sub-folder called "my- packages". Then I created a text file,
"my-packages.pth", containing the single line, "my-packages."
Finally, I moved my common personal modules into the my-packages
folder and deleted all of my clumsy duplicates. Import
statements now work for all of my files on the Windows box,
great!
I then tried to use this same strategy in Linux, and saw that I
don't automatically have the privileges needed to alter the
site-packages folder. On my Windows box, my default account has
Administrator privileges. On Linux I can, of course, use sudo
to modify the site- packages folder. But the fact that I would
have to use sudo has me asking -- is there something
inappropriate, or unsafe in my approach?
I want to know what is the *recommended* way to integrate my own
personal modules with Python. Thanks!
I can't speak about Linux, but on Windows, you really should move
your code out of the Python directory tree, I believe. When you
upgrade, you'll have to be sure to set it up the same way again,
and remember that your code resides there before you wipe out that
directory tree, etc.
Instead, just set up another directory containing your code and add
that to your PYTHONPATH environment variable string. That will be
unaffected by the Python version you're running, and will be
available for multiple versions, if you run more than one.
--
rzed This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Markus Doering |
last post by:
Hello,
I just switched from 2.2 to Python 2.3.
I am developing an XML/CGI interface to databases as a python package called
"unitWrapper" containing several modules which ran fine under v2.2.
...
|
by: Manlio Perillo |
last post by:
Hi.
I'm a new user of Python but I have noted a little problem.
Python is a very good language but it is evolving, in particular its
library is evolving.
This can be a problem when, ad example,...
|
by: Steve Holden |
last post by:
This is even stranger: it makes it if I import the module a second time:
import dbimp as dbimp
import sys
if __name__ == "__main__":
dbimp.install()
#k = sys.modules.keys()
#k.sort()
#for...
|
by: Olivier Noblanc ATOUSOFT |
last post by:
Hello,
When i want to import a .py fire from another subdirectory i make
import inc/setupxml
but that make me an error message.
|
by: Peter Saffrey |
last post by:
I'm trying to write a python service, with an executable in
/usr/local/bin, but modules that are kept in a sub-directory of
/usr/lib/python/site-packages.
Using apt-proxy as my template, I've...
|
by: mohan |
last post by:
Hi Guys,
I've been using the following IDE,
"Pythonwin - Python IDE and GUI Framework for Windows.
Copyright 1994-2001 Mark Hammond "
With respect to my work, I had created my own modules...
|
by: jack139 |
last post by:
I installed zope under windows and found a problem when import addition
modules - iHotfix and itools. When place itools in python's library
path, site-packages, import works fine. When place itools...
|
by: luca72 |
last post by:
Hello i can't import cherrypy2 but i don't know why this is the sys
path:
'', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/
setuptools-0.6c7-py2.5.egg',...
|
by: ssecorp |
last post by:
Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
import.modules
Also, is there anything like Cpan for Python?
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| | |