From c9f2e0b5cf4bce09c7f32e873c68da3d493b7f3e Mon Sep 17 00:00:00 2001 From: Suren Nihalani <1093911+SurenNihalani@users.noreply.github.com> Date: Fri, 1 Sep 2023 20:34:23 -0700 Subject: [PATCH 1/8] Document the project and file upload limits in pypi on the FAQ page --- tests/unit/admin/views/test_projects.py | 7 ++--- tests/unit/forklift/test_legacy.py | 35 +++++++++++++------------ tests/unit/manage/test_views.py | 2 +- warehouse/admin/views/projects.py | 2 +- warehouse/config.py | 4 ++- warehouse/constants.py | 5 ++++ warehouse/forklift/legacy.py | 8 +----- warehouse/manage/views/__init__.py | 2 +- warehouse/templates/pages/help.html | 6 +++-- 9 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 warehouse/constants.py diff --git a/tests/unit/admin/views/test_projects.py b/tests/unit/admin/views/test_projects.py index 989274a3e2eb..ed1b41cd93a3 100644 --- a/tests/unit/admin/views/test_projects.py +++ b/tests/unit/admin/views/test_projects.py @@ -19,6 +19,7 @@ from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently, HTTPSeeOther +import warehouse.constants from tests.common.db.oidc import GitHubPublisherFactory from warehouse.admin.views import projects as views from warehouse.packaging.models import Project, Role @@ -97,8 +98,8 @@ def test_gets_project(self, db_request): "journal": journals[:30], "oidc_publishers": oidc_publishers, "ONE_MB": views.ONE_MB, - "MAX_FILESIZE": views.MAX_FILESIZE, - "MAX_PROJECT_SIZE": views.MAX_PROJECT_SIZE, + "MAX_FILESIZE": warehouse.constants.MAX_FILESIZE, + "MAX_PROJECT_SIZE": warehouse.constants.MAX_PROJECT_SIZE, "ONE_GB": views.ONE_GB, "UPLOAD_LIMIT_CAP": views.UPLOAD_LIMIT_CAP, } @@ -418,7 +419,7 @@ def test_sets_limitwith_integer(self, db_request): flash=pretend.call_recorder(lambda *a, **kw: None) ) db_request.matchdict["project_name"] = project.normalized_name - new_upload_limit = views.MAX_FILESIZE // views.ONE_MB + new_upload_limit = warehouse.constants.MAX_FILESIZE // views.ONE_MB db_request.POST["upload_limit"] = str(new_upload_limit) views.set_upload_limit(project, db_request) diff --git a/tests/unit/forklift/test_legacy.py b/tests/unit/forklift/test_legacy.py index 3946edbc2ab4..e80ceba717b7 100644 --- a/tests/unit/forklift/test_legacy.py +++ b/tests/unit/forklift/test_legacy.py @@ -31,6 +31,7 @@ from wtforms.form import Form from wtforms.validators import ValidationError +import warehouse.constants from warehouse.admin.flags import AdminFlag, AdminFlagValue from warehouse.classifiers.models import Classifier from warehouse.errors import BasicAuthTwoFactorEnabled @@ -584,7 +585,7 @@ def test_zipfile_exceeds_compression_threshold(self, tmpdir): with zipfile.ZipFile(f, "w") as zfp: zfp.writestr("PKG-INFO", b"this is the package info") - zfp.writestr("1.dat", b"0" * 65 * legacy.ONE_MB, zipfile.ZIP_DEFLATED) + zfp.writestr("1.dat", b"0" * 65 * warehouse.constants.ONE_MB, zipfile.ZIP_DEFLATED) assert not legacy._is_valid_dist_file(f, "") @@ -1892,8 +1893,8 @@ def test_upload_fails_with_too_large_project_size_default_limit( EmailFactory.create(user=user) project = ProjectFactory.create( name="foobar", - upload_limit=legacy.MAX_FILESIZE, - total_size=legacy.MAX_PROJECT_SIZE - 1, + upload_limit=warehouse.constants.MAX_FILESIZE, + total_size=warehouse.constants.MAX_PROJECT_SIZE - 1, ) release = ReleaseFactory.create(project=project, version="1.0") RoleFactory.create(user=user, project=project) @@ -1939,10 +1940,10 @@ def test_upload_fails_with_too_large_project_size_custom_limit( one_megabyte = 1 * 1024 * 1024 project = ProjectFactory.create( name="foobar", - upload_limit=legacy.MAX_FILESIZE, - total_size=legacy.MAX_PROJECT_SIZE, - total_size_limit=legacy.MAX_PROJECT_SIZE - + one_megabyte, # Custom Limit for the project + upload_limit=warehouse.constants.MAX_FILESIZE, + total_size=warehouse.constants.MAX_PROJECT_SIZE, + total_size_limit=warehouse.constants.MAX_PROJECT_SIZE + + one_megabyte, # Custom Limit for the project ) release = ReleaseFactory.create(project=project, version="1.0") RoleFactory.create(user=user, project=project) @@ -1992,10 +1993,10 @@ def test_upload_succeeds_custom_project_size_limit( one_megabyte = 1 * 1024 * 1024 project = ProjectFactory.create( name="foobar", - upload_limit=legacy.MAX_FILESIZE, - total_size=legacy.MAX_PROJECT_SIZE, - total_size_limit=legacy.MAX_PROJECT_SIZE - + (one_megabyte * 60), # Custom Limit for the project + upload_limit=warehouse.constants.MAX_FILESIZE, + total_size=warehouse.constants.MAX_PROJECT_SIZE, + total_size_limit=warehouse.constants.MAX_PROJECT_SIZE + + (one_megabyte * 60), # Custom Limit for the project ) release = ReleaseFactory.create(project=project, version="1.0") RoleFactory.create(user=user, project=project) @@ -2374,7 +2375,7 @@ def test_upload_fails_with_invalid_filetype( }[filetype], "content": pretend.stub( filename=filename, - file=io.BytesIO(b"a" * (legacy.MAX_FILESIZE + 1)), + file=io.BytesIO(b"a" * (warehouse.constants.MAX_FILESIZE + 1)), type="application/tar", ), } @@ -2412,7 +2413,7 @@ def test_upload_fails_with_invalid_extension(self, pyramid_config, db_request): "md5_digest": "nope!", "content": pretend.stub( filename=filename, - file=io.BytesIO(b"a" * (legacy.MAX_FILESIZE + 1)), + file=io.BytesIO(b"a" * (warehouse.constants.MAX_FILESIZE + 1)), type="application/tar", ), } @@ -2453,7 +2454,7 @@ def test_upload_fails_with_unsafe_filename( "md5_digest": "nope!", "content": pretend.stub( filename=filename, - file=io.BytesIO(b"a" * (legacy.MAX_FILESIZE + 1)), + file=io.BytesIO(b"a" * (warehouse.constants.MAX_FILESIZE + 1)), type="application/tar", ), } @@ -2490,7 +2491,7 @@ def test_upload_fails_with_disallowed_in_filename( "md5_digest": "nope!", "content": pretend.stub( filename=filename, - file=io.BytesIO(b"a" * (legacy.MAX_FILESIZE + 1)), + file=io.BytesIO(b"a" * (warehouse.constants.MAX_FILESIZE + 1)), type="application/tar", ), } @@ -2529,7 +2530,7 @@ def test_upload_fails_without_user_permission(self, pyramid_config, db_request): "md5_digest": "nope!", "content": pretend.stub( filename=filename, - file=io.BytesIO(b"a" * (legacy.MAX_FILESIZE + 1)), + file=io.BytesIO(b"a" * (warehouse.constants.MAX_FILESIZE + 1)), type="application/tar", ), } @@ -2571,7 +2572,7 @@ def test_upload_fails_without_oidc_publisher_permission( "md5_digest": "nope!", "content": pretend.stub( filename=filename, - file=io.BytesIO(b"a" * (legacy.MAX_FILESIZE + 1)), + file=io.BytesIO(b"a" * (warehouse.constants.MAX_FILESIZE + 1)), type="application/tar", ), } diff --git a/tests/unit/manage/test_views.py b/tests/unit/manage/test_views.py index ff34c644c861..32a8bd93cab9 100644 --- a/tests/unit/manage/test_views.py +++ b/tests/unit/manage/test_views.py @@ -40,7 +40,7 @@ ) from warehouse.admin.flags import AdminFlagValue from warehouse.events.tags import EventTag -from warehouse.forklift.legacy import MAX_FILESIZE, MAX_PROJECT_SIZE +from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE from warehouse.macaroons import caveats from warehouse.macaroons.interfaces import IMacaroonService from warehouse.manage import views diff --git a/warehouse/admin/views/projects.py b/warehouse/admin/views/projects.py index 03632a0190c7..6dfb8580fc6e 100644 --- a/warehouse/admin/views/projects.py +++ b/warehouse/admin/views/projects.py @@ -20,7 +20,7 @@ from sqlalchemy.orm import joinedload from warehouse.accounts.models import User -from warehouse.forklift.legacy import MAX_FILESIZE, MAX_PROJECT_SIZE +from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE from warehouse.packaging.models import JournalEntry, Project, Release, Role from warehouse.packaging.tasks import update_release_description from warehouse.search.tasks import reindex_project as _reindex_project diff --git a/warehouse/config.py b/warehouse/config.py index a9548430ad6a..70cb8e6a5df4 100644 --- a/warehouse/config.py +++ b/warehouse/config.py @@ -32,6 +32,7 @@ from warehouse.errors import BasicAuthBreachedPassword, BasicAuthFailedPassword from warehouse.utils.static import ManifestCacheBuster from warehouse.utils.wsgi import ProxyFixer, VhmRootRemover +from warehouse.constants import ONE_MB, ONE_GB, MAX_FILESIZE, MAX_PROJECT_SIZE class Environment(str, enum.Enum): @@ -147,7 +148,8 @@ def from_base64_encoded_json(configuration): def configure(settings=None): if settings is None: settings = {} - + settings['warehouse.forklift.legacy.MAX_FILESIZE_MB'] = MAX_FILESIZE / ONE_MB + settings['warehouse.forklift.legacy.MAX_PROJECT_SIZE_GB'] = MAX_PROJECT_SIZE / ONE_GB # Add information about the current copy of the code. maybe_set(settings, "warehouse.commit", "SOURCE_COMMIT", default="null") diff --git a/warehouse/constants.py b/warehouse/constants.py new file mode 100644 index 000000000000..740dbde99502 --- /dev/null +++ b/warehouse/constants.py @@ -0,0 +1,5 @@ +ONE_MB = 1 * 1024 * 1024 +ONE_GB = 1 * 1024 * 1024 * 1024 +MAX_FILESIZE = 100 * ONE_MB +MAX_SIGSIZE = 8 * 1024 +MAX_PROJECT_SIZE = 10 * ONE_GB diff --git a/warehouse/forklift/legacy.py b/warehouse/forklift/legacy.py index ac6ace5d1e97..812a4239500d 100644 --- a/warehouse/forklift/legacy.py +++ b/warehouse/forklift/legacy.py @@ -47,6 +47,7 @@ from warehouse import forms from warehouse.admin.flags import AdminFlagValue from warehouse.classifiers.models import Classifier +from warehouse.constants import ONE_MB, ONE_GB, MAX_FILESIZE, MAX_PROJECT_SIZE from warehouse.email import ( send_basic_auth_with_two_factor_email, send_gpg_signature_uploaded_email, @@ -72,13 +73,6 @@ from warehouse.utils.project import PROJECT_NAME_RE, validate_project_name from warehouse.utils.security_policy import AuthenticationMethod -ONE_MB = 1 * 1024 * 1024 -ONE_GB = 1 * 1024 * 1024 * 1024 - -MAX_FILESIZE = 100 * ONE_MB -MAX_SIGSIZE = 8 * 1024 -MAX_PROJECT_SIZE = 10 * ONE_GB - PATH_HASHER = "blake2_256" COMPRESSION_RATIO_MIN_SIZE = 64 * ONE_MB diff --git a/warehouse/manage/views/__init__.py b/warehouse/manage/views/__init__.py index 341a3d0330c3..3d7c469b052c 100644 --- a/warehouse/manage/views/__init__.py +++ b/warehouse/manage/views/__init__.py @@ -69,7 +69,7 @@ send_yanked_project_release_email, ) from warehouse.events.tags import EventTag -from warehouse.forklift.legacy import MAX_FILESIZE, MAX_PROJECT_SIZE +from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE from warehouse.macaroons import caveats from warehouse.macaroons.interfaces import IMacaroonService from warehouse.manage.forms import ( diff --git a/warehouse/templates/pages/help.html b/warehouse/templates/pages/help.html index c63696ba333b..d67fb5a6e062 100644 --- a/warehouse/templates/pages/help.html +++ b/warehouse/templates/pages/help.html @@ -602,9 +602,10 @@
For how to check a description for validity, see also: {{ description_render_failure() }}
{% trans dev_release_href='https://www.python.org/dev/peps/pep-0440/#developmental-releases', file_issue_href='https://github.com/pypi/support/issues/new?assignees=&labels=limit+request&template=limit-request-file.yml&title=File+Limit+Request%3A+PROJECT_NAME+-+000+MB', title=gettext('External link') %} - If you can't upload your project's release to PyPI because you're hitting the upload file size limit, + If you can't upload your project's release to PyPI because you're hitting the upload file size limit ({{ max_file_size_mb }} MB), we can sometimes increase your limit. Make sure you've uploaded at least one release for the project that's under the limit (a developmental release version number is fine). @@ -621,9 +622,10 @@
+ {% set max_project_size_gb = request.registry.settings.get('warehouse.forklift.legacy.MAX_PROJECT_SIZE_GB') %} {% trans %} If you can't upload your project's release to PyPI because you're - hitting the project size limit, first remove any unnecessary + hitting the project size limit ({{ max_project_size_gb }} GB), first remove any unnecessary releases or individual files to lower your overall project size. {% endtrans %}
From 735ba2dee2b2ab2c5f278656d0f31bb61a04b282 Mon Sep 17 00:00:00 2001 From: Suren Nihalani <1093911+SurenNihalani@users.noreply.github.com> Date: Fri, 15 Sep 2023 17:00:07 -0400 Subject: [PATCH 2/8] Test it --- warehouse/locale/messages.pot | 244 +++++++++++++++++----------------- 1 file changed, 123 insertions(+), 121 deletions(-) diff --git a/warehouse/locale/messages.pot b/warehouse/locale/messages.pot index f3a0f2e59df5..458a45e63d09 100644 --- a/warehouse/locale/messages.pot +++ b/warehouse/locale/messages.pot @@ -728,37 +728,37 @@ msgstr "" #: warehouse/templates/pages/help.html:588 #: warehouse/templates/pages/help.html:600 #: warehouse/templates/pages/help.html:601 -#: warehouse/templates/pages/help.html:606 -#: warehouse/templates/pages/help.html:631 -#: warehouse/templates/pages/help.html:644 -#: warehouse/templates/pages/help.html:649 -#: warehouse/templates/pages/help.html:661 -#: warehouse/templates/pages/help.html:682 -#: warehouse/templates/pages/help.html:706 -#: warehouse/templates/pages/help.html:713 -#: warehouse/templates/pages/help.html:725 -#: warehouse/templates/pages/help.html:736 -#: warehouse/templates/pages/help.html:741 -#: warehouse/templates/pages/help.html:749 -#: warehouse/templates/pages/help.html:760 -#: warehouse/templates/pages/help.html:805 -#: warehouse/templates/pages/help.html:813 -#: warehouse/templates/pages/help.html:829 -#: warehouse/templates/pages/help.html:834 -#: warehouse/templates/pages/help.html:839 -#: warehouse/templates/pages/help.html:849 -#: warehouse/templates/pages/help.html:858 -#: warehouse/templates/pages/help.html:872 -#: warehouse/templates/pages/help.html:880 -#: warehouse/templates/pages/help.html:888 -#: warehouse/templates/pages/help.html:896 -#: warehouse/templates/pages/help.html:905 -#: warehouse/templates/pages/help.html:925 -#: warehouse/templates/pages/help.html:940 -#: warehouse/templates/pages/help.html:941 +#: warehouse/templates/pages/help.html:607 +#: warehouse/templates/pages/help.html:633 +#: warehouse/templates/pages/help.html:646 +#: warehouse/templates/pages/help.html:651 +#: warehouse/templates/pages/help.html:663 +#: warehouse/templates/pages/help.html:684 +#: warehouse/templates/pages/help.html:708 +#: warehouse/templates/pages/help.html:715 +#: warehouse/templates/pages/help.html:727 +#: warehouse/templates/pages/help.html:738 +#: warehouse/templates/pages/help.html:743 +#: warehouse/templates/pages/help.html:751 +#: warehouse/templates/pages/help.html:762 +#: warehouse/templates/pages/help.html:807 +#: warehouse/templates/pages/help.html:815 +#: warehouse/templates/pages/help.html:831 +#: warehouse/templates/pages/help.html:836 +#: warehouse/templates/pages/help.html:841 +#: warehouse/templates/pages/help.html:851 +#: warehouse/templates/pages/help.html:860 +#: warehouse/templates/pages/help.html:874 +#: warehouse/templates/pages/help.html:882 +#: warehouse/templates/pages/help.html:890 +#: warehouse/templates/pages/help.html:898 +#: warehouse/templates/pages/help.html:907 +#: warehouse/templates/pages/help.html:927 #: warehouse/templates/pages/help.html:942 #: warehouse/templates/pages/help.html:943 -#: warehouse/templates/pages/help.html:948 +#: warehouse/templates/pages/help.html:944 +#: warehouse/templates/pages/help.html:945 +#: warehouse/templates/pages/help.html:950 #: warehouse/templates/pages/sponsors.html:33 #: warehouse/templates/pages/sponsors.html:37 #: warehouse/templates/pages/sponsors.html:41 @@ -6911,12 +6911,12 @@ msgid "Administration of projects on PyPI" msgstr "" #: warehouse/templates/pages/help.html:173 -#: warehouse/templates/pages/help.html:657 +#: warehouse/templates/pages/help.html:659 msgid "Troubleshooting" msgstr "" #: warehouse/templates/pages/help.html:190 -#: warehouse/templates/pages/help.html:825 +#: warehouse/templates/pages/help.html:827 msgid "About" msgstr "" @@ -7652,47 +7652,49 @@ msgid "" "available formats." msgstr "" -#: warehouse/templates/pages/help.html:606 +#: warehouse/templates/pages/help.html:607 #, python-format msgid "" "If you can't upload your project's release to PyPI because you're hitting" -" the upload file size limit, we can sometimes increase your limit. Make " -"sure you've uploaded at least one release for the project that's " -"under the limit (a developmental " -"release version number is fine). Then, under the limit (a developmental release version number is fine). Then," +" file an issue and tell us:" msgstr "" -#: warehouse/templates/pages/help.html:615 -#: warehouse/templates/pages/help.html:636 +#: warehouse/templates/pages/help.html:616 +#: warehouse/templates/pages/help.html:638 msgid "A link to your project on PyPI (or Test PyPI)" msgstr "" -#: warehouse/templates/pages/help.html:616 +#: warehouse/templates/pages/help.html:617 msgid "The size of your release, in megabytes" msgstr "" -#: warehouse/templates/pages/help.html:617 +#: warehouse/templates/pages/help.html:618 msgid "Which index/indexes you need the increase for (PyPI, Test PyPI, or both)" msgstr "" -#: warehouse/templates/pages/help.html:618 -#: warehouse/templates/pages/help.html:638 +#: warehouse/templates/pages/help.html:619 +#: warehouse/templates/pages/help.html:640 msgid "" "A brief description of your project, including the reason for the " "additional size." msgstr "" -#: warehouse/templates/pages/help.html:624 +#: warehouse/templates/pages/help.html:626 +#, python-format msgid "" "If you can't upload your project's release to PyPI because you're hitting" -" the project size limit, first remove any unnecessary releases or " -"individual files to lower your overall project size." +" the project size limit (%(max_project_size_gb)s GB), first remove any " +"unnecessary releases or individual files to lower your overall project " +"size." msgstr "" -#: warehouse/templates/pages/help.html:631 +#: warehouse/templates/pages/help.html:633 #, python-format msgid "" "If that is not possible, we can sometimes increase your limit. File an issue and tell us:" msgstr "" -#: warehouse/templates/pages/help.html:637 +#: warehouse/templates/pages/help.html:639 msgid "The total size of your project, in gigabytes" msgstr "" -#: warehouse/templates/pages/help.html:644 +#: warehouse/templates/pages/help.html:646 #, python-format msgid "" "PyPI receives reports on vulnerabilities in the packages hosted on it " @@ -7715,7 +7717,7 @@ msgid "" "Advisory Database." msgstr "" -#: warehouse/templates/pages/help.html:649 +#: warehouse/templates/pages/help.html:651 #, python-format msgid "" "If you believe vulnerability data for your project is invalid or " @@ -7723,7 +7725,7 @@ msgid "" "target=\"_blank\" rel=\"noopener\">file an issue with details." msgstr "" -#: warehouse/templates/pages/help.html:661 +#: warehouse/templates/pages/help.html:663 #, python-format msgid "" "PyPI will reject uploads if the package description fails to render. You " @@ -7731,41 +7733,41 @@ msgid "" "command to locally check a description for validity." msgstr "" -#: warehouse/templates/pages/help.html:667 +#: warehouse/templates/pages/help.html:669 msgid "" "If you've forgotten your PyPI password but you remember your email " "address or username, follow these steps to reset your password:" msgstr "" -#: warehouse/templates/pages/help.html:669 +#: warehouse/templates/pages/help.html:671 #, python-format msgid "Go to reset your password." msgstr "" -#: warehouse/templates/pages/help.html:670 +#: warehouse/templates/pages/help.html:672 msgid "Enter the email address or username you used for PyPI and submit the form." msgstr "" -#: warehouse/templates/pages/help.html:671 +#: warehouse/templates/pages/help.html:673 msgid "You'll receive an email with a password reset link." msgstr "" -#: warehouse/templates/pages/help.html:676 +#: warehouse/templates/pages/help.html:678 msgid "If you've lost access to your PyPI account due to:" msgstr "" -#: warehouse/templates/pages/help.html:678 +#: warehouse/templates/pages/help.html:680 msgid "Lost access to the email address associated with your account" msgstr "" -#: warehouse/templates/pages/help.html:679 +#: warehouse/templates/pages/help.html:681 msgid "" "Lost two factor authentication application, device, and recovery " "codes" msgstr "" -#: warehouse/templates/pages/help.html:682 +#: warehouse/templates/pages/help.html:684 #, python-format msgid "" "You can proceed to API Token for uploads:" msgstr "" -#: warehouse/templates/pages/help.html:696 +#: warehouse/templates/pages/help.html:698 msgid "Ensure that your API Token is valid and has not been revoked." msgstr "" -#: warehouse/templates/pages/help.html:697 +#: warehouse/templates/pages/help.html:699 msgid "" "Ensure that your API Token is properly " "formatted and does not contain any trailing characters such as " "newlines." msgstr "" -#: warehouse/templates/pages/help.html:698 +#: warehouse/templates/pages/help.html:700 msgid "Ensure that the username you are using is__token__
."
msgstr ""
-#: warehouse/templates/pages/help.html:700
+#: warehouse/templates/pages/help.html:702
msgid ""
"In both cases, remember that PyPI and TestPyPI each require you to create"
" an account, so your credentials may be different."
msgstr ""
-#: warehouse/templates/pages/help.html:702
+#: warehouse/templates/pages/help.html:704
msgid ""
"If you're using Windows and trying to paste your password or token in the"
" Command Prompt or PowerShell, note that Ctrl-V and Shift+Insert won't "
@@ -7820,7 +7822,7 @@ msgid ""
"enable \"Use Ctrl+Shift+C/V as Copy/Paste\" in \"Properties\"."
msgstr ""
-#: warehouse/templates/pages/help.html:706
+#: warehouse/templates/pages/help.html:708
#, python-format
msgid ""
"This is a Learn why on the PSF blog."
msgstr ""
-#: warehouse/templates/pages/help.html:720
+#: warehouse/templates/pages/help.html:722
#, python-format
msgid ""
"If you are having trouble with %(command)s
and get a "
@@ -7849,7 +7851,7 @@ msgid ""
"information:"
msgstr ""
-#: warehouse/templates/pages/help.html:722
+#: warehouse/templates/pages/help.html:724
msgid ""
"If you see an error like There was a problem confirming the ssl "
"certificate
or tlsv1 alert protocol version
or "
@@ -7857,7 +7859,7 @@ msgid ""
"PyPI with a newer TLS support library."
msgstr ""
-#: warehouse/templates/pages/help.html:723
+#: warehouse/templates/pages/help.html:725
msgid ""
"The specific steps you need to take will depend on your operating system "
"version, where your installation of Python originated (python.org, your "
@@ -7865,7 +7867,7 @@ msgid ""
" Python, setuptools
, and pip
."
msgstr ""
-#: warehouse/templates/pages/help.html:725
+#: warehouse/templates/pages/help.html:727
#, python-format
msgid ""
"For help, go to %(command)s."
msgstr ""
-#: warehouse/templates/pages/help.html:736
+#: warehouse/templates/pages/help.html:738
#, python-format
msgid ""
"We take , so we can try to fix the problem, for you and others."
msgstr ""
-#: warehouse/templates/pages/help.html:749
+#: warehouse/templates/pages/help.html:751
#, python-format
msgid ""
"In a previous version of PyPI, it used to be possible for maintainers to "
@@ -7904,7 +7906,7 @@ msgid ""
"rel=\"noopener\">use twine to upload your project to PyPI."
msgstr ""
-#: warehouse/templates/pages/help.html:758
+#: warehouse/templates/pages/help.html:760
msgid ""
"Spammers return to PyPI with some regularity hoping to place their Search"
" Engine Optimized phishing, scam, and click-farming content on the site. "
@@ -7913,7 +7915,7 @@ msgid ""
"prime target."
msgstr ""
-#: warehouse/templates/pages/help.html:760
+#: warehouse/templates/pages/help.html:762
#, python-format
msgid ""
"When the PyPI administrators are overwhelmed by spam or "
@@ -7924,35 +7926,35 @@ msgid ""
"have updated it with reasoning for the intervention."
msgstr ""
-#: warehouse/templates/pages/help.html:769
+#: warehouse/templates/pages/help.html:771
msgid "PyPI will return these errors for one of these reasons:"
msgstr ""
-#: warehouse/templates/pages/help.html:771
+#: warehouse/templates/pages/help.html:773
msgid "Filename has been used and file exists"
msgstr ""
-#: warehouse/templates/pages/help.html:772
+#: warehouse/templates/pages/help.html:774
msgid "Filename has been used but file no longer exists"
msgstr ""
-#: warehouse/templates/pages/help.html:773
+#: warehouse/templates/pages/help.html:775
msgid "A file with the exact same content exists"
msgstr ""
-#: warehouse/templates/pages/help.html:776
+#: warehouse/templates/pages/help.html:778
msgid ""
"PyPI does not allow for a filename to be reused, even once a project has "
"been deleted and recreated."
msgstr ""
-#: warehouse/templates/pages/help.html:782
+#: warehouse/templates/pages/help.html:784
msgid ""
"A distribution filename on PyPI consists of the combination of project "
"name, version number, and distribution type."
msgstr ""
-#: warehouse/templates/pages/help.html:788
+#: warehouse/templates/pages/help.html:790
msgid ""
"This ensures that a given distribution for a given release for a given "
"project will always resolve to the same file, and cannot be "
@@ -7960,14 +7962,14 @@ msgid ""
" party (it can only be removed)."
msgstr ""
-#: warehouse/templates/pages/help.html:796
+#: warehouse/templates/pages/help.html:798
msgid ""
"To avoid this situation in most cases, you will need to change the "
"version number to one that you haven't previously uploaded to PyPI, "
"rebuild the distribution, and then upload the new distribution."
msgstr ""
-#: warehouse/templates/pages/help.html:805
+#: warehouse/templates/pages/help.html:807
#, python-format
msgid ""
"If you would like to request a new trove classifier file a pull request "
@@ -7976,7 +7978,7 @@ msgid ""
" to include a brief justification of why it is important."
msgstr ""
-#: warehouse/templates/pages/help.html:813
+#: warehouse/templates/pages/help.html:815
#, python-format
msgid ""
"If you're experiencing an issue with PyPI itself, we welcome "
@@ -7987,14 +7989,14 @@ msgid ""
" first check that a similar issue does not already exist."
msgstr ""
-#: warehouse/templates/pages/help.html:820
+#: warehouse/templates/pages/help.html:822
msgid ""
"If you are having an issue is with a specific package installed from "
"PyPI, you should reach out to the maintainers of that project directly "
"instead."
msgstr ""
-#: warehouse/templates/pages/help.html:829
+#: warehouse/templates/pages/help.html:831
#, python-format
msgid ""
"PyPI is powered by the Warehouse project; ."
msgstr ""
-#: warehouse/templates/pages/help.html:856
+#: warehouse/templates/pages/help.html:858
msgid ""
"As of April 16, 2018, PyPI.org is at \"production\" status, meaning that "
"it has moved out of beta and replaced the old site (pypi.python.org). It "
"is now robust, tested, and ready for expected browser and API traffic."
msgstr ""
-#: warehouse/templates/pages/help.html:858
+#: warehouse/templates/pages/help.html:860
#, python-format
msgid ""
"PyPI is heavily cached and distributed via private index."
msgstr ""
-#: warehouse/templates/pages/help.html:872
+#: warehouse/templates/pages/help.html:874
#, python-format
msgid ""
"We have a huge amount of work to do to continue to maintain and improve "
@@ -8067,22 +8069,22 @@ msgid ""
"target=\"_blank\" rel=\"noopener\">the Warehouse project)."
msgstr ""
-#: warehouse/templates/pages/help.html:877
+#: warehouse/templates/pages/help.html:879
msgid "Financial:"
msgstr ""
-#: warehouse/templates/pages/help.html:877
+#: warehouse/templates/pages/help.html:879
#, python-format
msgid ""
"We would deeply appreciate your donations to fund "
"development and maintenance."
msgstr ""
-#: warehouse/templates/pages/help.html:878
+#: warehouse/templates/pages/help.html:880
msgid "Development:"
msgstr ""
-#: warehouse/templates/pages/help.html:878
+#: warehouse/templates/pages/help.html:880
msgid ""
"Warehouse is open source, and we would love to see some new faces working"
" on the project. You do not need to be an experienced "
@@ -8090,7 +8092,7 @@ msgid ""
" you make your first open source pull request!"
msgstr ""
-#: warehouse/templates/pages/help.html:880
+#: warehouse/templates/pages/help.html:882
#, python-format
msgid ""
"If you have skills in Python, ElasticSearch, HTML, SCSS, JavaScript, or "
@@ -8104,7 +8106,7 @@ msgid ""
"here."
msgstr ""
-#: warehouse/templates/pages/help.html:888
+#: warehouse/templates/pages/help.html:890
#, python-format
msgid ""
"Issues are grouped into Python packaging forum on Discourse."
msgstr ""
-#: warehouse/templates/pages/help.html:905
+#: warehouse/templates/pages/help.html:907
#, python-format
msgid ""
"Changes to PyPI are generally announced on both the %(href)s."
msgstr ""
-#: warehouse/templates/pages/help.html:916
+#: warehouse/templates/pages/help.html:918
#, python-format
msgid ""
"More information about this list can be found here: %(href)s."
msgstr ""
-#: warehouse/templates/pages/help.html:920
+#: warehouse/templates/pages/help.html:922
msgid ""
"When Warehouse's maintainers are deploying new features, at first we mark"
" them with a small \"beta feature\" symbol to tell you: this should "
@@ -8162,11 +8164,11 @@ msgid ""
"functionality."
msgstr ""
-#: warehouse/templates/pages/help.html:921
+#: warehouse/templates/pages/help.html:923
msgid "Currently, no features are in beta."
msgstr ""
-#: warehouse/templates/pages/help.html:925
+#: warehouse/templates/pages/help.html:927
#, python-format
msgid ""
"\"PyPI\" should be pronounced like \"pie pea eye\", specifically with the"
@@ -8176,39 +8178,39 @@ msgid ""
"implementation of the Python language."
msgstr ""
-#: warehouse/templates/pages/help.html:937
+#: warehouse/templates/pages/help.html:939
msgid "Resources"
msgstr ""
-#: warehouse/templates/pages/help.html:938
+#: warehouse/templates/pages/help.html:940
msgid "Looking for something else? Perhaps these links will help:"
msgstr ""
-#: warehouse/templates/pages/help.html:940
+#: warehouse/templates/pages/help.html:942
msgid "Python Packaging User Guide"
msgstr ""
-#: warehouse/templates/pages/help.html:941
+#: warehouse/templates/pages/help.html:943
msgid "Python documentation"
msgstr ""
-#: warehouse/templates/pages/help.html:942
+#: warehouse/templates/pages/help.html:944
msgid "(main Python website)"
msgstr ""
-#: warehouse/templates/pages/help.html:943
+#: warehouse/templates/pages/help.html:945
msgid "Python community page"
msgstr ""
-#: warehouse/templates/pages/help.html:943
+#: warehouse/templates/pages/help.html:945
msgid "(lists IRC channels, mailing lists, etc.)"
msgstr ""
-#: warehouse/templates/pages/help.html:946
+#: warehouse/templates/pages/help.html:948
msgid "Contact"
msgstr ""
-#: warehouse/templates/pages/help.html:948
+#: warehouse/templates/pages/help.html:950
#, python-format
msgid ""
"The
Date: Fri, 15 Sep 2023 17:11:45 -0400
Subject: [PATCH 3/8] Add license
---
warehouse/constants.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/warehouse/constants.py b/warehouse/constants.py
index 740dbde99502..be9c8fc7a354 100644
--- a/warehouse/constants.py
+++ b/warehouse/constants.py
@@ -1,3 +1,15 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+
ONE_MB = 1 * 1024 * 1024
ONE_GB = 1 * 1024 * 1024 * 1024
MAX_FILESIZE = 100 * ONE_MB
From f43e2da6fedd7e83dcbd32ba5d789e014a3d5a03 Mon Sep 17 00:00:00 2001
From: Suren Nihalani <1093911+SurenNihalani@users.noreply.github.com>
Date: Fri, 15 Sep 2023 17:31:48 -0400
Subject: [PATCH 4/8] sort
---
tests/unit/admin/views/test_projects.py | 1 +
tests/unit/forklift/test_legacy.py | 17 ++++++++++++-----
tests/unit/manage/test_views.py | 2 +-
warehouse/config.py | 8 +++++---
warehouse/forklift/legacy.py | 2 +-
warehouse/manage/views/__init__.py | 2 +-
6 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/tests/unit/admin/views/test_projects.py b/tests/unit/admin/views/test_projects.py
index ed1b41cd93a3..ce67c9e24e13 100644
--- a/tests/unit/admin/views/test_projects.py
+++ b/tests/unit/admin/views/test_projects.py
@@ -20,6 +20,7 @@
from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently, HTTPSeeOther
import warehouse.constants
+
from tests.common.db.oidc import GitHubPublisherFactory
from warehouse.admin.views import projects as views
from warehouse.packaging.models import Project, Role
diff --git a/tests/unit/forklift/test_legacy.py b/tests/unit/forklift/test_legacy.py
index e80ceba717b7..b375fa61d6a2 100644
--- a/tests/unit/forklift/test_legacy.py
+++ b/tests/unit/forklift/test_legacy.py
@@ -32,6 +32,7 @@
from wtforms.validators import ValidationError
import warehouse.constants
+
from warehouse.admin.flags import AdminFlag, AdminFlagValue
from warehouse.classifiers.models import Classifier
from warehouse.errors import BasicAuthTwoFactorEnabled
@@ -585,7 +586,9 @@ def test_zipfile_exceeds_compression_threshold(self, tmpdir):
with zipfile.ZipFile(f, "w") as zfp:
zfp.writestr("PKG-INFO", b"this is the package info")
- zfp.writestr("1.dat", b"0" * 65 * warehouse.constants.ONE_MB, zipfile.ZIP_DEFLATED)
+ zfp.writestr(
+ "1.dat", b"0" * 65 * warehouse.constants.ONE_MB, zipfile.ZIP_DEFLATED
+ )
assert not legacy._is_valid_dist_file(f, "")
@@ -1942,8 +1945,11 @@ def test_upload_fails_with_too_large_project_size_custom_limit(
name="foobar",
upload_limit=warehouse.constants.MAX_FILESIZE,
total_size=warehouse.constants.MAX_PROJECT_SIZE,
- total_size_limit=warehouse.constants.MAX_PROJECT_SIZE
- + one_megabyte, # Custom Limit for the project
+ total_size_limit=(
+ warehouse.constants.MAX_PROJECT_SIZE
+ + one_megabyte
+ # Custom Limit for the project
+ ),
)
release = ReleaseFactory.create(project=project, version="1.0")
RoleFactory.create(user=user, project=project)
@@ -1995,8 +2001,9 @@ def test_upload_succeeds_custom_project_size_limit(
name="foobar",
upload_limit=warehouse.constants.MAX_FILESIZE,
total_size=warehouse.constants.MAX_PROJECT_SIZE,
- total_size_limit=warehouse.constants.MAX_PROJECT_SIZE
- + (one_megabyte * 60), # Custom Limit for the project
+ total_size_limit=(
+ warehouse.constants.MAX_PROJECT_SIZE + (one_megabyte * 60)
+ ), # Custom Limit for the project
)
release = ReleaseFactory.create(project=project, version="1.0")
RoleFactory.create(user=user, project=project)
diff --git a/tests/unit/manage/test_views.py b/tests/unit/manage/test_views.py
index 32a8bd93cab9..383359eaaf5d 100644
--- a/tests/unit/manage/test_views.py
+++ b/tests/unit/manage/test_views.py
@@ -39,8 +39,8 @@
TokenExpired,
)
from warehouse.admin.flags import AdminFlagValue
-from warehouse.events.tags import EventTag
from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE
+from warehouse.events.tags import EventTag
from warehouse.macaroons import caveats
from warehouse.macaroons.interfaces import IMacaroonService
from warehouse.manage import views
diff --git a/warehouse/config.py b/warehouse/config.py
index 70cb8e6a5df4..7cc3009e2bee 100644
--- a/warehouse/config.py
+++ b/warehouse/config.py
@@ -29,10 +29,10 @@
from pyramid.tweens import EXCVIEW
from pyramid_rpc.xmlrpc import XMLRPCRenderer
+from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE, ONE_GB, ONE_MB
from warehouse.errors import BasicAuthBreachedPassword, BasicAuthFailedPassword
from warehouse.utils.static import ManifestCacheBuster
from warehouse.utils.wsgi import ProxyFixer, VhmRootRemover
-from warehouse.constants import ONE_MB, ONE_GB, MAX_FILESIZE, MAX_PROJECT_SIZE
class Environment(str, enum.Enum):
@@ -148,8 +148,10 @@ def from_base64_encoded_json(configuration):
def configure(settings=None):
if settings is None:
settings = {}
- settings['warehouse.forklift.legacy.MAX_FILESIZE_MB'] = MAX_FILESIZE / ONE_MB
- settings['warehouse.forklift.legacy.MAX_PROJECT_SIZE_GB'] = MAX_PROJECT_SIZE / ONE_GB
+ settings["warehouse.forklift.legacy.MAX_FILESIZE_MB"] = MAX_FILESIZE / ONE_MB
+ settings["warehouse.forklift.legacy.MAX_PROJECT_SIZE_GB"] = (
+ MAX_PROJECT_SIZE / ONE_GB
+ )
# Add information about the current copy of the code.
maybe_set(settings, "warehouse.commit", "SOURCE_COMMIT", default="null")
diff --git a/warehouse/forklift/legacy.py b/warehouse/forklift/legacy.py
index 812a4239500d..5b900754d438 100644
--- a/warehouse/forklift/legacy.py
+++ b/warehouse/forklift/legacy.py
@@ -47,7 +47,7 @@
from warehouse import forms
from warehouse.admin.flags import AdminFlagValue
from warehouse.classifiers.models import Classifier
-from warehouse.constants import ONE_MB, ONE_GB, MAX_FILESIZE, MAX_PROJECT_SIZE
+from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE, ONE_GB, ONE_MB
from warehouse.email import (
send_basic_auth_with_two_factor_email,
send_gpg_signature_uploaded_email,
diff --git a/warehouse/manage/views/__init__.py b/warehouse/manage/views/__init__.py
index 3d7c469b052c..a881b3479056 100644
--- a/warehouse/manage/views/__init__.py
+++ b/warehouse/manage/views/__init__.py
@@ -42,6 +42,7 @@
from warehouse.accounts.models import Email, User
from warehouse.accounts.views import logout
from warehouse.admin.flags import AdminFlagValue
+from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE
from warehouse.email import (
send_account_deletion_email,
send_added_as_collaborator_email,
@@ -69,7 +70,6 @@
send_yanked_project_release_email,
)
from warehouse.events.tags import EventTag
-from warehouse.constants import MAX_FILESIZE, MAX_PROJECT_SIZE
from warehouse.macaroons import caveats
from warehouse.macaroons.interfaces import IMacaroonService
from warehouse.manage.forms import (
From 95df8ec1177beb10ba44d8d5681c5771c035a80c Mon Sep 17 00:00:00 2001
From: Suren Nihalani <1093911+SurenNihalani@users.noreply.github.com>
Date: Fri, 15 Sep 2023 18:06:45 -0400
Subject: [PATCH 5/8] Test config
---
tests/unit/test_config.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
index 7c4acff56fde..c85b5f42db39 100644
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_config.py
@@ -276,6 +276,8 @@ def __init__(self):
"warehouse.two_factor_mandate.cohort_size": 0,
"reconcile_file_storages.batch_size": 100,
"gcloud.service_account_info": {},
+ "warehouse.forklift.legacy.MAX_FILESIZE_MB": 100,
+ "warehouse.forklift.legacy.MAX_PROJECT_SIZE_GB": 10,
}
if environment == config.Environment.development:
expected_settings.update(
From 85eb9a0b6cb7ff61ea7c4d8929df0be779eca9bb Mon Sep 17 00:00:00 2001
From: Barry Warsaw