473,811 Members | 3,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1885
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.pytho n
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
3121
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 a link, like <a href="download.htm">Click Here</a>, the editor returns an absolute path the second time you toggle HTML mode: <a href="C:\Windows\Desktop\Editor\download.htm" and even adds file:/// on the third try. This path must be manually...
7
78649
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
1308
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 project A). The compiler interprets this and injects the command "import A.idl" into the idl for B. So far everything is okay. The problem is that when I build project B in debug, it references A.idl using the absolute path. When I build...
2
1202
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 encapsulate a HyperLink control in a user control. Of course this user control can go anywhere vin various subfolders, but when the link is clicked, I would like to set NavigateUrl to a the same target page. So a rlative path won't work. Thanks.
0
1321
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 around the use of absolute and relative paths under this mode. Obviously absolute paths break the sessionId tracking in the url, which in our system relates to the user logins, causing the users to be logged off immediately. Clearly the simple...
3
1894
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 analyzing all of the files. I noticed (on the same machine) that some user profiles appear to abbreviate the absolute paths to these files thus breaking my data loading mechanism. Does anyone know how I can programmatically change this filepath...
19
5115
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 things, like php code), which resolves the correct image path when opened under / but when x.php is read into a file under /dir the image no longer resolves, for obvious reasons. With absolute paths, this isn't an issue but it is with relative...
6
3180
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 guess not? e.g., when I do include './Scripts/AddNav.php';
6
1246
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 insists on getting an absolute path for the prefix, I cannot avoid installing to a path whose name contains a blank. Python does not seem to be prepared for this, as it uses only the part before the blank, resulting in numerous error messages. Does...
0
9730
marktang
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...
0
9605
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,...
0
10651
Oralloy
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...
0
10392
jinu1996
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...
0
9208
agi2029
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...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5555
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.