-
-
Notifications
You must be signed in to change notification settings - Fork 792
Expose all .whl,.ABOUT, .NOTICE,.LICENCE files and Create an archive #2117
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
Merged
pombredanne
merged 8 commits into
aboutcode-org:develop
from
Abhishek-Dev09-zz:#295-github_release
Jul 27, 2020
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f08eacf
Expose all .whl, and other files and Create an archive
Abhishek-Dev09 89e957e
Move all script to etc/scripts
Abhishek-Dev09 90bff2b
Use abspath instead of expanduser
Abhishek-Dev09 2e80d15
Format the script properly
Abhishek-Dev09 393fad4
Sort imports,remove examples,use proper variable name
Abhishek-Dev09 d0e1386
Improve the description and documentation of function
Abhishek-Dev09 27c4e86
Improve help texts
pombredanne c062d21
Improve release creation and upload #2072
pombredanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # | ||
| # Copyright (c) nexB Inc. and others. All rights reserved. | ||
| # http://nexb.com and https://github.com/nexB/scancode-toolkit/ | ||
| # The ScanCode software is licensed under the Apache License version 2.0. | ||
| # Data generated with ScanCode require an acknowledgment. | ||
| # ScanCode is a trademark of nexB Inc. | ||
| # | ||
| # You may not use this software except in compliance with the License. | ||
| # You may obtain a copy of the License at: http://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. | ||
| # | ||
| # When you publish or redistribute any data created with ScanCode or any ScanCode | ||
| # derivative work, you must accompany this data with the following acknowledgment: | ||
| # | ||
| # Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
| # OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
| # ScanCode should be considered or used as legal advice. Consult an Attorney | ||
| # for any legal advice. | ||
| # ScanCode is a free software code scanning tool from nexB Inc. and others. | ||
| # Visit https://github.com/nexB/scancode-toolkit/ for support and download. | ||
|
|
||
| from __future__ import absolute_import | ||
| from __future__ import print_function | ||
|
|
||
| import argparse | ||
| from commoncode.system import on_windows | ||
| import os | ||
| from shutil import make_archive | ||
| import sys | ||
|
|
||
|
|
||
| def generate_OS_archive(input_dir, output): | ||
| """ | ||
| Generate an archive for dependencies for specific OS and | ||
| given version of python by taking directory as an input. | ||
| """ | ||
|
|
||
| root_dir = os.path.expanduser(os.path.join("~", input_dir)) | ||
| output_dir = os.path.expanduser(os.path.join("~", output)) | ||
| if on_windows: | ||
| make_archive(output_dir, "zip", root_dir) | ||
| else: | ||
| make_archive(output_dir, "gztar", root_dir) | ||
|
|
||
|
|
||
| def main_with_args(args: str) -> None: | ||
| parser = argparse.ArgumentParser( | ||
| description="""Creates a archive for specific OS and specific python. | ||
| EXAMPLE: | ||
| generate_OS_archive.py \\ | ||
| --input scancode-toolkit/thirdparty \\ | ||
| --output Desktop/macOS_py36 \\ | ||
| """, | ||
| formatter_class=argparse.RawDescriptionHelpFormatter, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--input", | ||
| help="Required: Thirdparty Dependencies directory to be archived. ", | ||
| type=str, | ||
| required=True, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--output", | ||
| help="Required: The Generated archive file name without extension. ", | ||
| type=str, | ||
| required=True, | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| input_dir = args.input | ||
| output = args.output | ||
| generate_OS_archive(input_dir, output) | ||
|
|
||
|
|
||
| def main() -> None: | ||
| main_with_args(sys.argv[1:]) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # | ||
| # Copyright (c) nexB Inc. and others. All rights reserved. | ||
| # http://nexb.com and https://github.com/nexB/scancode-toolkit/ | ||
| # The ScanCode software is licensed under the Apache License version 2.0. | ||
| # Data generated with ScanCode require an acknowledgment. | ||
| # ScanCode is a trademark of nexB Inc. | ||
| # | ||
| # You may not use this software except in compliance with the License. | ||
| # You may obtain a copy of the License at: http://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. | ||
| # | ||
| # When you publish or redistribute any data created with ScanCode or any ScanCode | ||
| # derivative work, you must accompany this data with the following acknowledgment: | ||
| # | ||
| # Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
| # OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
| # ScanCode should be considered or used as legal advice. Consult an Attorney | ||
| # for any legal advice. | ||
| # ScanCode is a free software code scanning tool from nexB Inc. and others. | ||
| # Visit https://github.com/nexB/scancode-toolkit/ for support and download. | ||
|
|
||
| from __future__ import absolute_import | ||
| from __future__ import print_function | ||
|
|
||
| import argparse | ||
| from commoncode.fileutils import resource_iter | ||
| import fnmatch | ||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
|
|
||
| def release_asset(token, tag, repo, body, user, limit, file): | ||
| """ | ||
| Release .whl,.ABOUT,.NOTICE,.LICENSE to github repository from | ||
| given directory. | ||
| """ | ||
|
|
||
| cwd = os.getcwd() | ||
| os.environ["GITHUB_TOKEN"] = token | ||
| thirdparty = list(resource_iter(file, with_dirs=False)) | ||
| # FIXME this code is for py 3.6 and later we will update for all version | ||
| dependencies = [ | ||
| files | ||
| for files in thirdparty | ||
| if fnmatch.fnmatchcase(files, "*py3*") | ||
| or fnmatch.fnmatchcase(files, "*cp36*") | ||
| or ( | ||
| fnmatch.fnmatchcase(files, "*tar.gz*") | ||
| and not fnmatch.fnmatchcase(files, "*py2-ipaddress-3.4.1.tar.gz*") | ||
| ) | ||
| ] | ||
| for deps in dependencies: | ||
| print(deps) | ||
| subprocess.run( | ||
| [ | ||
| "python3", | ||
| "-m", | ||
| "github_release_retry.github_release_retry", | ||
| "--user", | ||
| user, | ||
| "--repo", | ||
| repo, | ||
| "--tag_name", | ||
| tag, | ||
| "--body_string", | ||
| body, | ||
| "--retry_limit", | ||
| limit, | ||
| deps, | ||
| ] | ||
| ) | ||
|
|
||
|
|
||
| def main_with_args(args: str) -> None: | ||
| parser = argparse.ArgumentParser( | ||
| description="""Creates a GitHub release (if it does not already exist) and uploads files to the release. | ||
| Please pass the GITHUB_TOKEN as an argument. | ||
| EXAMPLE: | ||
| github-release-asset \\ | ||
| --user Abhishek-Dev09 \\ | ||
| --repo thirdparty \\ | ||
| --tag_name v1.0 \\ | ||
| --body_string "Python 3.6 wheels" \\ | ||
| hello-world.zip RELEASE_NOTES.txt | ||
| """, | ||
| formatter_class=argparse.RawDescriptionHelpFormatter, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--user", | ||
| help="Required: The GitHub username or organization name in which the repo resides. ", | ||
| type=str, | ||
| required=True, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--token", | ||
| help="Required: The Github token is required to acess the repository where you want to upload . ", | ||
| type=str, | ||
| required=True, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--repo", | ||
| help="Required: The GitHub repo name in which to make the release. ", | ||
| type=str, | ||
| required=True, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--tag_name", | ||
| help="Required: The name of the tag to create or use. ", | ||
| type=str, | ||
| required=True, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--body_string", | ||
| help="Required (or use --body_file): Text describing the release. Ignored if the release already exists.", | ||
| type=str, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--retry_limit", | ||
| help="The number of times to retry creating/getting the release and/or uploading each file. ", | ||
| type=str, | ||
| default="10", | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--files", type=str, help="The files to upload to the release.", | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| token = args.token | ||
| tag = args.tag_name | ||
| repo = args.repo | ||
| body = args.body_string | ||
| user = args.user | ||
| limit = args.retry_limit | ||
| file = args.files | ||
|
|
||
| release_asset(token, tag, repo, body, user, limit, file) | ||
|
|
||
|
|
||
| def main() -> None: | ||
| main_with_args(sys.argv[1:]) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.