473,287 Members | 1,643 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

pyo contains absolute paths

Hi!

When I "compile" my python files with "python -OO ...." into pyo files
then they still contain absolute paths of the source files which is
undesirable for me. How can I deal with that?

Thank you.

David

Jul 21 '05 #1
6 1859
David Siroky wrote:
When I "compile" my python files with "python -OO ...." into pyo files
then they still contain absolute paths of the source files which is
undesirable for me. How can I deal with that?


Don't do that?

Delete the pyo files?

Stop using Python?

I could guess at a few more possibilities, but since you don't actually
say what you *want* to happen, just what you don't want to happen, there
are an infinite number of ways to satisfy you right now. <wink>

(Hint #1: absolute paths are always, AFAIK, put into the .pyc or .pyo
files.)

(Hint #2: maybe explaining why you don't want this to happen would help
too, since that will probably determine the "best" solution.)

-Peter
Jul 21 '05 #2
ncf
Python is compiling the files with absolute paths because it is much
faster to load a file when you know where it is, than to have to find
it and then load it.

I'm guessing you're wondering this so you can distribute it compiled or
such? If so, I wouldn't do that in the first place. Python's compiled
files might be version/architecture dependant.

-NcF

Jul 21 '05 #3
V Sat, 09 Jul 2005 10:22:06 -0400, Peter Hansen napsal(a):
David Siroky wrote:
When I "compile" my python files with "python -OO ...." into pyo files
then they still contain absolute paths of the source files which is
undesirable for me. How can I deal with that?


Don't do that?

Delete the pyo files?

Stop using Python?

I could guess at a few more possibilities, but since you don't actually
say what you *want* to happen, just what you don't want to happen, there
are an infinite number of ways to satisfy you right now. <wink>

(Hint #1: absolute paths are always, AFAIK, put into the .pyc or .pyo
files.)

(Hint #2: maybe explaining why you don't want this to happen would help
too, since that will probably determine the "best" solution.)

-Peter


I want to write a commercial application in Python and I don't want the
customer to see the source code and absolute paths of my modules which
have btw. the same base path as the main module so I would expect only
relative paths in the compiled files.

David

Jul 21 '05 #4
V Sat, 09 Jul 2005 11:48:51 -0700, ncf napsal(a):
Python is compiling the files with absolute paths because it is much
faster to load a file when you know where it is, than to have to find
it and then load it.

I'm guessing you're wondering this so you can distribute it compiled or
such? If so, I wouldn't do that in the first place. Python's compiled
files might be version/architecture dependant.

-NcF


I want to write a commercial application in Python and I don't want the
customer to see the source code and absolute paths of my modules which
have btw. the same base path as the main module so I would expect only
relative paths in the compiled files.

David

Jul 21 '05 #5
David Siroky <ds*****@email.cz> writes:
Hi!

When I "compile" my python files with "python -OO ...." into pyo files
then they still contain absolute paths of the source files which is
undesirable for me. How can I deal with that?


Are you trying to save space? In 2.4 and later each code object will
contain the same copy of the absolute path, so you can't save that
much space.

There are probably ways to make .pycs that have a path of "", if you
really want (see py_compile in the stdlib).

Cheers,
mwh

--
I located the link but haven't bothered to re-read the article,
preferring to post nonsense to usenet before checking my facts.
-- Ben Wolfson, comp.lang.python
Jul 21 '05 #6
David Siroky wrote:
When I "compile" my python files with "python -OO ...." into pyo files
then they still contain absolute paths of the source files which is
undesirable for me. How can I deal with that?


Use the script compileall.py (in Lib) to compile all the files. This
script has an option -d <dir> that allows to set the directory name
compiled into the .pyo files.

From the help: "-d destdir: purported directory name for error messages"

Daniel
Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: William Starr Moake | last post by:
Another problem with absolute paths in the WYSIWYG editor I'm putting together. The function to toggle between WYSIWYG and HTML modes works except for one glitch. If you use a relative path for...
7
by: Rizaan Jappie | last post by:
is it possible to get the relative path based on a absolute path in c#? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
0
by: Jason Lawrence | last post by:
I have an attributed ATL project (call it B) that I am building with Microsoft Visual C++ .NET (55537-640-3684941- 18356). In the project I include the COM generated file A.h (from another ATL...
2
by: David Cho | last post by:
This is a simple issue I am trying to figure out. How would I express absolute paths to various aspx files in the aspx page. I am not intereted in relative paths. For example, I want to...
0
by: Chris Gill | last post by:
I'm trying to use cookieless sessions in asp.net using the InProc mode (for various reasons it is not desirable for us to use the other modes if it is possible to avoid them). My problem revolves...
3
by: JeffDotNet | last post by:
I wrote a small data processing application that writes a summary of several hundred files. I use drag and drop on a panel (Panel1) to grab the absolute path to each of these files. Then I begin...
19
by: Jerry M. Gartner | last post by:
Greetings: What is the best way to resolve paths within a document regardless of what path it is opened under? For example: I have x.php and it contains <img src="images...">, (amongst other...
6
by: Jon Slaughter | last post by:
do I have to prefix every absolute path with document root to get it to work? For some reason I thought that prefixing a path with '/' or './' with make it absolute w.r.t to document root but I...
6
by: Konrad Hinsen | last post by:
I am trying to install Python from sources in my home directory on a Mac cluster (running MacOS X 10.4.8). The path to my home directory contains a blank, and since the installation procedure...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.