Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find_packages doesn't find my Python file

I have a directory tree like this:

dir/
    A/
        __init__.py
        something.py

I used find_packages on dir/A and expected it to find something.py. However, it returned an empty list. How do I make find_packages find something.py as a package?

from setuptools import find_packages

packages = find_packages('c:/dir/A')
print(packages)
like image 908
Trying_hard Avatar asked Mar 23 '17 18:03

Trying_hard


People also ask

What is Find_packages in Setuptools?

Function defined in setuptools find_packages(where='.', exclude=()) Return a list all Python packages found within directory 'where' 'where' should be supplied as a “cross-platform” (i.e. URL-style) path; it will be converted to the appropriate local path syntax.

What is setup CFG Python?

The setup. cfg is an ini file, containing option defaults for setup.py commands. You can pretty much specify every keyword we used in the setup.py file in the new setup. cfg file and simply use the setup.py file as the command line interface.


1 Answers

You'd need to make it a package, it's a module right now. You would do this the same way you made the A package: create a directory with the package name, include an __init__.py file (in this case, you would rename something.py to __init__.py under the something directory).

find_packages('c:/dir') would find A, since A is a package under c:/dir.

like image 52
davidism Avatar answered Oct 02 '22 01:10

davidism