Best way to deal with .pyc files?

Mathieu Arnold mat at FreeBSD.org
Thu Dec 13 09:35:10 UTC 2018


On Mon, Dec 10, 2018 at 11:22:49AM -0800, John Baldwin wrote:
> On 12/7/18 10:17 AM, John Baldwin wrote:
> > On 12/6/18 11:17 AM, Michael Gmelin wrote:
> >>
> >>
> >>> On 6. Dec 2018, at 19:21, John Baldwin <jhb at freebsd.org> wrote:
> >>>
> >>> The devel/gdb port installs python scripts into /usr/local/share/gdb<ver>/python.
> >>> If you then run kgdb as root (not that unusual), it will generate .pyc files in
> >>> those directories that are not deleted by 'pkg delete'.  What is the best way to
> >>> handle this case?  Should the pkg-plist include @rmtry entries for each pyc
> >>> file or is there a better way?
> >>>
> >>
> >> Pre-generate the pyc files on package build and install them with the port, so they become part of plist (there are examples of that in the ports tree, whenever possible for both py27 and py3x).
> > 
> > Ok.  One follow-up question.  GDB's python bindings work with both py2 and
> > py3, but the bindings are optional.  Right now PYTHON is a port option
> > (but on by default).  If I wanted to add flavors I would probably want them
> > to be conditional on the option, so the results would be 'gdb' and
> > 'gdb-py3' packages by default, but if someone was using poudriere locally
> > and disabled python, I would only want to build a single 'gdb' without
> > python.  So, can I make the flavors conditional on an option or is it too
> > late to define flavors after including bsd.ports.options.mk?
> > 
> > That is, can I do something this:
> > 
> > OPTIONS_DEFINE= PYTHON
> > OPTIONS_DEFAULT= PYTHON
> > 
> > .include <bsd.port.pre.mk>
> > 
> > .if ${PORT_OPTIONS:MPYTHON}
> > USES_PYTHON= flavors
> > .endif
> 
> FYI, this worked:

All things considered, it does not matter when you set
USE_PYTHON=flavors because it does nothing if USES does not contain python.

-- 
Mathieu Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20181213/ffadc9e3/attachment.sig>


More information about the freebsd-ports mailing list