Scripts in python package

You need relative imports. Try

from .. import mypackage

or

from ..mypackage import server

The documentation is here

http://docs.python.org/tutorial/modules.html#intra-package-references

These work on Python 2.5 or newer.

To do it only in the development version, try:

try:
    from my_package import server
except ImportError:
    from ..my_package import server

You can use virtualenv for testing Python code while in development as if it was released


The simplest way is to configure the right Python path, so Python knows to look for my_package in the current directory.

On Linux (using Bash):

export PYTHONPATH=.
bin/server-run

On Windows:

set PYTHONPATH=.
python bin/server-run

There is the console_scripts approach now. See e.g.

entry_points={
      'console_scripts': [
        'wikibackup = wikibot.wikipush:mainBackup',   
        'wikiedit = wikibot.wikipush:mainEdit',
        'wikinuke = wikibot.wikipush:mainNuke',
        'wikipush = wikibot.wikipush:mainPush',
        'wikiupload = wikibot.wikipush:mainUpload',
        'wikiuser = wikibot.wikiuser:main',
      ],
    },

from https://pypi.org/project/py-3rdparty-mediawiki/ (where i am a committer).

If you do a pip install of that package the above scripts will be installed as part of the installation process.

see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/blob/master/setup.py for the full source code of the setup script.