Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
f0948384
Unverified
Commit
f0948384
authored
Oct 11, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix excluded files appearing in package_data
Fixes #431
parent
11c62cb8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
137 additions
and
4 deletions
+137
-4
CHANGELOG.md
+1
-0
poetry/masonry/builders/sdist.py
+22
-4
tests/masonry/builders/fixtures/default_with_excluded_data/LICENSE
+20
-0
tests/masonry/builders/fixtures/default_with_excluded_data/README.rst
+2
-0
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/__init__.py
+0
-0
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/data/data1.txt
+0
-0
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/data/sub_data/data2.txt
+0
-0
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/data/sub_data/data3.txt
+0
-0
tests/masonry/builders/fixtures/default_with_excluded_data/pyproject.toml
+39
-0
tests/masonry/builders/test_sdist.py
+53
-0
No files found.
CHANGELOG.md
View file @
f0948384
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
-
Fixed a recursion error on duplicate dependencies with only different extras.
-
Fixed a recursion error on duplicate dependencies with only different extras.
-
Fixed handling of extras.
-
Fixed handling of extras.
-
Fixed duplicate entries in both sdist and wheel.
-
Fixed duplicate entries in both sdist and wheel.
-
Fixed excluded files appearing in the
`package_data`
of the generated
`setup.py`
.
## [0.11.5] - 2018-09-04
## [0.11.5] - 2018-09-04
...
...
poetry/masonry/builders/sdist.py
View file @
f0948384
...
@@ -223,8 +223,7 @@ class SdistBuilder(Builder):
...
@@ -223,8 +223,7 @@ class SdistBuilder(Builder):
return
encode
(
pkg_info
)
return
encode
(
pkg_info
)
@classmethod
def
find_packages
(
self
,
include
):
def
find_packages
(
cls
,
include
):
"""
"""
Discover subpackages and data.
Discover subpackages and data.
...
@@ -255,6 +254,7 @@ class SdistBuilder(Builder):
...
@@ -255,6 +254,7 @@ class SdistBuilder(Builder):
# Relative to the top-level package
# Relative to the top-level package
return
pkg_name
,
rel_path
return
pkg_name
,
rel_path
excluded_files
=
self
.
find_excluded_files
()
for
path
,
dirnames
,
filenames
in
os
.
walk
(
str
(
base
),
topdown
=
True
):
for
path
,
dirnames
,
filenames
in
os
.
walk
(
str
(
base
),
topdown
=
True
):
if
os
.
path
.
basename
(
path
)
==
"__pycache__"
:
if
os
.
path
.
basename
(
path
)
==
"__pycache__"
:
continue
continue
...
@@ -270,10 +270,28 @@ class SdistBuilder(Builder):
...
@@ -270,10 +270,28 @@ class SdistBuilder(Builder):
packages
.
append
(
"."
.
join
([
pkg_name
]
+
parts
))
packages
.
append
(
"."
.
join
([
pkg_name
]
+
parts
))
else
:
else
:
pkg
,
from_nearest_pkg
=
find_nearest_pkg
(
from_top_level
)
pkg
,
from_nearest_pkg
=
find_nearest_pkg
(
from_top_level
)
pkg_data
[
pkg
]
.
append
(
pjoin
(
from_nearest_pkg
,
"*"
))
data_elements
=
[
f
.
relative_to
(
self
.
_path
)
for
f
in
Path
(
path
)
.
glob
(
"*"
)
if
not
f
.
is_dir
()
]
data
=
[
e
for
e
in
data_elements
if
e
not
in
excluded_files
]
if
not
data
:
continue
if
len
(
data
)
==
len
(
data_elements
):
pkg_data
[
pkg
]
.
append
(
pjoin
(
from_nearest_pkg
,
"*"
))
else
:
for
d
in
data
:
if
d
.
is_dir
():
continue
pkg_data
[
pkg
]
+=
[
pjoin
(
from_nearest_pkg
,
d
.
name
)
for
d
in
data
]
# Sort values in pkg_data
# Sort values in pkg_data
pkg_data
=
{
k
:
sorted
(
v
)
for
(
k
,
v
)
in
pkg_data
.
items
()}
pkg_data
=
{
k
:
sorted
(
v
)
for
(
k
,
v
)
in
pkg_data
.
items
()
if
v
}
return
pkgdir
,
sorted
(
packages
),
pkg_data
return
pkgdir
,
sorted
(
packages
),
pkg_data
...
...
tests/masonry/builders/fixtures/default_with_excluded_data/LICENSE
0 → 100644
View file @
f0948384
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.
tests/masonry/builders/fixtures/default_with_excluded_data/README.rst
0 → 100644
View file @
f0948384
My Package
==========
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/__init__.py
0 → 100644
View file @
f0948384
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/data/data1.txt
0 → 100644
View file @
f0948384
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/data/sub_data/data2.txt
0 → 100644
View file @
f0948384
tests/masonry/builders/fixtures/default_with_excluded_data/my_package/data/sub_data/data3.txt
0 → 100644
View file @
f0948384
tests/masonry/builders/fixtures/default_with_excluded_data/pyproject.toml
0 → 100644
View file @
f0948384
[tool.poetry]
name
=
"my-package"
version
=
"1.2.3"
description
=
"Some description."
authors
=
[
"Sébastien Eustace <sebastien@eustace.io>"
]
license
=
"MIT"
readme
=
"README.rst"
homepage
=
"https://poetry.eustace.io/"
repository
=
"https://github.com/sdispater/poetry"
documentation
=
"https://poetry.eustace.io/docs"
keywords
=
[
"packaging"
,
"dependency"
,
"poetry"
]
classifiers
=
[
"Topic :: Software Development :: Build Tools"
,
"Topic :: Software Development :: Libraries :: Python Modules"
]
# Requirements
[tool.poetry.dependencies]
python
=
"^3.6"
cleo
=
"^0.6"
cachy
=
{
version
=
"^0.2.0"
,
extras
=
["msgpack"]
}
pendulum
=
{
version
=
"^1.4"
,
optional
=
true
}
[tool.poetry.dev-dependencies]
pytest
=
"~3.4"
[tool.poetry.extras]
time
=
["pendulum"]
[tool.poetry.scripts]
my-script
=
"my_package:main"
my-2nd-script
=
"my_package:main2"
tests/masonry/builders/test_sdist.py
View file @
f0948384
...
@@ -406,6 +406,7 @@ def test_package_with_include(mocker):
...
@@ -406,6 +406,7 @@ def test_package_with_include(mocker):
exec
(
compile
(
setup_ast
,
filename
=
"setup.py"
,
mode
=
"exec"
),
ns
)
exec
(
compile
(
setup_ast
,
filename
=
"setup.py"
,
mode
=
"exec"
),
ns
)
assert
"package_dir"
not
in
ns
assert
"package_dir"
not
in
ns
assert
ns
[
"packages"
]
==
[
"extra_dir"
,
"extra_dir.sub_pkg"
,
"package_with_include"
]
assert
ns
[
"packages"
]
==
[
"extra_dir"
,
"extra_dir.sub_pkg"
,
"package_with_include"
]
assert
ns
[
"package_data"
]
==
{
""
:
[
"*"
]}
assert
ns
[
"modules"
]
==
[
"my_module"
]
assert
ns
[
"modules"
]
==
[
"my_module"
]
builder
.
build
()
builder
.
build
()
...
@@ -431,6 +432,58 @@ def test_package_with_include(mocker):
...
@@ -431,6 +432,58 @@ def test_package_with_include(mocker):
assert
"with-include-1.2.3/PKG-INFO"
in
names
assert
"with-include-1.2.3/PKG-INFO"
in
names
def
test_default_with_excluded_data
(
mocker
):
# Patch git module to return specific excluded files
p
=
mocker
.
patch
(
"poetry.vcs.git.Git.get_ignored_files"
)
p
.
return_value
=
[
str
(
Path
(
__file__
)
.
parent
/
"fixtures"
/
"default_with_excluded_data"
/
"my_package"
/
"data"
/
"sub_data"
/
"data2.txt"
)
]
poetry
=
Poetry
.
create
(
project
(
"default_with_excluded_data"
))
builder
=
SdistBuilder
(
poetry
,
NullEnv
(),
NullIO
())
# Check setup.py
setup
=
builder
.
build_setup
()
setup_ast
=
ast
.
parse
(
setup
)
setup_ast
.
body
=
[
n
for
n
in
setup_ast
.
body
if
isinstance
(
n
,
ast
.
Assign
)]
ns
=
{}
exec
(
compile
(
setup_ast
,
filename
=
"setup.py"
,
mode
=
"exec"
),
ns
)
assert
"package_dir"
not
in
ns
assert
ns
[
"packages"
]
==
[
"my_package"
]
assert
ns
[
"package_data"
]
==
{
""
:
[
"*"
],
"my_package"
:
[
"data/*"
,
"data/sub_data/data3.txt"
],
}
builder
.
build
()
sdist
=
(
fixtures_dir
/
"default_with_excluded_data"
/
"dist"
/
"my-package-1.2.3.tar.gz"
)
assert
sdist
.
exists
()
with
tarfile
.
open
(
str
(
sdist
),
"r"
)
as
tar
:
names
=
tar
.
getnames
()
assert
len
(
names
)
==
len
(
set
(
names
))
assert
"my-package-1.2.3/LICENSE"
in
names
assert
"my-package-1.2.3/README.rst"
in
names
assert
"my-package-1.2.3/my_package/__init__.py"
in
names
assert
"my-package-1.2.3/my_package/data/data1.txt"
in
names
assert
"my-package-1.2.3/pyproject.toml"
in
names
assert
"my-package-1.2.3/setup.py"
in
names
assert
"my-package-1.2.3/PKG-INFO"
in
names
def
test_proper_python_requires_if_single_version_specified
():
def
test_proper_python_requires_if_single_version_specified
():
poetry
=
Poetry
.
create
(
project
(
"simple_version"
))
poetry
=
Poetry
.
create
(
project
(
"simple_version"
))
...
...
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