doremi
doremi

Reputation: 15329

Custom Python Package Won't Properly Install via Pip In VirtualEnv

I've created a new python package for a project I'm working on.

It has a folder structure that resembles:

bin
docs
mypackage
license.md
readme.md
setup.py

Here are the contents of my setup.py:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'description': 'A python client for foo',
    'author': 'Me',
    'url': 'https://github.com/account/mypackage',
    'download_url': 'https://github.com/account/mypackage',
    'author_email': '[email protected]',
    'version': '0.1',
    'install_requires': ['nose'],
    'name': 'MyPackage'
}

setup(**config)

I'm not ready to make this public so I install it directly from Git via:

pip install git+ssh://[email protected]/account/mypackage.git

Here's the output:

Downloading/unpacking git+ssh://[email protected]/account/mypackage.git
  Cloning git+ssh://[email protected]/account/mypackage.git to /var/folders/7w/qsdf76s97sfsdf7sdf97sdf/T/pip-ovbMpR-build
  Running setup.py egg_info for package from git+ssh://[email protected]/account/mypackage.git

Downloading/unpacking nose (from MyPackage==0.1)
  Downloading nose-1.2.1.tar.gz (400kB): 400kB downloaded
  Running setup.py egg_info for package nose

    no previously-included directories found matching 'doc/.build'
Installing collected packages: nose, MyPackage
  Running setup.py install for nose

    no previously-included directories found matching 'doc/.build'
    Installing nosetests script to /Users/user/sandbox/.pyvirtualenvs/project/bin
    Installing nosetests-2.7 script to /Users/user/sandbox/.pyvirtualenvs/project/bin
  Running setup.py install for MyPackage

Successfully installed nose MyPackage
Cleaning up...

It says it installed correctly, but when I check /Users/user/sandbox/.pyvirtualenvs/project/bin - I don't see my MyPackage.

I see that nose was installed correctly, and it created a MyPackage-0.1-py2.7.egg-info/ directory - but no mypackage folder with my library.

Consequently, when I try to use the package, it cannot be found.

Why? Is my setup.py configured incorrectly?

Upvotes: 2

Views: 696

Answers (1)

rhettg
rhettg

Reputation: 2453

It doesn't appear you are actually instructing setup to install your package.

You'll need something like:

packages=['mypackage'],

in your setup() call. Checkout how py-bootstrap does it: https://github.com/splaice/py-bootstrap/blob/master/setup.py

For including bin scripts, you'll need to list your scripts with the scripts directive as well, for example:

scripts=['bin/myscript']

Upvotes: 3

Related Questions