Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pypa/twine
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.3.0
Choose a base ref
...
head repository: pypa/twine
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.4.1
Choose a head ref
  • 10 commits
  • 14 files changed
  • 5 contributors

Commits on Feb 21, 2021

  1. Prefer importlib_metadata for entrypoint parsing. (#728)

    * Prefer importlib_metadata for entrypoint parsing.
    
    * Prefer dict comprehension for now.
    
    * Workaround "implicit reexport disabled"
    
    * Add changelog.
    
    Co-authored-by: Brian Rutledge <[email protected]>
    jaraco and bhrutledge authored Feb 21, 2021
    Copy the full SHA
    7e95990 View commit details
  2. Cleanup: allow analysis of merge commits (#730)

    Follows updates to CodeQL integration guidance per github/codeql-action#297
    jayaddison authored Feb 21, 2021
    Copy the full SHA
    c1807fa View commit details

Commits on Feb 27, 2021

  1. Copy the full SHA
    22aaa04 View commit details
  2. Honor types in dependencies (#735)

    * Install the project and dependencies in 'types'. Ref #733.
    
    * Cast parameters to match keyring's expectations.
    
    * Bump requirement on keyring in typechecks
    
    * Remove ignores for importlib_metadata and keyring, both typed.
    jaraco authored Feb 27, 2021
    Copy the full SHA
    d01fdfa View commit details

Commits on Mar 2, 2021

  1. Copy the full SHA
    0bd26af View commit details

Commits on Mar 14, 2021

  1. Release 3.4.0 (#742)

    * Update changelog for 3.4.0
    
    * Update releasing process
    bhrutledge authored Mar 14, 2021
    Copy the full SHA
    2dab479 View commit details

Commits on Mar 16, 2021

  1. Copy the full SHA
    57db878 View commit details

Commits on Mar 17, 2021

  1. Fix the "safe_name" attribute of PackageFile for backwards compatibil…

    …ity (#745)
    
    * Fix the "safe_name" attribute of PackageFile for backwards compatibility
    
    Commit 0bd26af introduced a regression
    that was causing some namespace packages with dots in them fail to
    upload to PyPI. The reason is because
    `packaging.utils.canonicalize_name()` is not equivalent to
    `pkg_resources.safe_name()` as the former transforms the "." into "-",
    while the later only does it for non-alphanumeric/. characters.
    
    Closes: #743
    
    * Update docstring of safe_name()
    
    Co-authored-by: Brian Rutledge <[email protected]>
    
    Co-authored-by: Brian Rutledge <[email protected]>
    pablogsal and bhrutledge authored Mar 17, 2021
    Copy the full SHA
    7dc99ad View commit details
  2. Copy the full SHA
    dffdc9a View commit details
  3. Copy the full SHA
    ce3e76d View commit details
Showing with 101 additions and 128 deletions.
  1. +0 −9 .github/workflows/codeql-analysis.yml
  2. +20 −0 docs/changelog.rst
  3. +5 −4 docs/contributing.rst
  4. +0 −12 mypy.ini
  5. +1 −2 setup.cfg
  6. BIN tests/fixtures/twine-3.3.0-py3.9.egg
  7. +29 −0 tests/test_package.py
  8. +7 −1 tests/test_repository.py
  9. +2 −3 tox.ini
  10. +1 −7 twine/__init__.py
  11. +0 −60 twine/_installed.py
  12. +5 −2 twine/auth.py
  13. +13 −24 twine/cli.py
  14. +18 −4 twine/package.py
9 changes: 0 additions & 9 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -31,15 +31,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
20 changes: 20 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -12,6 +12,26 @@ schemes recommended by the Python Packaging Authority.
.. towncrier release notes start
3.4.1 (2021-03-16)
------------------

Bugfixes
^^^^^^^^

- Fix a regression that was causing some namespace packages with dots in them fail to upload to PyPI. (`#745 <https://github.com/pypa/twine/issues/745>`_)


3.4.0 (2021-03-15)
------------------

Features
^^^^^^^^

- Prefer importlib.metadata for entry point handling. (`#728 <https://github.com/pypa/twine/issues/728>`_)
- Rely on importlib_metadata 3.6 for nicer entry point processing. (`#732 <https://github.com/pypa/twine/issues/732>`_)
- Eliminate dependency on setuptools/pkg_resources and replace with packaging and importlib_metadata. (`#736 <https://github.com/pypa/twine/issues/736>`_)


3.3.0 (2020-12-23)
------------------

9 changes: 5 additions & 4 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -232,13 +232,14 @@ Making a new release

A checklist for creating, testing, and distributing a new version.

#. Choose a version number, e.g. ``3.3.0``.
#. Run ``tox -e changelog -- --version {version}`` to build
#. Choose a version number, e.g. ``VERSION=3.3.0``.
#. Create a new branch, e.g. ``git switch -c release-$VERSION``.
#. Run ``tox -e changelog -- --version $VERSION`` to build
:file:`docs/changelog.rst`.
#. Commit and open a pull request for review.
#. Merge the pull request, and ensure the `GitHub Actions`_ build passes.
#. Create a new git tag with ``git tag -m "Release v{version}" {version}``.
#. Push the new tag with ``git push upstream {version}``.
#. Create a new git tag with ``git tag -m "Release v$VERSION" $VERSION``.
#. Push the new tag with ``git push upstream $VERSION``.
#. Watch the release in `GitHub Actions`_.
#. Send announcement email to `distutils-sig mailing list`_ and celebrate.

12 changes: 0 additions & 12 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -22,14 +22,6 @@ strict_equality = True
; https://github.com/tartley/colorama/issues/206
ignore_missing_imports = True

[mypy-importlib_metadata]
; https://gitlab.com/python-devs/importlib_metadata/-/issues/10
ignore_missing_imports = True

[mypy-keyring]
; https://github.com/jaraco/keyring/issues/437
ignore_missing_imports = True

[mypy-pkginfo]
; https://bugs.launchpad.net/pkginfo/+bug/1876591
ignore_missing_imports = True
@@ -45,10 +37,6 @@ ignore_missing_imports = True
[mypy-rfc3986]
ignore_missing_imports = True

[mypy-setuptools]
; https://github.com/python/typeshed/issues/2171
ignore_missing_imports = True

[mypy-tqdm]
; https://github.com/tqdm/tqdm/issues/260
ignore_missing_imports = True
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -38,9 +38,8 @@ install_requires=
readme_renderer >= 21.0
requests >= 2.20
requests-toolbelt >= 0.8.0, != 0.9.0
setuptools >= 0.7.0
tqdm >= 4.14
importlib_metadata; python_version < "3.8"
importlib_metadata >= 3.6
keyring >= 15.1
rfc3986 >= 1.4.0
colorama >= 0.4.3
Binary file added tests/fixtures/twine-3.3.0-py3.9.egg
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/test_package.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import string

import pretend
import pytest

@@ -110,6 +112,28 @@ def test_package_signed_name_is_correct():
assert package.signed_filename == (filename + ".asc")


@pytest.mark.parametrize(
"pkg_name,expected_name",
[
(string.ascii_letters, string.ascii_letters),
(string.digits, string.digits),
(string.punctuation, "-.-"),
("mosaik.SimConfig", "mosaik.SimConfig"),
("mosaik$$$$.SimConfig", "mosaik-.SimConfig"),
],
)
def test_package_safe_name_is_correct(pkg_name, expected_name):
package = package_file.PackageFile(
filename="tests/fixtures/deprecated-pypirc",
comment=None,
metadata=pretend.stub(name=pkg_name),
python_version=None,
filetype=None,
)

assert package.safe_name == expected_name


@pytest.mark.parametrize("gpg_signature", [(None), (pretend.stub())])
def test_metadata_dictionary(gpg_signature):
meta = pretend.stub(
@@ -264,3 +288,8 @@ def test_malformed_from_file(monkeypatch):
package_file.PackageFile.from_filename(filename, comment=None)

assert "Invalid distribution file" in err.value.args[0]


def test_package_from_egg():
filename = "tests/fixtures/twine-3.3.0-py3.9.egg"
package_file.PackageFile.from_filename(filename, comment=None)
8 changes: 7 additions & 1 deletion tests/test_repository.py
Original file line number Diff line number Diff line change
@@ -89,7 +89,13 @@ def test_make_user_agent_string(default_repo):
assert "User-Agent" in default_repo.session.headers

user_agent = default_repo.session.headers["User-Agent"]
packages = ("twine/", "requests/", "requests-toolbelt/", "pkginfo/", "setuptools/")
packages = (
"twine/",
"requests/",
"requests-toolbelt/",
"pkginfo/",
"importlib_metadata/",
)
assert all(p in user_agent for p in packages)


5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ commands =
twine check dist/*

[testenv:watch-docs]
skip_install = True
deps =
-rdocs/requirements.txt
sphinx-autobuild
@@ -69,17 +68,17 @@ commands =
flake8 twine/ tests/

[testenv:types]
skip_install = True
deps =
mypy
lxml
# required for more thorough type declarations
keyring >= 22.3
commands =
mypy --html-report mypy --txt-report mypy {posargs:twine}
python -c 'with open("mypy/index.txt") as f: print(f.read())'

[testenv:changelog]
basepython = python3
skip_install = true
deps =
towncrier
commands =
8 changes: 1 addition & 7 deletions twine/__init__.py
Original file line number Diff line number Diff line change
@@ -24,13 +24,7 @@

__copyright__ = "Copyright 2019 Donald Stufft and individual contributors"

import sys

if sys.version_info[:2] >= (3, 8):
from importlib import metadata as importlib_metadata
else:
import importlib_metadata

import importlib_metadata

metadata = importlib_metadata.metadata("twine")

60 changes: 0 additions & 60 deletions twine/_installed.py

This file was deleted.

7 changes: 5 additions & 2 deletions twine/auth.py
Original file line number Diff line number Diff line change
@@ -55,7 +55,8 @@ def system(self) -> Optional[str]:

def get_username_from_keyring(self) -> Optional[str]:
try:
creds = keyring.get_credential(self.system, None)
system = cast(str, self.system)
creds = keyring.get_credential(system, None)
if creds:
return cast(str, creds.username)
except AttributeError:
@@ -67,7 +68,9 @@ def get_username_from_keyring(self) -> Optional[str]:

def get_password_from_keyring(self) -> Optional[str]:
try:
return cast(str, keyring.get_password(self.system, self.username))
system = cast(str, self.system)
username = cast(str, self.username)
return cast(str, keyring.get_password(system, username))
except Exception as exc:
warnings.warn(str(exc))
return None
37 changes: 13 additions & 24 deletions twine/cli.py
Original file line number Diff line number Diff line change
@@ -12,36 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
from typing import Any, Dict, List, Tuple
from typing import Any, List, Tuple

import pkg_resources
import pkginfo
import requests
import requests_toolbelt
import setuptools
import tqdm
from importlib_metadata import entry_points
from importlib_metadata import version

import twine
from twine import _installed

args = argparse.Namespace()


def _registered_commands(
group: str = "twine.registered_commands",
) -> Dict[str, pkg_resources.EntryPoint]:
registered_commands = pkg_resources.iter_entry_points(group=group)
return {c.name: c for c in registered_commands}


def list_dependencies_and_versions() -> List[Tuple[str, str]]:
return [
("pkginfo", _installed.Installed(pkginfo).version),
("requests", requests.__version__),
("setuptools", setuptools.__version__),
("requests-toolbelt", requests_toolbelt.__version__),
("tqdm", tqdm.__version__),
]
deps = (
"importlib_metadata",
"pkginfo",
"requests",
"requests-toolbelt",
"tqdm",
)
return [(dep, version(dep)) for dep in deps] # type: ignore[no-untyped-call] # python/importlib_metadata#288 # noqa: E501


def dep_versions() -> str:
@@ -51,7 +40,7 @@ def dep_versions() -> str:


def dispatch(argv: List[str]) -> Any:
registered_commands = _registered_commands()
registered_commands = entry_points(group="twine.registered_commands")
parser = argparse.ArgumentParser(prog="twine")
parser.add_argument(
"--version",
@@ -67,7 +56,7 @@ def dispatch(argv: List[str]) -> Any:
)
parser.add_argument(
"command",
choices=registered_commands.keys(),
choices=registered_commands.names,
)
parser.add_argument(
"args",
Loading