18

I vaguely remember some sort of setuptools wrapper that would generate .egg files from distutils source. Can someone jog my memory?

Ben
  • 2,422
  • 2
  • 16
  • 23

2 Answers2

25

setuptools monkey-patches some parts of distutils when it is imported. When you use easy_install to get a distutils-based project from PyPI, it will create an egg (pip may do that too). To do the same thing locally (i.e. in a directory that’s a code checkout or an unpacked tarball), use this trick: python -c "import setuptools; execfile('setup.py')" bdist_egg.

merwok
  • 6,779
  • 1
  • 28
  • 42
  • 1
    Exactly what I was looking for. Hopefully I won't have this hard a time finding it the next time I need it. Thanks. – Ben Apr 02 '12 at 03:57
  • 3
    In Python 3, `execfile` disappeared, so you'll want something like `python -c "import setuptools; exec(open('setup.py').read())" bdist_egg`. – Xiong Chiamiov Feb 26 '16 at 23:49
23

Have you tried

python setup.py bdist_egg

Here I assume you are using setuptools instead of distutils i.e.

in setup.py instead of

from distutils.core import setup

use

from setuptools import setup
Anurag Uniyal
  • 85,954
  • 40
  • 175
  • 219
  • 1
    Thanks, but looking for something that would turn someone else's distutils package into an egg. It does exist, as I found it before. – Ben Mar 30 '12 at 21:37
  • 2
    how I could build egg with "distutils" ? – zx1986 Jun 17 '13 at 13:17