473,378 Members | 1,407 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,378 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 1861
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.