Skip to content

Commit

Permalink
don't pass in username and password if there is a pypirc file
Browse files Browse the repository at this point in the history
  • Loading branch information
CangyuanLi committed Oct 9, 2023
1 parent b47601e commit cb13eb5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pyproject/project_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ def config(self):
"""
self._write_config_file(self._config)

def _has_pypirc(self) -> bool:
# check project root and home directory
return (self.proj_path / ".pypirc").exists() or (
Path().home() / ".pypirc"
).exists()

def upload(self):
"""Discover the virtual environment and upload project to PyPI."""
username = self._config.pypi_username
Expand Down Expand Up @@ -500,7 +506,7 @@ def upload(self):
clear=False,
)

if username == "" and password == "":
if (username == "" and password == "") or self._has_pypirc():
twine_args = []
elif username == "" and password != "":
twine_args = ["-p", password]
Expand Down

0 comments on commit cb13eb5

Please sign in to comment.