-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yehoshuadimarsky/dev
Automation, bug fixes
- Loading branch information
Showing
10 changed files
with
261 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,13 @@ | ||
{ | ||
"GH_user": "yehoshuadimarsky", | ||
"name": "bcpandas", | ||
"version": "0.1.3", | ||
"GH_release_name": "v0.1.3 Release", | ||
"GH_release_message": "Working to automate releases to GitHub, PyPI, and Conda-Forge.\n Fixed bug in `read_sql` that didn't set QUERYOUT when reading from a query.\n Added constructor to SqlCreds to create from SQLAlchemy.", | ||
"short_description": "High-level wrapper around BCP for high performance data transfers between pandas and SQL Server. No knowledge of BCP required!!", | ||
"author": "Josh Dimarsky", | ||
"dependencies": [ | ||
"python >=3.6", | ||
"pandas >=0.22" | ||
] | ||
} |
This file contains 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,51 @@ | ||
|
||
# get configs and auth | ||
Write-Host "Getting Configs..." | ||
$config = Get-Content -Raw -Path "./dist.json" | ConvertFrom-Json | ||
$auth = Get-Content -Raw -Path "./creds.json" | ConvertFrom-Json | ||
|
||
$url = "https://github.com/$($config.GH_user)/$($config.name)/archive/$($config.version).tar.gz" | ||
$dest = "$ENV:USERPROFILE\Downloads\$($config.name)-$(Split-Path $url -Leaf)" | ||
$condaEnv = "dist-env" | ||
|
||
|
||
# Setup conda | ||
conda create -n $condaEnv python -y | ||
conda install -n $condaEnv -c conda-forge pygithub twine click jinja2 -y | ||
# get path to env python | ||
$envpath = ((conda info -e) -match $condaEnv ).Split(" ")[-1] | ||
|
||
|
||
# deploy to GitHub | ||
Start-Process "$envpath\python.exe" -ArgumentList ".\dist.py github-release" -NoNewWindow -Wait | ||
|
||
|
||
# PyPI | ||
if (Test-Path "./dist") { Remove-Item "./dist" -Recurse; } | ||
python .\setup.py sdist bdist_wheel | ||
|
||
# add --repository-url https://test.pypi.org/legacy/ if to test.pypi.org | ||
Start-Process "$envpath\python.exe" -ArgumentList "-m twine upload --verbose -u $($auth.pypi_username) -p $($auth.pypi_password) dist/*" -NoNewWindow -Wait | ||
|
||
|
||
# conda | ||
# get sha256 of GitHub tar.gz | ||
Write-Host "Downloading $($config.name) from $url" | ||
(New-Object System.Net.WebClient).DownloadFile($url, $dest) | ||
if (!(Test-Path $dest)) { | ||
Write-Host "Error, $($config.name) not found in $dest" -ForegroundColor Red | ||
} else { | ||
Write-Host "$($config.name) downloaded successfully to $dest" -ForegroundColor Green | ||
} | ||
$hash = (certutil -hashfile $dest sha256 )[1] # returns 3 rows, 2nd is hash | ||
|
||
# render meta.yaml | ||
Start-Process "$envpath\python.exe" -ArgumentList ".\dist.py render-conda --sha256 $hash" -NoNewWindow -Wait | ||
|
||
|
||
# TODO upload meta.yaml to conda-forge feedstock, create PR | ||
|
||
# cleanup | ||
Remove-Item -Path $dest | ||
conda remove -n $condaEnv --all -y | ||
Remove-Item -Path $envpath -Recurse |
This file contains 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,72 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Tue Aug 6 22:05:04 2019 | ||
@author: JoshDimarsky | ||
""" | ||
|
||
import json | ||
|
||
import click | ||
from jinja2 import Environment, FileSystemLoader | ||
from github import Github | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
|
||
@cli.command() | ||
def github_release(): | ||
print("getting auth and config") | ||
with open("./creds.json") as file: | ||
auth = json.load(file) | ||
|
||
with open("./dist.json") as file: | ||
config = json.load(file) | ||
print("auth and config loaded") | ||
|
||
print("logging into GitHub") | ||
g = Github(auth["github_token"]) | ||
repo = g.get_repo(f"{config['GH_user']}/{config['name']}") | ||
master_branch = repo.get_branch("master") | ||
|
||
print("Creating release") | ||
# https://pygithub.readthedocs.io/en/latest/github_objects/Repository.html#github.Repository.Repository.create_git_release | ||
repo.create_git_release( | ||
tag=config["version"], | ||
name=config["GH_release_name"], | ||
message=config["GH_release_message"], | ||
draft=False, | ||
prerelease=False, | ||
target_commitish=master_branch, | ||
) | ||
print("All done!") | ||
|
||
|
||
@cli.command() | ||
@click.option("--sha256", required=True, type=str) | ||
def render_conda(sha256): | ||
print("jinja rendering conda template file called meta.template.yaml ...") | ||
with open("./dist.json", "r") as file: | ||
config = json.load(file) | ||
|
||
env = Environment(loader=FileSystemLoader(".")) | ||
t = env.get_template("meta.template.yaml") | ||
|
||
rendered = t.render( | ||
name=config["name"], | ||
version=config["version"], | ||
sha256val=sha256, | ||
creator=config["GH_user"], | ||
dependencies=config["dependencies"], | ||
PYTHON="{{ PYTHON }}", | ||
) | ||
with open("./meta.yaml", "wt") as yaml_file: | ||
yaml_file.write(rendered) | ||
print("all done - file rendered and saved as meta.yaml") | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
This file contains 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,42 @@ | ||
package: | ||
name: {{ name|lower }} | ||
version: "{{ version }}" | ||
|
||
source: | ||
url: https://github.com/{{ creator }}/{{ name }}/archive/{{ version }}.tar.gz | ||
sha256: {{ sha256val }} | ||
|
||
build: | ||
noarch: python | ||
number: 0 | ||
script: "{{ PYTHON }} -m pip install . -vv" | ||
|
||
requirements: | ||
host: | ||
- python >=3.6 | ||
- pip | ||
- setuptools | ||
|
||
run: {% for dep in dependencies %} | ||
- {{ dep }} {% endfor %} | ||
|
||
test: | ||
imports: | ||
- bcpandas | ||
|
||
about: | ||
home: https://pypi.org/project/{{ name }} | ||
license: MIT | ||
license_family: MIT | ||
license_file: LICENSE | ||
summary: Wrapper around BCP to transfer data between pandas and SQL Server. | ||
description: | | ||
High-level wrapper around BCP for high performance data transfers between pandas and SQL Server. | ||
No knowledge of BCP required!! | ||
doc_url: https://github.com/{{ creator }}/{{ name }} | ||
dev_url: https://github.com/{{ creator }}/{{ name }} | ||
|
||
extra: | ||
recipe-maintainers: | ||
- {{ creator }} | ||
|
This file contains 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
Oops, something went wrong.