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
d792134b
Unverified
Commit
d792134b
authored
Mar 23, 2019
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for VCS dependencies when building
parent
c0d6d7bc
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
15 deletions
+108
-15
poetry/packages/dependency.py
+19
-13
poetry/packages/vcs_dependency.py
+11
-0
tests/masonry/builders/fixtures/with_vcs_dependency/pyproject.toml
+24
-0
tests/masonry/builders/fixtures/with_vcs_dependency/with_vcs_dependency/__init__.py
+0
-0
tests/masonry/builders/test_sdist.py
+8
-2
tests/masonry/builders/test_wheel.py
+24
-0
tests/packages/test_vcs_dependency.py
+22
-0
No files found.
poetry/packages/dependency.py
View file @
d792134b
...
...
@@ -127,6 +127,24 @@ class Dependency(object):
def
in_extras
(
self
):
# type: () -> list
return
self
.
_in_extras
@property
def
base_pep_508_name
(
self
):
# type: () -> str
requirement
=
self
.
pretty_name
if
self
.
extras
:
requirement
+=
"[{}]"
.
format
(
","
.
join
(
self
.
extras
))
if
isinstance
(
self
.
constraint
,
VersionUnion
):
requirement
+=
" ({})"
.
format
(
","
.
join
([
str
(
c
)
.
replace
(
" "
,
""
)
for
c
in
self
.
constraint
.
ranges
])
)
elif
isinstance
(
self
.
constraint
,
Version
):
requirement
+=
" (=={})"
.
format
(
self
.
constraint
.
text
)
elif
not
self
.
constraint
.
is_any
():
requirement
+=
" ({})"
.
format
(
str
(
self
.
constraint
)
.
replace
(
" "
,
""
))
return
requirement
def
allows_prereleases
(
self
):
return
self
.
_allows_prereleases
...
...
@@ -156,19 +174,7 @@ class Dependency(object):
)
def
to_pep_508
(
self
,
with_extras
=
True
):
# type: (bool) -> str
requirement
=
self
.
pretty_name
if
self
.
extras
:
requirement
+=
"[{}]"
.
format
(
","
.
join
(
self
.
extras
))
if
isinstance
(
self
.
constraint
,
VersionUnion
):
requirement
+=
" ({})"
.
format
(
","
.
join
([
str
(
c
)
.
replace
(
" "
,
""
)
for
c
in
self
.
constraint
.
ranges
])
)
elif
isinstance
(
self
.
constraint
,
Version
):
requirement
+=
" (=={})"
.
format
(
self
.
constraint
.
text
)
elif
not
self
.
constraint
.
is_any
():
requirement
+=
" ({})"
.
format
(
str
(
self
.
constraint
)
.
replace
(
" "
,
""
))
requirement
=
self
.
base_pep_508_name
markers
=
[]
if
not
self
.
marker
.
is_any
():
...
...
poetry/packages/vcs_dependency.py
View file @
d792134b
...
...
@@ -62,6 +62,17 @@ class VCSDependency(Dependency):
return
"{} {}"
.
format
(
what
,
version
)
@property
def
base_pep_508_name
(
self
):
# type: () -> str
requirement
=
self
.
pretty_name
if
self
.
extras
:
requirement
+=
"[{}]"
.
format
(
","
.
join
(
self
.
extras
))
requirement
+=
" @ {}+{}@{}"
.
format
(
self
.
_vcs
,
self
.
_source
,
self
.
reference
)
return
requirement
def
is_vcs
(
self
):
# type: () -> bool
return
True
...
...
tests/masonry/builders/fixtures/with_vcs_dependency/pyproject.toml
0 → 100644
View file @
d792134b
[tool.poetry]
name
=
"with-vcs-dependency"
version
=
"1.2.3"
description
=
"Some description."
authors
=
[
"Sébastien Eustace <sebastien@eustace.io>"
]
license
=
"MIT"
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
=
{
git
=
"https://github.com/sdispater/cleo.git"
,
branch
=
"master"
}
tests/masonry/builders/fixtures/with_vcs_dependency/with_vcs_dependency/__init__.py
0 → 100644
View file @
d792134b
tests/masonry/builders/test_sdist.py
View file @
d792134b
# -*- coding: utf-8 -*-
import
ast
import
pytest
import
re
import
shutil
import
tarfile
...
...
@@ -11,6 +10,7 @@ from poetry.io import NullIO
from
poetry.masonry.builders.sdist
import
SdistBuilder
from
poetry.masonry.utils.package_include
import
PackageInclude
from
poetry.packages
import
Package
from
poetry.packages.vcs_dependency
import
VCSDependency
from
poetry.poetry
import
Poetry
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
to_str
...
...
@@ -49,9 +49,15 @@ def test_convert_dependencies():
get_dependency
(
"A"
,
"^1.0"
),
get_dependency
(
"B"
,
"~1.0"
),
get_dependency
(
"C"
,
"1.2.3"
),
VCSDependency
(
"D"
,
"git"
,
"https://github.com/sdispater/d.git"
),
],
)
main
=
[
"A>=1.0,<2.0"
,
"B>=1.0,<1.1"
,
"C==1.2.3"
]
main
=
[
"A>=1.0,<2.0"
,
"B>=1.0,<1.1"
,
"C==1.2.3"
,
"D @ git+https://github.com/sdispater/d.git@master"
,
]
extras
=
{}
assert
result
==
(
main
,
extras
)
...
...
tests/masonry/builders/test_wheel.py
View file @
d792134b
# -*- coding: utf-8 -*-
import
pytest
import
shutil
import
zipfile
from
email.parser
import
Parser
from
poetry.io
import
NullIO
from
poetry.masonry.builders
import
WheelBuilder
from
poetry.poetry
import
Poetry
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
to_str
from
poetry.utils.env
import
NullEnv
from
poetry.packages
import
ProjectPackage
...
...
@@ -144,3 +148,23 @@ def test_write_metadata_file_license_homepage_default(mocker):
# Assertion
mocked_file
.
write
.
assert_any_call
(
"Home-page: UNKNOWN
\n
"
)
mocked_file
.
write
.
assert_any_call
(
"License: UNKNOWN
\n
"
)
def
test_metadata_file_with_vcs_dependencies
():
project_path
=
fixtures_dir
/
"with_vcs_dependency"
WheelBuilder
.
make
(
Poetry
.
create
(
str
(
project_path
)),
NullEnv
(),
NullIO
())
whl
=
project_path
/
"dist"
/
"with_vcs_dependency-1.2.3-py3-none-any.whl"
assert
whl
.
exists
()
p
=
Parser
()
with
zipfile
.
ZipFile
(
str
(
whl
))
as
z
:
metadata
=
p
.
parsestr
(
to_str
(
z
.
read
(
"with_vcs_dependency-1.2.3.dist-info/METADATA"
))
)
requires_dist
=
metadata
[
"Requires-Dist"
]
assert
"cleo @ git+https://github.com/sdispater/cleo.git@master"
==
requires_dist
tests/packages/test_vcs_dependency.py
0 → 100644
View file @
d792134b
from
poetry.packages.vcs_dependency
import
VCSDependency
def
test_to_pep_508
():
dependency
=
VCSDependency
(
"poetry"
,
"git"
,
"https://github.com/sdispater/poetry.git"
)
expected
=
"poetry @ git+https://github.com/sdispater/poetry.git@master"
assert
expected
==
dependency
.
to_pep_508
()
def
test_to_pep_508_with_extras
():
dependency
=
VCSDependency
(
"poetry"
,
"git"
,
"https://github.com/sdispater/poetry.git"
)
dependency
.
extras
.
append
(
"foo"
)
expected
=
"poetry[foo] @ git+https://github.com/sdispater/poetry.git@master"
assert
expected
==
dependency
.
to_pep_508
()
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