Commit 783fb9a5 by Sébastien Eustace

Automatically add LICENSE file to built packages

parent 68f3791b
......@@ -23,6 +23,7 @@
- Improved support for private repositories.
- Expanded version constraints now keep the original version's precision.
- The lock file hash no longer use the project's name and version.
- The `LICENSE` file, or similar, is now automatically added to the built packages.
### Fixed
......
# Third Party Libraries
Poetry
......@@ -103,6 +103,16 @@ class Builder(object):
)
to_add.append(Path('pyproject.toml'))
# If a license file exists, add it
for license_file in self._path.glob('LICENSE*'):
self._io.writeln(
' - Adding: <comment>{}</comment>'.format(
license_file.relative_to(self._path)
),
verbosity=self._io.VERBOSITY_VERY_VERBOSE
)
to_add.append(license_file.relative_to(self._path))
# If a README is specificed we need to include it
# to avoid errors
if 'readme' in self._poetry.local_config:
......
Copyright (c) 2018 Sébastien Eustace
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
......@@ -156,6 +156,7 @@ def test_find_files_to_add():
result = builder.find_files_to_add()
assert result == [
Path('LICENSE'),
Path('README.rst'),
Path('my_package/__init__.py'),
Path('my_package/data1/test.json'),
......@@ -176,6 +177,10 @@ def test_package():
assert sdist.exists()
tar = tarfile.open(str(sdist), 'r')
assert 'my-package-1.2.3/LICENSE' in tar.getnames()
def test_module():
poetry = Poetry.create(project('module1'))
......
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