ccpgames / pypackage

Tools to package python from static metadata
MIT License
25 stars 4 forks source link

Error with certain arguments to `find_packages` #13

Open Zearin opened 8 years ago

Zearin commented 8 years ago

In my pypackage.meta:

...
"packages":     "find_packages('src', include=['cucumber','cucumber.*'])",
...

When I run py-build, I get the following error:

error: package directory 'src/find_packages('src', include=['cucumber','cucumber/*'])' does not exist

I realize that exclude=[…] is the more common kwarg to find_packages. However, according to the setuptools documentation “Using find_packages, the find_packages function accepts a starting dir, and “two lists of package name patterns to exclude and include”.

(You can reproduce this bug using the same steps as described in #12. ☻ )

Zearin commented 8 years ago

(Edit: Added link to #12 for steps to reproduce.)

Zearin commented 8 years ago

I just figured out that the issue is not include=[…], but rather the presence of a comma for either include or exclude.

So include=['cucumber'] works, but include=['cucumber', 'anything_else'] fails.

a-tal commented 8 years ago

I don't think it's the , that's breaking this. find_packages is recursive in nature... I made another package inside the src directory and that seemed to work fine. (for your example mkdir anything_else && touch anything_else/__init__.py)

Zearin commented 8 years ago

I don't think it's the , that's breaking this. find_packages is recursive in nature...

Huh. I am unsure the issue is, then…

The reason I assumed it was a comment is because I originally had include=['cucumber', 'cucumber.*'], but removing the second item resulted in no error.

For reference, the setuptools docs for find_packages says:

Inclusion and exclusion patterns are package names, optionally including wildcards. For example, find_packages(exclude=["*.tests"]) will exclude all packages whose last name part is tests. Or, find_packages(exclude=["*.tests", "*.tests.*"]) will also exclude any subpackages of packages named tests, but it still won’t exclude a top-level tests package or the children thereof. In fact, if you really want no tests packages at all, you’ll need something like this:

find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"])

Although I don’t really need cucumber.* at the moment, I plan on restructuring the package hierarchy such that I will need it in the future.

(I was just learning how the hell setuptools decides which files to include or exclude, and messing around with pypackage.meta until I figured out what’s what. I got the error and decided to report it here. I thought

When I got an error, I checked the official docs on find_packages, and it looks like the arguments should be legal, so I decided to report this issue. I was excited when I thought I had found the cause of the error…but apparently not. (I’ve been staring at my screen too long. :P)

Zearin commented 8 years ago

I just noticed:

So the dot (.) is being replaced with os.sep. If that’s happening right before printing the error, then I don’t think it’s the problem; but if it’s happening when parsing pypackage.meta, perhaps that might be the cause…?

a-tal commented 8 years ago

from reading the include docs, it makes me think it has more to do with the /, since it uses fnmatch