I'm planning to switch away from /usr/bin/env python to being explicit
about python2.5 as that's the OS X python version we require.
Anyone have any objections?
I'm also unsure about the new module layout, we basically have:
/Library/Application Support/crankd/PyMacAdmin/crankd
which feels wrong.
I'm not sure I'm entirely happy with the idea of
/Library/Application Support/PyMacAdmin/crankd
though....
thoughts?
Currently there is no explicit relationship required between
PyMacAdmin and crankd. The utility methods in the PyMacAdmin module
aren't necessary at all for crankd, and I'm tempted to say that we
shouldn't require them. The stuff that is there I feel would work
better in a Carbon module or something.
The longer term goal is to simply have a package install, and I'd like
to push forward with crankd as a standalone project.
Of course I don't know for sure what was going on in Chris' head, so
may be missing the point here :)
1. The PyMacAdmin code goes in the standard Python locations - e.g.
/Library/Python/2.5/site-packages - as you'd get with a basic install.
The idea being that you shouldn't need to play games to get it into
the default path simply to get "import PyMacAdmin" to work and
"easy_install pymacadmin" works like other Python packages.
2. /Library/Application Support/PyMacAdmin and
$HOME/Library/Application Support/PyMacAdmin are placed into the
default python path so users can install whatever code they write
there.
3. crankd looks for its config in /Library/Preferences and
$HOME/Library/Preferences, following expected behaviour for Mac apps.
As far as a separate install goes, it's not a bad idea since crankd is
a pretty separate beast. The one catch is that I'd been planning to
separate the event handlers out to avoid having one massive .py file
but that might not be necessary with a bit of code cleanup since the
current structure is a bit suboptimal (not surprising given how
quickly it was hacked together last spring). Here's what I had in
mind:
/Library/Python/2.5/site-packages/PyMacAdmin has the entire project
/Library/Python/2.5/site-packages /PyMacAdmin/crankd/__init__.py has
some library code and each of the different event handlers could be
broken into a separate file:
/Library/Python/2.5/site-packages /PyMacAdmin/crankd/FSEvents.py
/Library/Python/2.5/site-packages /PyMacAdmin/crankd/NSWorkspace.py
etc.
The idea being that each one could inherit from a base EventSource
class (getting rid of some of the hokey duplicate code in crankd now)
and we could add some niceties for event handlers cleaning up the raw
event data before calling user code.
Thinking about this, however, it could also be done in a single large
crankd file - the biggest benefit is going to be refactoring the
existing code into smarter classes and cleaning up some of the
structural oddities which crept in along the way.
Chris
> Thinking about this, however, it could also be done in a single large
> crankd file - the biggest benefit is going to be refactoring the
> existing code into smarter classes and cleaning up some of the
> structural oddities which crept in along the way.
Honestly, this is what I'm leaning towards.
I don't quite see that we're going to do much in crankd itself that is
worth creating a module for so other tools can use it?
> I don't quite see that we're going to do much in crankd itself that is
> worth creating a module for so other tools can use it?
I'm not sure I agree. I think having the event listening code
available to python projects outside of crankd would be valuable.
The biggest issue with using crankd from within python right now is
that to have your python function called in response to an event, it
has to resolve from a string to something on the python path. This
makes it harder to harness crankd functionality from various projects
The sticky part is the runloop - its simple to have everything in one
place with one runloop. The timer hack to keep the runloop responsive
could be avoided (in the Dev Docs it says to avoid this technique) if
each event watched for had its own thread and runloop. Each thread
would lay quiet until the event happened and then callback into python
code.
However I think all of the above comes after some cleanup work to
crankd - since it is a major change and involves tricky interaction of
NSThreads and python code.
-Preston
(groups having issues. re-sending)
What is gained? This will mess with any use in a Python virtualenvI'm not going to put up a huge fight on this, but I'm totally againstenv, particularly in environments like Mac OS X where you can have abunch of completely different python interpreters installed.
If you want to assert > 2.4 - then why not just test the pythonversion and error if condition not met?Because it's not just the version that matters. I have an install ofPython 2.6 on this computer that crankd can't work with.
PyMacAdmin should be migrated to be a regular python package installedon the python path (either a virtualenv or site-packages)It should also be renamed to pymacadmin to conform to convention (PEP 8)Cocoa and PyObjC dictate completely different method names and classstructures to PEP 8. We can't just follow PEP 8 unfortunately, but weshould where we can.I just don't think pymacadmin is a very good name for a module.
I forgot to address this.
I really just dislike general purpose names altogether, and would
rather see us come up with several decent modules that are targeted at
certain functionality rather than bundling everything into a
macadmin/madmin/mactools module.
This is somewhat orthogonal to this discussion as far as getting a
packageable version of crankd out there for people.
-Greg
I'm entirely comfortable just using PyMacAdmin as a google-friendly
project / repository name and distributing more granular packages. I
think there's value in having e.g. the entire collection of
Cocoa/Carbon-bridge wrappers under lib sharing code since there's at
least some utility overlap (e.g. the carbon error handling code) but
the image unit testing framework and crankd have nothing in common
with each other or those libraries.
Chris