Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
0b99bde8
Commit
0b99bde8
authored
Mar 22, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created PEP420PackageFinder, whose .find method can be used to find any suitable directory.
parent
d3969808
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
20 deletions
+13
-20
setuptools/__init__.py
setuptools/__init__.py
+6
-4
setuptools/tests/test_find_packages.py
setuptools/tests/test_find_packages.py
+7
-16
No files found.
setuptools/__init__.py
View file @
0b99bde8
...
...
@@ -79,10 +79,7 @@ class PackageFinder(object):
@
staticmethod
def
_looks_like_package
(
path
):
return
(
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
'__init__.py'
))
or
sys
.
version_info
[:
2
]
>=
(
3
,
3
)
# PEP 420
)
return
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
'__init__.py'
))
@
staticmethod
def
_build_filter
(
*
patterns
):
...
...
@@ -92,6 +89,11 @@ class PackageFinder(object):
"""
return
lambda
name
:
any
(
fnmatchcase
(
name
,
pat
=
pat
)
for
pat
in
patterns
)
class
PEP420PackageFinder
(
PackageFinder
):
@
staticmethod
def
_looks_like_package
(
path
):
return
True
find_packages
=
PackageFinder
.
find
setup
=
distutils
.
core
.
setup
...
...
setuptools/tests/test_find_packages.py
View file @
0b99bde8
"""Tests for setuptools.find_packages()."""
import
os
import
shutil
import
sys
import
tempfile
import
unittest
import
setuptools
from
setuptools
import
find_packages
from
setuptools.tests.py26compat
import
skipIf
PEP420
=
sys
.
version_info
[:
2
]
>=
(
3
,
3
)
find_420_packages
=
setuptools
.
PEP420PackageFinder
.
find
class
TestFindPackages
(
unittest
.
TestCase
):
...
...
@@ -63,7 +60,6 @@ class TestFindPackages(unittest.TestCase):
fp
.
close
()
return
path
@
skipIf
(
PEP420
,
'Not a PEP 420 env'
)
def
test_regular_package
(
self
):
self
.
_touch
(
'__init__.py'
,
self
.
pkg_dir
)
packages
=
find_packages
(
self
.
dist_dir
)
...
...
@@ -90,35 +86,30 @@ class TestFindPackages(unittest.TestCase):
def
_assert_packages
(
self
,
actual
,
expected
):
self
.
assertEqual
(
set
(
actual
),
set
(
expected
))
@
skipIf
(
not
PEP420
,
'PEP 420 only'
)
def
test_pep420_ns_package
(
self
):
packages
=
find_packages
(
packages
=
find_
420_
packages
(
self
.
dist_dir
,
include
=
[
'pkg*'
],
exclude
=
[
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
skipIf
(
not
PEP420
,
'PEP 420 only'
)
def
test_pep420_ns_package_no_includes
(
self
):
packages
=
find_packages
(
packages
=
find_
420_
packages
(
self
.
dist_dir
,
exclude
=
[
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
skipIf
(
not
PEP420
,
'PEP 420 only'
)
def
test_pep420_ns_package_no_includes_or_excludes
(
self
):
packages
=
find_packages
(
self
.
dist_dir
)
packages
=
find_
420_
packages
(
self
.
dist_dir
)
expected
=
[
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
,
'pkg.subpkg.assets'
]
self
.
_assert_packages
(
packages
,
expected
)
@
skipIf
(
not
PEP420
,
'PEP 420 only'
)
def
test_regular_package_with_nested_pep420_ns_packages
(
self
):
self
.
_touch
(
'__init__.py'
,
self
.
pkg_dir
)
packages
=
find_packages
(
packages
=
find_
420_
packages
(
self
.
dist_dir
,
exclude
=
[
'docs'
,
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
skipIf
(
not
PEP420
,
'PEP 420 only'
)
def
test_pep420_ns_package_no_non_package_dirs
(
self
):
shutil
.
rmtree
(
self
.
docs_dir
)
shutil
.
rmtree
(
os
.
path
.
join
(
self
.
dist_dir
,
'pkg/subpkg/assets'
))
packages
=
find_packages
(
self
.
dist_dir
)
packages
=
find_
420_
packages
(
self
.
dist_dir
)
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment