2

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?

2
  • Not sure if this will help you, but if you're "not ready to make it public", you can install your package using python setup.py develop. This is what I typically do if I have a package that I want to use but it's "not ready to be made public". Commented Feb 25, 2013 at 18:45
  • Part of what I'm doing is to test the end-users installation experience before it goes live, which is why I'm going this route. I know it's not apples to apples, but it should still work. Commented Feb 25, 2013 at 18:46

1 Answer 1

3

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']
Sign up to request clarification or add additional context in comments.

4 Comments

Yup. Just figured that out. As an aside, the Pytjon Setup Doc is poorly written. Not at all friendly to new package authors.
doremi: I’d love to get your feedback to improve the docs. Could you open a report on bugs.python.org or if you prefer send me a mail? (my address is on my profile)
@ÉricAraujo: I had the same problem for the same reason despite following the official guide. I guess that it would be a great idea to get a step-by-step guide for the simplest user case (I want to share a pure python package between my projects and import it as if it was inside the file without having to copy it each time). Including a project structure, setup structure and step by step guide before explaining what is the wheel, PEP naming conventions and Co would be a great plus for the newcomers like myself.
Well, the page your linked to in your question does start with an example that uses packages=[...].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.