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
b0e9e0cd
Unverified
Commit
b0e9e0cd
authored
Mar 16, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for Markdown README files
parent
deff8fa6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
50 deletions
+75
-50
CHANGELOG.md
+1
-0
poetry/masonry/builders/builder.py
+2
-0
poetry/masonry/builders/sdist.py
+14
-17
poetry/masonry/builders/wheel.py
+27
-23
poetry/masonry/metadata.py
+19
-3
poetry/masonry/publishing/publisher.py
+9
-1
poetry/packages/package.py
+1
-1
poetry/poetry.py
+1
-2
tests/test_poetry.py
+1
-3
No files found.
CHANGELOG.md
View file @
b0e9e0cd
...
...
@@ -8,6 +8,7 @@
-
Added the
`run`
command to execute commands inside the created virtualenvs.
-
Added the
`debug:resolve`
command to debug dependency resolution.
-
Added
`pyproject.toml`
file validation.
-
Added support for Markdown readme files.
### Fixed
...
...
poetry/masonry/builders/builder.py
View file @
b0e9e0cd
...
...
@@ -9,6 +9,7 @@ from poetry.semver.constraints import MultiConstraint
from
poetry.semver.version_parser
import
VersionParser
from
poetry.vcs
import
get_vcs
from
..metadata
import
Metadata
from
..utils.module
import
Module
...
...
@@ -33,6 +34,7 @@ class Builder:
self
.
_module
=
Module
(
self
.
_package
.
name
,
self
.
_path
.
as_posix
()
)
self
.
_meta
=
Metadata
.
from_package
(
self
.
_package
)
def
build
(
self
):
raise
NotImplementedError
()
...
...
poetry/masonry/builders/sdist.py
View file @
b0e9e0cd
...
...
@@ -89,14 +89,13 @@ class SdistBuilder(Builder):
tar_info
.
size
=
len
(
setup
)
tar
.
addfile
(
tar_info
,
BytesIO
(
setup
))
author
=
self
.
convert_author
(
self
.
_package
.
authors
[
0
])
pkg_info
=
PKG_INFO
.
format
(
name
=
self
.
_
package
.
name
,
version
=
self
.
_
package
.
version
,
summary
=
self
.
_
package
.
description
,
home_page
=
self
.
_
package
.
homepage
or
self
.
_package
.
repository_url
,
author
=
author
[
'name'
]
,
author_email
=
author
[
'email'
]
,
name
=
self
.
_
meta
.
name
,
version
=
self
.
_
meta
.
version
,
summary
=
self
.
_
meta
.
summary
,
home_page
=
self
.
_
meta
.
home_page
,
author
=
self
.
_meta
.
author
,
author_email
=
self
.
_meta
.
author_email
,
)
.
encode
(
'utf-8'
)
tar_info
=
tarfile
.
TarInfo
(
pjoin
(
tar_dir
,
'PKG-INFO'
))
...
...
@@ -146,21 +145,19 @@ class SdistBuilder(Builder):
extra
.
append
(
"'entry_points': entry_points,"
)
if
self
.
_package
.
python_versions
!=
'*'
:
python_requires
=
format_python_constraint
(
self
.
_package
.
python_constraint
)
python_requires
=
self
.
_meta
.
requires_python
extra
.
append
(
"'python_requires': {!r},"
.
format
(
python_requires
))
author
=
self
.
convert_author
(
self
.
_package
.
authors
[
0
])
return
SETUP
.
format
(
before
=
'
\n
'
.
join
(
before
),
name
=
self
.
_
package
.
name
,
version
=
self
.
_
package
.
version
,
description
=
self
.
_
package
.
description
,
long_description
=
self
.
_
package
.
readme
,
author
=
author
[
'name'
]
,
author_email
=
author
[
'email'
]
,
url
=
self
.
_
package
.
homepage
or
self
.
_package
.
repository_url
,
name
=
self
.
_
meta
.
name
,
version
=
self
.
_
meta
.
version
,
description
=
self
.
_
meta
.
summary
,
long_description
=
self
.
_
meta
.
description
,
author
=
self
.
_meta
.
author
,
author_email
=
self
.
_meta
.
author_email
,
url
=
self
.
_
meta
.
home_page
,
extra
=
'
\n
'
.
join
(
extra
),
after
=
'
\n
'
.
join
(
after
)
)
.
encode
(
'utf-8'
)
...
...
poetry/masonry/builders/wheel.py
View file @
b0e9e0cd
...
...
@@ -18,6 +18,7 @@ from poetry.semver.constraints import MultiConstraint
from
poetry.vcs
import
get_vcs
from
poetry.version.helpers
import
format_python_constraint
from
..metadata
import
Metadata
from
..utils.helpers
import
normalize_file_permissions
from
..utils.tags
import
get_abbr_impl
from
..utils.tags
import
get_abi_tag
...
...
@@ -292,36 +293,39 @@ class WheelBuilder(Builder):
def
_write_metadata_file
(
self
,
fp
):
"""
Write out metadata in the
1
.x format (email like)
Write out metadata in the
2
.x format (email like)
"""
fp
.
write
(
'Metadata-Version:
1.2
\n
'
)
fp
.
write
(
f
'Name: {self._
package
.name}
\n
'
)
fp
.
write
(
f
'Version: {self._
package
.version}
\n
'
)
fp
.
write
(
f
'Summary: {self._
package.description
}
\n
'
)
fp
.
write
(
f
'Home-page: {self._
package.homepage or self._package.repository_url
or "UNKNOWN"}
\n
'
)
fp
.
write
(
f
'License: {self._
package
.license or "UNKOWN"}
\n
'
)
fp
.
write
(
'Metadata-Version:
2.1
\n
'
)
fp
.
write
(
f
'Name: {self._
meta
.name}
\n
'
)
fp
.
write
(
f
'Version: {self._
meta
.version}
\n
'
)
fp
.
write
(
f
'Summary: {self._
meta.summary
}
\n
'
)
fp
.
write
(
f
'Home-page: {self._
meta.home_page
or "UNKNOWN"}
\n
'
)
fp
.
write
(
f
'License: {self._
meta
.license or "UNKOWN"}
\n
'
)
# Optional fields
if
self
.
_
package
.
keywords
:
fp
.
write
(
f
"Keywords: {
','.join(self._package.keywords)
}
\n
"
)
if
self
.
_
meta
.
keywords
:
fp
.
write
(
f
"Keywords: {
self._meta.keywords
}
\n
"
)
if
self
.
_
package
.
authors
:
author
=
self
.
convert_author
(
self
.
_package
.
authors
[
0
]
)
if
self
.
_
meta
.
author
:
fp
.
write
(
f
'Author: {self._meta.author}
\n
'
)
fp
.
write
(
f
'Author: {author["name"]}
\n
'
)
fp
.
write
(
f
'Author-email: {
author["email"]
}
\n
'
)
if
self
.
_meta
.
author_email
:
fp
.
write
(
f
'Author-email: {
self._meta.author_email
}
\n
'
)
if
self
.
_
package
.
python_versions
!=
'*'
:
python_requires
=
format_python_constraint
(
self
.
_package
.
python_constraint
)
if
self
.
_
meta
.
requires_python
:
fp
.
write
(
f
'Requires-Python: {self._meta.requires_python}
\n
'
)
fp
.
write
(
f
'Requires-Python: {python_requires}
\n
'
)
classifiers
=
self
.
get_classifers
()
for
classifier
in
classifiers
:
for
classifier
in
self
.
_meta
.
classifiers
:
fp
.
write
(
f
'Classifier: {classifier}
\n
'
)
for
dep
in
self
.
_package
.
requires
:
fp
.
write
(
'Requires-Dist: {}
\n
'
.
format
(
dep
.
to_pep_508
()))
for
dep
in
self
.
_meta
.
requires_dist
:
fp
.
write
(
f
'Requires-Dist: {dep}
\n
'
)
if
self
.
_meta
.
description_content_type
:
fp
.
write
(
f
'Description-Content-Type: '
f
'{self._meta.description_content_type}
\n
'
)
# TODO: Provides extra
if
self
.
_
package
.
readme
is
not
None
:
fp
.
write
(
'
\n
'
+
self
.
_
package
.
readme
+
'
\n
'
)
if
self
.
_
meta
.
description
is
not
None
:
fp
.
write
(
'
\n
'
+
self
.
_
meta
.
description
+
'
\n
'
)
poetry/masonry/metadata.py
View file @
b0e9e0cd
from
poetry.semver.constraints
import
MultiConstraint
from
poetry.utils.helpers
import
canonicalize_name
from
poetry.version.helpers
import
format_python_constraint
class
Metadata
:
metadata_version
=
'
1.2
'
metadata_version
=
'
2.1
'
# version 1.0
name
=
None
version
=
None
...
...
@@ -34,6 +33,10 @@ class Metadata:
obsoletes_dist
=
()
project_urls
=
()
# Version 2.1
description_content_type
=
None
provides_extra
=
[]
@classmethod
def
from_package
(
cls
,
package
)
->
'Metadata'
:
meta
=
cls
()
...
...
@@ -41,7 +44,10 @@ class Metadata:
meta
.
name
=
canonicalize_name
(
package
.
name
)
meta
.
version
=
package
.
version
meta
.
summary
=
package
.
description
meta
.
description
=
package
.
readme
if
package
.
readme
:
with
package
.
readme
.
open
()
as
f
:
meta
.
description
=
f
.
read
()
meta
.
keywords
=
','
.
join
(
package
.
keywords
)
meta
.
home_page
=
package
.
homepage
or
package
.
repository_url
meta
.
author
=
package
.
author_name
...
...
@@ -58,4 +64,14 @@ class Metadata:
# Requires python
meta
.
requires_python
=
format_python_constraint
(
package
.
python_constraint
)
# Version 2.1
if
package
.
readme
:
if
package
.
readme
.
suffix
==
'.rst'
:
meta
.
description_content_type
=
'text/x-rst'
elif
package
.
readme
.
suffix
in
[
'.md'
,
'.markdown'
]:
meta
.
description_content_type
=
'text/markdown'
else
:
meta
.
description_content_type
=
'text/plain'
# TODO: Provides extra
return
meta
poetry/masonry/publishing/publisher.py
View file @
b0e9e0cd
...
...
@@ -187,7 +187,7 @@ class Publisher:
else
:
py_version
=
None
return
{
data
=
{
# identify release
"name"
:
meta
.
name
,
"version"
:
meta
.
version
,
...
...
@@ -230,6 +230,14 @@ class Publisher:
"requires_python"
:
meta
.
requires_python
,
}
# Metadata 2.1
if
meta
.
description_content_type
:
data
[
'description_content_type'
]
=
meta
.
description_content_type
# TODO: Provides extra
return
data
def
_upload
(
self
,
session
,
url
):
dist
=
self
.
_poetry
.
file
.
parent
/
'dist'
packages
=
dist
.
glob
(
f
'{self._package.name}-{self._package.version}*'
)
...
...
poetry/packages/package.py
View file @
b0e9e0cd
...
...
@@ -69,7 +69,7 @@ class Package:
self
.
repository_url
=
None
self
.
keywords
=
[]
self
.
license
=
None
self
.
readme
=
''
self
.
readme
=
None
self
.
source_type
=
''
self
.
source_reference
=
''
...
...
poetry/poetry.py
View file @
b0e9e0cd
...
...
@@ -90,8 +90,7 @@ class Poetry:
package
.
keywords
=
local_config
.
get
(
'keywords'
,
[])
if
'readme'
in
local_config
:
with
open
(
poetry_file
.
parent
/
local_config
[
'readme'
])
as
f
:
package
.
readme
=
f
.
read
()
package
.
readme
=
Path
(
cwd
)
/
local_config
[
'readme'
]
if
'platform'
in
local_config
:
package
.
platform
=
local_config
[
'platform'
]
...
...
tests/test_poetry.py
View file @
b0e9e0cd
...
...
@@ -18,9 +18,7 @@ def test_poetry():
assert
package
.
description
==
'Some description.'
assert
package
.
authors
==
[
'Sébastien Eustace <sebastien@eustace.io>'
]
assert
package
.
license
==
'MIT'
assert
package
.
readme
==
"""My Package
==========
"""
assert
str
(
package
.
readme
.
relative_to
(
fixtures_dir
))
==
"sample_project/README.rst"
assert
package
.
homepage
==
'https://poetry.eustace.io'
assert
package
.
repository_url
==
'https://github.com/sdispater/poetry'
assert
package
.
keywords
==
[
"packaging"
,
"dependency"
,
"poetry"
]
...
...
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