简体   繁体   中英

How to build a setup.py with directories of files

My setup.py looks like this

setup = (
    name='foo',
    packages=['bin'],
    package_data={'':['data/*.dat','data/usr/*/*.dat']},
)   

And my directory looks like,

main_directory\
     main.py
     bin\
       modules.py
       functions.py
     data\
       main_data.dat
         otherdata\
            otherdata.dat

main.py is the controller of the the functions and modules, are there any problems with my package structures? How can I build a right setup.py and after install I can open it from terminal?

I think you've misunderstood the setup.py creation. In the distutils (and setuptools ) package there's a function called setup() . I think you want tu use it, but you're creating a tuple and assigning it to a variable called setup . Also, name should be a string.

It should be like this:

from distutils.core import setup

setup(
    name='foo',
    packages=['bin'],
    package_data={'':['data/*.dat','data/usr/*/*.dat']},
)

You can install the above (saved as setup.py ) using:

python setup.py install

After this is done, you can use your package in the Python shell or other Python files like this:

import foo
from foo.bin.modules import whatever
whatever()
# assuming you have a function called whatever in bin/modules.py

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM