Commit 22dfb29b by Boris Feld Committed by Sébastien Eustace

Find excluded files no vcs (#590)

* Add a new test for the case where no vcs is detected

It can happens with unsupported VCS or no VCS at all (building from an
archive).
I copy the test_complete test and run it in a temporary directory where no VCS
should be detected.
I also modified the complete directory fixture directory, I can create a new
one if it's better

* Fix find_excluded_files to works without vcs

Fix #585
parent 3feff049
......@@ -43,14 +43,16 @@ class Builder(object):
# Checking VCS
vcs = get_vcs(self._path)
if not vcs:
return []
vcs_ignored_files = []
else:
vcs_ignored_files = vcs.get_ignored_files()
explicitely_excluded = []
for excluded_glob in self._package.exclude:
for excluded in self._path.glob(excluded_glob):
explicitely_excluded.append(excluded)
ignored = vcs.get_ignored_files() + explicitely_excluded
ignored = vcs_ignored_files + explicitely_excluded
result = []
for file in ignored:
try:
......
......@@ -20,6 +20,10 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules"
]
exclude = [
"**/*.xml"
]
# Requirements
[tool.poetry.dependencies]
python = "^3.6"
......
......@@ -7,6 +7,7 @@ import shutil
import sys
import tarfile
import zipfile
import tempfile
from poetry import __version__
from poetry.io import NullIO
......@@ -164,6 +165,105 @@ My Package
zip.close()
def test_complete_no_vcs():
# Copy the complete fixtures dir to a temporary directory
module_path = fixtures_dir / "complete"
temporary_dir = Path(tempfile.mkdtemp()) / "complete"
shutil.copytree(module_path.as_posix(), temporary_dir.as_posix())
builder = CompleteBuilder(
Poetry.create(temporary_dir), NullEnv(execute=True), NullIO()
)
builder.build()
whl = temporary_dir / "dist" / "my_package-1.2.3-py3-none-any.whl"
assert whl.exists()
zip = zipfile.ZipFile(str(whl))
# Check the zipped file to be sure that included and excluded files are
# correctly taken account of without vcs
expected_name_list = [
"my_package/__init__.py",
"my_package/data1/test.json",
"my_package/sub_pkg1/__init__.py",
"my_package/sub_pkg2/__init__.py",
"my_package/sub_pkg2/data2/data.json",
"my_package-1.2.3.dist-info/entry_points.txt",
"my_package-1.2.3.dist-info/LICENSE",
"my_package-1.2.3.dist-info/WHEEL",
"my_package-1.2.3.dist-info/METADATA",
"my_package-1.2.3.dist-info/RECORD",
]
assert sorted(zip.namelist()) == sorted(expected_name_list)
try:
entry_points = zip.read("my_package-1.2.3.dist-info/entry_points.txt")
assert (
decode(entry_points.decode())
== """\
[console_scripts]
extra-script=my_package.extra:main[time]
my-2nd-script=my_package:main2
my-script=my_package:main
"""
)
wheel_data = decode(zip.read("my_package-1.2.3.dist-info/WHEEL"))
assert (
wheel_data
== """\
Wheel-Version: 1.0
Generator: poetry {}
Root-Is-Purelib: true
Tag: py3-none-any
""".format(
__version__
)
)
wheel_data = decode(zip.read("my_package-1.2.3.dist-info/METADATA"))
assert (
wheel_data
== """\
Metadata-Version: 2.1
Name: my-package
Version: 1.2.3
Summary: Some description.
Home-page: https://poetry.eustace.io/
License: MIT
Keywords: packaging,dependency,poetry
Author: Sébastien Eustace
Author-email: sebastien@eustace.io
Requires-Python: >=3.6,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: time
Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0)
Requires-Dist: cleo (>=0.6,<0.7)
Requires-Dist: pendulum (>=1.4,<2.0); extra == "time"
Project-URL: Documentation, https://poetry.eustace.io/docs
Project-URL: Repository, https://github.com/sdispater/poetry
Description-Content-Type: text/x-rst
My Package
==========
"""
)
finally:
zip.close()
def test_module_src():
module_path = fixtures_dir / "source_file"
builder = CompleteBuilder(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment