-
Notifications
You must be signed in to change notification settings - Fork 19
Verify dependencies before uploading a package #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9394f75
22e9c55
f093778
9503f1c
8a8fc6d
1da9b8c
c892ac4
8276b7e
87c30a2
bb1bac1
f38e582
1269a2f
d600e18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
types-Routes | ||
types-attrs | ||
types-enum34 | ||
types-first | ||
types-mypy-extensions | ||
types-six | ||
types-toml | ||
types-typed-ast | ||
types-typing-extensions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
""" | ||
Entry point for scheduled GitHub auto-upload action. | ||
|
||
This does three things: | ||
This does following things: | ||
* Reads the list of stub packages modified since last commit in typeshed | ||
* Checks what is the current stub version increment for each package on PyPI | ||
* Bumps the increment, builds and uploads (unless run with --dry-run) each | ||
new package to PyPI | ||
* Verifies validity of stub dependencies, and updates known dependencies if needed | ||
""" | ||
|
||
import argparse | ||
|
@@ -17,24 +18,34 @@ | |
from scripts import get_changed | ||
|
||
|
||
def main(typeshed_dir: str, commit: str, dry_run: bool = False) -> None: | ||
def main(typeshed_dir: str, commit: str, uploaded: str, dry_run: bool = False) -> None: | ||
"""Upload stub typeshed packages modified since commit.""" | ||
changed = get_changed.main(typeshed_dir, commit) | ||
for distribution in changed: | ||
# Sort by dependency to prevent depending on foreign distributions. | ||
to_upload = build_wheel.sort_by_dependency( | ||
build_wheel.make_dependency_map(typeshed_dir, changed) | ||
) | ||
for distribution in to_upload: | ||
# Setting base version to None, so it will be read from current METADATA.toml. | ||
increment = get_version.main(typeshed_dir, distribution, None) | ||
increment += 1 | ||
temp_dir = build_wheel.main(typeshed_dir, distribution, increment) | ||
if dry_run: | ||
print(f"Would upload: {distribution}, increment {increment}") | ||
continue | ||
for dependency in build_wheel.read_matadata( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Share this code? It seems repeated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I tried, but because of one line in the middle that is different it doesn't look worth it. |
||
os.path.join(typeshed_dir, build_wheel.THIRD_PARTY_NAMESPACE, distribution) | ||
).get("requires", []): | ||
build_wheel.verify_dependency(typeshed_dir, dependency, uploaded) | ||
subprocess.run(["twine", "upload", os.path.join(temp_dir, "*")], check=True) | ||
build_wheel.update_uploaded(uploaded, distribution) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("typeshed_dir", help="Path to typeshed checkout directory") | ||
parser.add_argument("previous_commit", help="Previous typeshed commit for which we performed upload") | ||
parser.add_argument("uploaded", help="Previously uploaded packages to validate dependencies") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a path to a file, not the name of packages? Make the help text more explicit. |
||
parser.add_argument("--dry-run", action="store_true", help="Should we perform a dry run (don't actually upload)") | ||
args = parser.parse_args() | ||
main(args.typeshed_dir, args.previous_commit, args.dry_run) | ||
main(args.typeshed_dir, args.previous_commit, args.uploaded, args.dry_run) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
""" | ||
Entry point for manual GitHub upload action. | ||
|
||
This does three things: | ||
This does following things: | ||
* Finds all distributions with names that match the pattern provided | ||
* Checks what is the current stub version increment for each package on PyPI | ||
* Bumps the increment, builds and uploads the each new package to PyPI | ||
* Verifies validity of stub dependencies, and updates known dependencies if needed | ||
""" | ||
|
||
import argparse | ||
|
@@ -16,22 +17,33 @@ | |
from scripts import build_wheel | ||
|
||
|
||
def main(typeshed_dir: str, pattern: str) -> None: | ||
def main(typeshed_dir: str, pattern: str, uploaded: str) -> None: | ||
"""Force upload typeshed stub packages to PyPI.""" | ||
compiled = re.compile(f"^{pattern}$") # force exact matches | ||
for distribution in os.listdir(os.path.join(typeshed_dir, "stubs")): | ||
if not re.match(compiled, distribution): | ||
continue | ||
matching = [ | ||
d for d in os.listdir(os.path.join(typeshed_dir, "stubs")) if re.match(compiled, d) | ||
] | ||
# Sort by dependency to prevent depending on foreign distributions. | ||
to_upload = build_wheel.sort_by_dependency( | ||
build_wheel.make_dependency_map(typeshed_dir, matching) | ||
) | ||
for distribution in to_upload: | ||
# Setting base version to None, so it will be read from current METADATA.toml. | ||
increment = get_version.main(typeshed_dir, distribution, version=None) | ||
increment += 1 | ||
for dependency in build_wheel.read_matadata( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the other copy which looks the same. |
||
os.path.join(typeshed_dir, build_wheel.THIRD_PARTY_NAMESPACE, distribution) | ||
).get("requires", []): | ||
build_wheel.verify_dependency(typeshed_dir, dependency, uploaded) | ||
temp_dir = build_wheel.main(typeshed_dir, distribution, increment) | ||
subprocess.run(["twine", "upload", os.path.join(temp_dir, "*")], check=True) | ||
build_wheel.update_uploaded(uploaded, distribution) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("typeshed_dir", help="Path to typeshed checkout directory") | ||
parser.add_argument("pattern", help="Pattern to select distributions for upload") | ||
parser.add_argument("pattern", help="Regular expression to select distributions for upload") | ||
parser.add_argument("uploaded", help="Previously uploaded packages to validate dependencies") | ||
args = parser.parse_args() | ||
main(args.typeshed_dir, args.pattern) | ||
main(args.typeshed_dir, args.pattern, args.uploaded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there is a space before
>=
? There could also be a semicolon. This example is fromtest-requirements.txt
for mypy:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should not be semicolons,
requires
is a list already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't notice what is in the second part, I think we may not support this initially.