[Pythonmac-SIG] Distutils for research?

Bob Ippolito bob at redivi.com
Tue Dec 13 21:18:33 CET 2005


On Dec 13, 2005, at 12:12 PM, Bob Ippolito wrote:

>
> On Dec 13, 2005, at 11:36 AM, Schollnick, Benjamin wrote:
>
>>
>>> Is distutils more for distributing packages/modules than developing?
>>
>> The only situation I use distutils is for installing packages/ 
>> modules,
>> and distributing the software that I write (via py2app & py2exe).
>>
>> To my knowledge distutils is primarily for distributing packages &
>> modules...
>
> It's the only good way to compile extensions, which makes it
> infinitely useful for extension development as well.
>
> However, setuptools is also useful for pure Python development,
> because setup.py develop goes ahead and checks all your dependencies
> and adds your working copy to sys.path (ensuring that it doesn't
> conflict with something already installed).  Normally I would
> manually generate a pth file to add my working copy to sys.path, but
> creating a minimal setup.py is easier than dealing with any of that.
> It can also create scripts via entry points, which saves more time.
>
> crack:~/src/MyPackage bob$ cd ~
> crack:~ bob$ mkdir -p src/MyPackage/MyPackage
> crack:~ bob$ cd src/MyPackage
> crack:~/src/MyPackage bob$ touch MyPackage/__init__.py
> crack:~/src/MyPackage bob$ cat - > setup.py
> #!/usr/bin/env python
> from setuptools import setup, find_packages
> setup(name="MyPackage", version="1.0", packages=find_packages())
> crack:~/src/MyPackage bob$ python setup.py develop
> running develop
> running egg_info
> creating MyPackage.egg-info
> writing ./MyPackage.egg-info/PKG-INFO
> writing top-level names to ./MyPackage.egg-info/top_level.txt
> running build_ext
> Creating /Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/MyPackage.egg-link (link to .)
> Adding MyPackage 1.0 to easy-install.pth file
>
> Installed /Volumes/Crack/src/MyPackage
> Processing dependencies for MyPackage==1.0
> crack:~/src/MyPackage bob$ cd ~
> crack:~ bob$ python -c "import MyPackage; print MyPackage.__file__"
> /Volumes/Crack/src/MyPackage/MyPackage/__init__.py

One thing I forgot to mention, is that setuptools also provides for  
painless uninstallation.

crack:~/src/MyPackage bob$ python setup.py develop -u
running develop
Removing /Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/MyPackage.egg-link (link to .)
Removing MyPackage 1.0 from easy-install.pth file
crack:~/src/MyPackage bob$ cd ~
crack:~ bob$ python -c "import MyPackage; print MyPackage.__file__"
Traceback (most recent call last):
   File "<string>", line 1, in ?
ImportError: No module named MyPackage

-bob



More information about the Pythonmac-SIG mailing list