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
a43c3baf
Unverified
Commit
a43c3baf
authored
May 26, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve files to publish detection and improve publish command
parent
bf061f93
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
26 deletions
+48
-26
CHANGELOG.md
+1
-0
poetry/console/commands/publish.py
+23
-4
poetry/masonry/publishing/publisher.py
+4
-0
poetry/masonry/publishing/uploader.py
+20
-22
No files found.
CHANGELOG.md
View file @
a43c3baf
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
-
Improved the
`show`
command to make it easier to check if packages are properly installed.
-
Improved the
`show`
command to make it easier to check if packages are properly installed.
-
The
`script`
command has been deprecated, use
`run`
instead.
-
The
`script`
command has been deprecated, use
`run`
instead.
-
The
`publish`
command no longer build packages by default. Use
`--build`
to retrieve the previous behavior.
-
Improved support for private repositories.
-
Improved support for private repositories.
-
Expanded version constraints now keep the original version's precision.
-
Expanded version constraints now keep the original version's precision.
-
The lock file hash no longer use the project's name and version.
-
The lock file hash no longer use the project's name and version.
...
...
poetry/console/commands/publish.py
View file @
a43c3baf
...
@@ -9,7 +9,7 @@ class PublishCommand(Command):
...
@@ -9,7 +9,7 @@ class PublishCommand(Command):
{ --r|repository= : The repository to publish the package to. }
{ --r|repository= : The repository to publish the package to. }
{ --u|username= : The username to access the repository. }
{ --u|username= : The username to access the repository. }
{ --p|password= : The password to access the repository. }
{ --p|password= : The password to access the repository. }
{ --
no-build : Do not b
uild the package before publishing. }
{ --
build : B
uild the package before publishing. }
"""
"""
help
=
"""The publish command builds and uploads the package to a remote repository.
help
=
"""The publish command builds and uploads the package to a remote repository.
...
@@ -24,13 +24,32 @@ the config command.
...
@@ -24,13 +24,32 @@ the config command.
def
handle
(
self
):
def
handle
(
self
):
from
poetry.masonry.publishing.publisher
import
Publisher
from
poetry.masonry.publishing.publisher
import
Publisher
# Building package first, unless told otherwise
publisher
=
Publisher
(
self
.
poetry
,
self
.
output
)
if
not
self
.
option
(
'no-build'
):
# Building package first, if told
if
self
.
option
(
'build'
):
if
publisher
.
files
:
if
not
self
.
confirm
(
'There are <info>{}</info> files ready for publishing. '
'Build anyway?'
.
format
(
len
(
publisher
.
files
))
):
self
.
line_error
(
'<error>Aborted!</error>'
)
return
1
self
.
call
(
'build'
)
self
.
call
(
'build'
)
files
=
publisher
.
files
if
not
files
:
self
.
line_error
(
'<error>No files to publish. '
'Run poetry build first or use the --build option.</error>'
)
return
1
self
.
line
(
''
)
self
.
line
(
''
)
publisher
=
Publisher
(
self
.
poetry
,
self
.
output
)
publisher
.
publish
(
publisher
.
publish
(
self
.
option
(
'repository'
),
self
.
option
(
'repository'
),
self
.
option
(
'username'
),
self
.
option
(
'username'
),
...
...
poetry/masonry/publishing/publisher.py
View file @
a43c3baf
...
@@ -17,6 +17,10 @@ class Publisher:
...
@@ -17,6 +17,10 @@ class Publisher:
self
.
_io
=
io
self
.
_io
=
io
self
.
_uploader
=
Uploader
(
poetry
,
io
)
self
.
_uploader
=
Uploader
(
poetry
,
io
)
@property
def
files
(
self
):
return
self
.
_uploader
.
files
def
publish
(
self
,
repository_name
,
username
,
password
):
def
publish
(
self
,
repository_name
,
username
,
password
):
if
repository_name
:
if
repository_name
:
self
.
_io
.
writeln
(
self
.
_io
.
writeln
(
...
...
poetry/masonry/publishing/uploader.py
View file @
a43c3baf
...
@@ -2,6 +2,8 @@ import hashlib
...
@@ -2,6 +2,8 @@ import hashlib
import
io
import
io
import
re
import
re
from
typing
import
List
import
requests
import
requests
from
requests
import
adapters
from
requests
import
adapters
...
@@ -52,6 +54,23 @@ class Uploader:
...
@@ -52,6 +54,23 @@ class Uploader:
return
adapters
.
HTTPAdapter
(
max_retries
=
retry
)
return
adapters
.
HTTPAdapter
(
max_retries
=
retry
)
@property
def
files
(
self
):
# type: () -> List[str]
dist
=
self
.
_poetry
.
file
.
parent
/
'dist'
version
=
normalize_version
(
self
.
_package
.
version
.
text
)
wheels
=
list
(
dist
.
glob
(
'{}-{}-*.whl'
.
format
(
re
.
sub
(
"[^
\
w
\
d.]+"
,
"_"
,
self
.
_package
.
pretty_name
,
flags
=
re
.
UNICODE
),
re
.
sub
(
"[^
\
w
\
d.]+"
,
"_"
,
version
,
flags
=
re
.
UNICODE
),
)
))
tars
=
list
(
dist
.
glob
(
'{}-{}.tar.gz'
.
format
(
self
.
_package
.
pretty_name
,
version
)
))
return
sorted
(
wheels
+
tars
)
def
auth
(
self
,
username
,
password
):
def
auth
(
self
,
username
,
password
):
self
.
_username
=
username
self
.
_username
=
username
self
.
_password
=
password
self
.
_password
=
password
...
@@ -178,28 +197,7 @@ class Uploader:
...
@@ -178,28 +197,7 @@ class Uploader:
raise
raise
def
_do_upload
(
self
,
session
,
url
):
def
_do_upload
(
self
,
session
,
url
):
dist
=
self
.
_poetry
.
file
.
parent
/
'dist'
for
file
in
self
.
files
:
version
=
normalize_version
(
self
.
_package
.
version
.
text
)
packages
=
dist
.
glob
(
'{}-{}*'
.
format
(
self
.
_package
.
name
,
version
)
)
files
=
(
i
for
i
in
packages
if
(
i
.
match
(
'{}-{}-*.whl'
.
format
(
self
.
_package
.
name
,
version
)
)
or
i
.
match
(
'{}-{}.tar.gz'
.
format
(
self
.
_package
.
name
,
version
)
)
)
)
for
file
in
files
:
# TODO: Check existence
# TODO: Check existence
resp
=
self
.
_upload_file
(
session
,
url
,
file
)
resp
=
self
.
_upload_file
(
session
,
url
,
file
)
...
...
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