Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
/ python-egg Public archive

Python base egg with developer environment

License

Notifications You must be signed in to change notification settings

KiraLT/python-egg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-egg

Python base egg with developer environment

setup.py

The setup script is the centre of all activity in building, distributing, and installing modules using the Distutils or enchanted version- setuptools. We will use setuptools couse it is better.

Setuptools example:

from setuptools import setup, find_packages
setup(
    name='myegg',
    version='1.0.0',
    install_requires=[
    ],
    packages=find_packages(exclude=['tests']),
    entry_points={
        'console_scripts': [
            'myegg = myegg.commands:run'
        ]
    },
    test_suite='tests'
)
  • name - your package name, don't forget to rename myapp directory if you change package name in config
  • version - used for package versioning
  • install_requires - list of python dependencies
  • packages - let setuptools find sub packages automaticaly (e.g. myapp.helpers, myapp.apps.hello)
  • entry_points - generate custom bin script, in this example it will generate bin/myegg bash script which will execute run function from myegg.commands
  • test_suite - run tests from tests package

Tests

Python egg has a great Unit tests support. It will automaticaly find and run tests from tests package.

Runnning tests

With bash script:
./test.sh
Manually:
python setup.py test

Install in develop mode

You can install your egg localy in developer mode. Then you will be able to frequently edit your code and not have to re-install your package to run it.

Installation requiries virtualenv (virtualenv is a tool to create isolated Python environments):

pip install virtualenv
With bash script:
./install.sh
Manually:
virtualenv -p python
bin/python setup.py develop

Not you can use bin scripts from entry_points:

bin/myapp

'HELLO WORLD'

Build .egg

The .egg file is a distribution format for Python packages. It’s just an alternative to a source code distribution or Windows exe. But note that for pure Python, the egg file is completely cross-platform.

With bash script:
./build.sh
Manually:
python setup.py bdist_egg

You fill find you .egg in dist directory: dist/myegg-1.0.0-py2.7.egg

Submit a package to PyPI

Tutorial

Python 3

For bash script to use python 3 change python.txt content to python3

About

Python base egg with developer environment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published