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
8055bcf4
Unverified
Commit
8055bcf4
authored
Sep 19, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support PEP-517 officially
parent
58e3676c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
9 deletions
+106
-9
docs/docs/pyproject.md
+19
-0
poetry/layouts/layout.py
+15
-0
poetry/masonry/api.py
+15
-9
poetry/masonry/builders/wheel.py
+2
-0
tests/masonry/test_api.py
+55
-0
No files found.
docs/docs/pyproject.md
View file @
8055bcf4
...
@@ -217,3 +217,22 @@ To match the example in the setuptools documentation, you would use the followin
...
@@ -217,3 +217,22 @@ To match the example in the setuptools documentation, you would use the followin
[tool.poetry.plugins."blogtool.parsers"]
[tool.poetry.plugins."blogtool.parsers"]
".rst"
=
"some_module:SomeClass"
".rst"
=
"some_module:SomeClass"
```
```
## Poetry and PEP-517
[
PEP-517
](
https://www.python.org/dev/peps/pep-0517/
)
introduces a standard way
to define alternative build systems to build a Python project.
Poetry is compliant with PEP-517 so if you use Poetry to manage your Python
project you should reference it in the
`build-system`
section of the
`pyproject.toml`
file like so:
```
toml
[build-system]
requires
=
["poetry>=0.12"]
build-backend
=
"poetry.masonry.api"
```
!!!note
When using the `new` or `init` command this section will be automatically added.
poetry/layouts/layout.py
View file @
8055bcf4
from
tomlkit
import
dumps
from
tomlkit
import
dumps
from
tomlkit
import
loads
from
tomlkit
import
loads
from
tomlkit
import
table
from
poetry.utils.helpers
import
module_name
from
poetry.utils.helpers
import
module_name
...
@@ -37,6 +38,9 @@ license = ""
...
@@ -37,6 +38,9 @@ license = ""
[tool.poetry.dev-dependencies]
[tool.poetry.dev-dependencies]
"""
"""
BUILD_SYSTEM_MIN_VERSION
=
"0.12"
BUILD_SYSTEM_MAX_VERSION
=
None
class
Layout
(
object
):
class
Layout
(
object
):
def
__init__
(
def
__init__
(
...
@@ -102,6 +106,17 @@ class Layout(object):
...
@@ -102,6 +106,17 @@ class Layout(object):
for
dep_name
,
dep_constraint
in
self
.
_dev_dependencies
.
items
():
for
dep_name
,
dep_constraint
in
self
.
_dev_dependencies
.
items
():
poetry_content
[
"dev-dependencies"
][
dep_name
]
=
dep_constraint
poetry_content
[
"dev-dependencies"
][
dep_name
]
=
dep_constraint
# Add build system
build_system
=
table
()
build_system_version
=
">="
+
BUILD_SYSTEM_MIN_VERSION
if
BUILD_SYSTEM_MAX_VERSION
is
not
None
:
build_system_version
+=
",<"
+
BUILD_SYSTEM_MAX_VERSION
build_system
.
add
(
"requires"
,
[
"poetry"
+
build_system_version
])
build_system
.
add
(
"build-backend"
,
"poetry.masonry.api"
)
content
.
add
(
"build-system"
,
build_system
)
return
dumps
(
content
)
return
dumps
(
content
)
def
_create_default
(
self
,
path
,
src
=
True
):
def
_create_default
(
self
,
path
,
src
=
True
):
...
...
poetry/masonry/api.py
View file @
8055bcf4
...
@@ -8,6 +8,7 @@ from pathlib import Path
...
@@ -8,6 +8,7 @@ from pathlib import Path
from
poetry.poetry
import
Poetry
from
poetry.poetry
import
Poetry
from
poetry.io
import
NullIO
from
poetry.io
import
NullIO
from
poetry.utils._compat
import
unicode
from
poetry.utils.env
import
SystemEnv
from
poetry.utils.env
import
SystemEnv
from
.builders
import
SdistBuilder
from
.builders
import
SdistBuilder
...
@@ -15,17 +16,16 @@ from .builders import WheelBuilder
...
@@ -15,17 +16,16 @@ from .builders import WheelBuilder
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
# PEP 517 specifies that the CWD will always be the source tree
poetry
=
Poetry
.
create
(
"."
)
def
get_requires_for_build_wheel
(
config_settings
=
None
):
def
get_requires_for_build_wheel
(
config_settings
=
None
):
"""
"""
Returns a list of requirements for building, as strings
Returns a list of requirements for building, as strings
"""
"""
main
,
extras
=
SdistBuilder
.
convert_dependencies
(
poetry
.
package
.
requires
)
poetry
=
Poetry
.
create
(
"."
)
main
,
_
=
SdistBuilder
.
convert_dependencies
(
poetry
.
package
,
poetry
.
package
.
requires
)
return
main
+
extras
return
main
# For now, we require all dependencies to build either a wheel or an sdist.
# For now, we require all dependencies to build either a wheel or an sdist.
...
@@ -34,15 +34,21 @@ get_requires_for_build_sdist = get_requires_for_build_wheel
...
@@ -34,15 +34,21 @@ get_requires_for_build_sdist = get_requires_for_build_wheel
def
build_wheel
(
wheel_directory
,
config_settings
=
None
,
metadata_directory
=
None
):
def
build_wheel
(
wheel_directory
,
config_settings
=
None
,
metadata_directory
=
None
):
"""Builds a wheel, places it in wheel_directory"""
"""Builds a wheel, places it in wheel_directory"""
info
=
WheelBuilder
.
make_in
(
poetry
,
NullIO
(),
Path
(
wheel_directory
)
)
poetry
=
Poetry
.
create
(
"."
)
return
info
.
file
.
name
return
unicode
(
WheelBuilder
.
make_in
(
poetry
,
SystemEnv
(
Path
(
sys
.
prefix
)),
NullIO
(),
Path
(
wheel_directory
)
)
)
def
build_sdist
(
sdist_directory
,
config_settings
=
None
):
def
build_sdist
(
sdist_directory
,
config_settings
=
None
):
"""Builds an sdist, places it in sdist_directory"""
"""Builds an sdist, places it in sdist_directory"""
path
=
SdistBuilder
(
poetry
,
SystemEnv
(
sys
.
prefix
),
NullIO
())
.
build
(
poetry
=
Poetry
.
create
(
"."
)
path
=
SdistBuilder
(
poetry
,
SystemEnv
(
Path
(
sys
.
prefix
)),
NullIO
())
.
build
(
Path
(
sdist_directory
)
Path
(
sdist_directory
)
)
)
return
path
.
name
return
unicode
(
path
.
name
)
poetry/masonry/builders/wheel.py
View file @
8055bcf4
...
@@ -48,6 +48,8 @@ class WheelBuilder(Builder):
...
@@ -48,6 +48,8 @@ class WheelBuilder(Builder):
wb
=
WheelBuilder
(
poetry
,
env
,
io
,
target_dir
=
directory
,
original
=
original
)
wb
=
WheelBuilder
(
poetry
,
env
,
io
,
target_dir
=
directory
,
original
=
original
)
wb
.
build
()
wb
.
build
()
return
wb
.
wheel_filename
@classmethod
@classmethod
def
make
(
cls
,
poetry
,
env
,
io
):
def
make
(
cls
,
poetry
,
env
,
io
):
"""Build a wheel in the dist/ directory, and optionally upload it."""
"""Build a wheel in the dist/ directory, and optionally upload it."""
...
...
tests/masonry/test_api.py
0 → 100644
View file @
8055bcf4
import
os
import
tarfile
import
zipfile
from
contextlib
import
contextmanager
from
poetry.masonry
import
api
from
poetry.utils.helpers
import
temporary_directory
@contextmanager
def
cwd
(
directory
):
prev
=
os
.
getcwd
()
os
.
chdir
(
str
(
directory
))
try
:
yield
finally
:
os
.
chdir
(
prev
)
fixtures
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"builders"
,
"fixtures"
)
def
test_get_requires_for_build_wheel
():
expected
=
[
"cleo>=0.6.0,<0.7.0"
,
"cachy[msgpack]>=0.2.0,<0.3.0"
]
with
cwd
(
os
.
path
.
join
(
fixtures
,
"complete"
)):
api
.
get_requires_for_build_wheel
()
==
expected
def
test_get_requires_for_build_sdist
():
expected
=
[
"cleo>=0.6.0,<0.7.0"
,
"cachy[msgpack]>=0.2.0,<0.3.0"
]
with
cwd
(
os
.
path
.
join
(
fixtures
,
"complete"
)):
api
.
get_requires_for_build_sdist
()
==
expected
def
test_build_wheel
():
with
temporary_directory
()
as
tmp_dir
,
cwd
(
os
.
path
.
join
(
fixtures
,
"complete"
)):
filename
=
api
.
build_wheel
(
tmp_dir
)
with
zipfile
.
ZipFile
(
str
(
os
.
path
.
join
(
tmp_dir
,
filename
)))
as
zip
:
namelist
=
zip
.
namelist
()
assert
"my_package-1.2.3.dist-info/entry_points.txt"
in
namelist
assert
"my_package-1.2.3.dist-info/WHEEL"
in
namelist
assert
"my_package-1.2.3.dist-info/METADATA"
in
namelist
def
test_build_sdist
():
with
temporary_directory
()
as
tmp_dir
,
cwd
(
os
.
path
.
join
(
fixtures
,
"complete"
)):
filename
=
api
.
build_sdist
(
tmp_dir
)
with
tarfile
.
open
(
str
(
os
.
path
.
join
(
tmp_dir
,
filename
)))
as
tar
:
namelist
=
tar
.
getnames
()
assert
"my-package-1.2.3/LICENSE"
in
namelist
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