Skip to content

Commit 3570640

Browse files
committed
excluding conftest.py under src/ploomber_engine
1 parent d13a54d commit 3570640

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ include CHANGELOG.md
44
include README.md
55
graft src/pkgmt/assets
66
global-exclude __pycache__
7-
global-exclude *.py[co]
7+
global-exclude *.py[co]

setup.py

+24
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import ast
33
from glob import glob
44
from os.path import basename, splitext
5+
import fnmatch
56

67
from setuptools import find_packages
78
from setuptools import setup
9+
from setuptools.command.build_py import build_py as build_py_orig
810

911
_version_re = re.compile(r"__version__\s+=\s+(.*)")
1012

@@ -49,6 +51,27 @@
4951
]
5052

5153

54+
exclude = ["*.conftest"]
55+
56+
57+
# this is the only way I found for excluding single .py files in wheels
58+
# (https://stackoverflow.com/a/50592100/709975). MANIFEST.in only applies to source
59+
# distributions. Some more info:
60+
# https://github.com/pypa/packaging.python.org/issues/306
61+
# https://github.com/pypa/setuptools/issues/511
62+
class build_py(build_py_orig):
63+
def find_package_modules(self, package, package_dir):
64+
modules = super().find_package_modules(package, package_dir)
65+
66+
return [
67+
(pkg, mod, file)
68+
for (pkg, mod, file) in modules
69+
if not any(
70+
fnmatch.fnmatchcase(pkg + "." + mod, pat=pattern) for pattern in exclude
71+
)
72+
]
73+
74+
5275
setup(
5376
name="ploomber-engine",
5477
version=VERSION,
@@ -58,6 +81,7 @@
5881
author_email=None,
5982
url=None,
6083
packages=find_packages("src"),
84+
cmdclass={"build_py": build_py},
6185
package_dir={"": "src"},
6286
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
6387
include_package_data=True,

0 commit comments

Comments
 (0)