Deleting python compiled files

Chuck Swiger cswiger at mac.com
Mon Aug 4 23:36:40 UTC 2008


On Aug 4, 2008, at 3:35 PM, ros wrote:
> Working in a port using python i'm facing this problem. If I run the  
> application after the install the py source files are compiled in  
> pyc (or pyo) files. This is good cause precompiled files provide  
> better performances.

Mildly.  :-)  The "compiled" or "optimized" .pyc/.pyo files mainly  
improve upon the time required to load them by the interpreter.

> The problem is deleting the port. The pyc files aren't registered in  
> the pkg-plist so the deletion isn't complete and I can't delete the  
> main directory containing the application files.
> If I add the pyc files, when I remove the port I receive an error  
> saying the checksum dosn't exist, and that's right.  So what's the  
> best way handle this problem ?

Anyway, to address your issue, most Python software uses a setup.py  
file which uses distutils, and that is supported by the BSD ports  
infrastructure via the USE_PYDISTUTILS option, which will call the  
setup.py with the right arguments to build the .pyc/.pyo files.  You  
can then list all of them in the pkg-plist and the right thing should  
happen from there.

If you'd like to see an example, check out one of the python ports  
which use this, such as /usr/ports/security/denyhosts; you'll see it  
listing:

%%PYTHON_SITELIBDIR%%/DenyHosts/loginattempt.py
%%PYTHON_SITELIBDIR%%/DenyHosts/loginattempt.pyc
%%PYTHON_SITELIBDIR%%/DenyHosts/loginattempt.pyo
[ ... ]

Regards,
-- 
-Chuck



More information about the freebsd-ports mailing list