Skip to content

Instantly share code, notes, and snippets.

@macagua
Created February 6, 2013 14:24
Show Gist options
  • Save macagua/4722804 to your computer and use it in GitHub Desktop.
Save macagua/4722804 to your computer and use it in GitHub Desktop.
A setuptools configuration (setup.py) for define the package name
# the package name
name = 'collective.mypackage'
# get packages from the package name: '1.2.3' -> ['1','1.2','1.2.3']
>>> packages = [name.rsplit('.',x)[0] for x in reversed(range(len(name.split('.'))))]
>>> packages
['collective', 'collective.mypackage']
>>> # all except the last are treated as namespace_packages
>>> namespace_packages = packages[:-1]
>>> namespace_packages
['collective']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment