Skip to content

Commit 3fb1ef0

Browse files
committed
Initial commit
0 parents  commit 3fb1ef0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2985
-0
lines changed

.bumpversion.cfg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[bumpversion]
2+
current_version = 0.1.1
3+
commit = True
4+
tag = True
5+
6+
[bumpversion:file:__pkginfo__.py]
7+
8+
[bumpversion:file:README.rst]
9+
10+
[bumpversion:file:doc-source/index.rst]
11+
12+
[bumpversion:file:repo_helper.yml]
13+
14+
[bumpversion:file:coverage_pyver_pragma/__init__.py]

.ci/copy_pypi_2_github.py

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# stdlib
2+
import json
3+
import os
4+
import pathlib
5+
import sys
6+
import tempfile
7+
import urllib.parse
8+
9+
# 3rd party
10+
import github
11+
import requests
12+
13+
14+
def get_pypi_releases(project_name):
15+
16+
pypi_releases = {}
17+
18+
# Parse PyPI data
19+
r = requests.get(f"https://pypi.org/pypi/{project_name}/json")
20+
if r.status_code != 200:
21+
print(f"Unable to get package data from PyPI for '{project_name}'", file=sys.stderr)
22+
23+
else:
24+
pkg_info = json.loads(r.content)
25+
26+
for release, release_data in pkg_info["releases"].items():
27+
release_urls = []
28+
for file in release_data:
29+
release_urls.append(file["url"])
30+
pypi_releases[release] = release_urls
31+
32+
return pypi_releases
33+
34+
35+
def update_github_release(repo, tag_name, release_name, release_message):
36+
current_assets = []
37+
38+
try:
39+
release = repo.get_release(tag_name)
40+
41+
# Update existing release
42+
release.update_release(name=release_name, message=release_message)
43+
44+
# Get list of current assets for release
45+
for asset in release.get_assets():
46+
current_assets.append(asset.name)
47+
48+
except github.UnknownObjectException:
49+
50+
# Create the release
51+
release = repo.create_git_release(tag=tag_name, name=release_name, message=release_message)
52+
53+
return release, current_assets
54+
55+
56+
def get_file_from_pypi(url, tmpdir):
57+
filename = pathlib.PosixPath(urllib.parse.urlparse(url).path).name
58+
59+
r = requests.get(url)
60+
if r.status_code != 200:
61+
print(f"Unable to download '{filename}' from PyPI. Skipping.", file=sys.stderr)
62+
return False
63+
64+
(tmpdir / filename).write_bytes(r.content)
65+
66+
return True
67+
68+
69+
def copy_pypi_2_github(g, repo_name, github_username, *, release_message='', pypi_name=None):
70+
repo_name = str(repo_name)
71+
github_username = str(github_username)
72+
73+
if not pypi_name:
74+
pypi_name = repo_name
75+
pypi_name = str(pypi_name)
76+
77+
pypi_releases = get_pypi_releases(pypi_name)
78+
79+
repo = g.get_repo(f"{github_username}/{repo_name}")
80+
print(repo.name)
81+
82+
with tempfile.TemporaryDirectory() as tmpdir:
83+
tmpdir = pathlib.Path(tmpdir)
84+
85+
for tag in repo.get_tags():
86+
version = tag.name.lstrip("v")
87+
if version not in pypi_releases:
88+
sys.stdout.flush()
89+
print(f"No PyPI release found for tag '{tag.name}'. Skipping.", file=sys.stderr)
90+
sys.stderr.flush()
91+
continue
92+
93+
print(f"Processing release for {version}")
94+
release_name = f"Version {version}"
95+
release_message += f"""
96+
Automatically copied from PyPI.
97+
https://pypi.org/project/{pypi_name}/{version}
98+
"""
99+
100+
release, current_assets = update_github_release(repo, tag.name, release_name, release_message)
101+
102+
# pprint(pypi_releases[version])
103+
# Copy the files from PyPI
104+
105+
for pypi_url in pypi_releases[version]:
106+
filename = pathlib.PosixPath(urllib.parse.urlparse(pypi_url).path).name
107+
# print(filename)
108+
109+
if filename in current_assets:
110+
sys.stdout.flush()
111+
print(f"File '{filename}' already exists for release '{tag.name}'. Skipping.", file=sys.stderr)
112+
sys.stderr.flush()
113+
continue
114+
115+
if get_file_from_pypi(pypi_url, tmpdir):
116+
print(f"Copying {filename} from PyPi to GitHub Releases")
117+
release.upload_asset(str(tmpdir / filename))
118+
else:
119+
continue
120+
121+
122+
if __name__ == '__main__':
123+
gh_token = os.environ.get("GITHUB_TOKEN")
124+
if not gh_token:
125+
sys.stdout.flush()
126+
print("Please supply a GitHub token via the environment variable `GITHUB_TOKEN`.", file=sys.stderr)
127+
sys.stderr.flush()
128+
sys.exit(1)
129+
130+
g = github.Github(gh_token)
131+
132+
rate = g.get_rate_limit()
133+
remaining_requests = rate.core.remaining
134+
print(rate)
135+
136+
github_username = "domdfcoding"
137+
138+
copy_pypi_2_github(g, "coverage_pyver_pragma", "domdfcoding", pypi_name="coverage_pyver_pragma")
139+
140+
rate = g.get_rate_limit()
141+
used_requests = remaining_requests - rate.core.remaining
142+
print(f"Used {used_requests} requests. {rate.core.remaining} remaining. Resets at {rate.core.reset}")

.ci/travis_deploy_conda.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# This file is managed by `repo_helper`. Don't edit it directly
3+
4+
set -e -x
5+
6+
if [ $TRAVIS_PYTHON_VERSION == 3.6 ]; then
7+
if [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_COMMIT_MESSAGE" == "Bump Version*" ]; then
8+
echo "Deferring building conda package because this is release"
9+
else
10+
11+
python3 ./make_conda_recipe.py || exit 1
12+
13+
# Switch to miniconda
14+
source "$HOME/miniconda/etc/profile.d/conda.sh"
15+
hash -r
16+
conda activate base
17+
conda config --set always_yes yes --set changeps1 no
18+
conda update -q conda
19+
conda install conda-build
20+
conda install anaconda-client
21+
conda info -a
22+
23+
conda config --add channels domdfcoding || exit 1
24+
25+
conda config --add channels conda-forge || exit 1
26+
27+
conda build conda -c domdfcoding -c conda-forge --output-folder conda/dist --skip-existing
28+
29+
for f in conda/dist/noarch/coverage_pyver_pragma-*.tar.bz2; do
30+
[ -e "$f" ] || continue
31+
echo "$f"
32+
conda install $f || exit 1
33+
echo "Deploying to Anaconda.org..."
34+
anaconda -t $ANACONDA_TOKEN upload $f || exit 1
35+
echo "Successfully deployed to Anaconda.org."
36+
done
37+
38+
fi
39+
40+
else
41+
echo "Skipping deploying conda package because this is not the required runtime"
42+
fi
43+
44+
exit 0

.dependabot/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This file is managed by `repo_helper`. Don't edit it directly
2+
3+
version: 1
4+
update_configs:
5+
- package_manager: "python"
6+
directory: "/"
7+
update_schedule: "weekly"
8+
default_reviewers:
9+
- "domdfcoding"

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
labels: bug
5+
assignees: domdfcoding
6+
7+
---
8+
9+
<!-- Have you searched for similar issues? Before submitting this issue, please check the open issues and add a note before logging a new issue.
10+
11+
PLEASE USE THE TEMPLATE BELOW TO PROVIDE INFORMATION ABOUT THE ISSUE.
12+
INSUFFICIENT INFO WILL GET THE ISSUE CLOSED. IT WILL ONLY BE REOPENED AFTER SUFFICIENT INFO IS PROVIDED-->
13+
14+
## Description
15+
<!--Provide a brief description of the issue-->
16+
17+
18+
## Steps to Reproduce
19+
<!--Please add a series of steps to reproduce the issue-->
20+
21+
1.
22+
2.
23+
3.
24+
25+
## Actual result:
26+
<!--Please add screenshots if needed and include the Python traceback if present-->
27+
28+
29+
## Expected result:
30+
31+
32+
## Reproduces how often:
33+
<!--[Easily reproduced/Intermittent issue/No steps to reproduce]-->
34+
35+
36+
## Version
37+
38+
* Operating System:
39+
* Python:
40+
* coverage_pyver_pragma:
41+
42+
## Installation source
43+
<!-- e.g. Github repository, Github Releases, PyPI/pip, Anaconda/conda -->
44+
45+
46+
## Other Additional Information:
47+
<!--Any additional information, related issues, extra QA steps, configuration or data that might be necessary to reproduce the issue-->
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
labels: "enhancement"
5+
assignees: domdfcoding
6+
7+
---
8+
9+
<!-- Have you searched for similar issues? Someone may already be working on the feature you are suggesting. Before submitting this issue, please check the open issues and add a note before logging a new issue.
10+
11+
PLEASE USE THE TEMPLATE BELOW TO PROVIDE INFORMATION ABOUT THE ISSUE.
12+
INSUFFICIENT INFO WILL GET THE ISSUE CLOSED. IT WILL ONLY BE REOPENED AFTER SUFFICIENT INFO IS PROVIDED-->
13+
14+
15+
## Description
16+
<!--Provide a clear and concise description of what the problem is and the improvement you are suggesting-->
17+
18+
<!--Please add screenshots if needed-->
19+
20+
21+
## Version
22+
23+
* Operating System:
24+
* Python:
25+
* coverage_pyver_pragma:
26+
27+
28+
## Other Additional Information:
29+
<!--Any additional information, related issues, etc.-->

.github/auto_assign.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file is managed by `repo_helper`. Don't edit it directly
2+
3+
# Set to true to add reviewers to pull requests
4+
addReviewers: true
5+
6+
# Set to true to add assignees to pull requests
7+
addAssignees: true
8+
9+
# A list of reviewers to be added to pull requests (GitHub user name)
10+
reviewers:
11+
- domdfcoding
12+
13+
# A number of reviewers added to the pull request
14+
# Set 0 to add all the reviewers (default: 0)
15+
numberOfReviewers: 0
16+
17+
# A list of assignees, overrides reviewers if set
18+
# assignees:
19+
# - assigneeA
20+
21+
# A number of assignees to add to the pull request
22+
# Set to 0 to add all of the assignees.
23+
# Uses numberOfReviewers if unset.
24+
# numberOfAssignees: 2
25+
26+
# A list of keywords to be skipped the process that add reviewers if pull requests include it
27+
# skipKeywords:
28+
# - wip
29+
30+
# more settings at https://github.com/marketplace/actions/auto-assign-action

.github/stale.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
3+
# Number of days of inactivity before an Issue or Pull Request becomes stale
4+
daysUntilStale: 180
5+
6+
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8+
daysUntilClose: 180
9+
10+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11+
onlyLabels: []
12+
13+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14+
exemptLabels:
15+
- pinned
16+
- security
17+
- "[Status] Maybe Later"
18+
19+
# Set to true to ignore issues in a project (defaults to false)
20+
exemptProjects: false
21+
22+
# Set to true to ignore issues in a milestone (defaults to false)
23+
exemptMilestones: false
24+
25+
# Set to true to ignore issues with an assignee (defaults to false)
26+
exemptAssignees: false
27+
28+
# Label to use when marking as stale
29+
staleLabel: wontfix
30+
31+
# Comment to post when marking as stale. Set to `false` to disable
32+
markComment: >
33+
This issue has been automatically marked as stale because it has not had
34+
recent activity. It will be closed if no further activity occurs. Thank you
35+
for your contributions.
36+
37+
# Comment to post when removing the stale label.
38+
# unmarkComment: >
39+
# Your comment here.
40+
41+
# Comment to post when closing a stale Issue or Pull Request.
42+
# closeComment: >
43+
# Your comment here.
44+
45+
# Limit the number of actions per hour, from 1-30. Default is 30
46+
limitPerRun: 30
47+
48+
# Limit to only `issues` or `pulls`
49+
# only: issues
50+
51+
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
52+
# pulls:
53+
# daysUntilStale: 30
54+
# markComment: >
55+
# This pull request has been automatically marked as stale because it has not had
56+
# recent activity. It will be closed if no further activity occurs. Thank you
57+
# for your contributions.
58+
59+
# issues:
60+
# exemptLabels:
61+
# - confirmed

0 commit comments

Comments
 (0)