diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 00000000000000..1a03a7b6c4911d --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/PCbuild/prepare_ssl.py b/PCbuild/prepare_ssl.py index 0f3c63ee24ffba..af4e605338ec19 100755 --- a/PCbuild/prepare_ssl.py +++ b/PCbuild/prepare_ssl.py @@ -25,6 +25,70 @@ import sys import subprocess from shutil import copy +import os +import yaml +from typing import NoReturn + + +def create_directory(directory: str) -> NoReturn: + """ + Create a directory if it doesn't exist. + + Parameters + ---------- + directory : string + A ``string`` of the full directory path to create if it doesn't exist. + """ + if not os.path.exists(directory): + os.makedirs(directory) + + +def update_log(logfile: str, contents: str) -> NoReturn: + """ + Append a log with new output from a test. + + Parameters + ---------- + logfile : string + A ``string`` of the logfile to write data to. + contents : string + A ``string`` of the contents to append the log file with. + """ + with open(logfile, 'a') as log: + log.write(contents) + + +def write_file(filename: str, contents: str) -> NoReturn: + """ + Write data to a file. + + Parameters + ---------- + filename : string + A ``string`` of the file to write data to. + contents : string + A ``string`` of the contents to write to the file. + """ + with open(filename, 'w') as fp: + fp.write(contents) + + +def read_yaml(filename: str) -> dict: + """ + Read a YAML file and return the contents. + + Parameters + ---------- + filename : string + A ``string`` of the full file path to read. + + Returns + ------- + dict + Returns a ``dict`` representing the entire contents of the file. + """ + with open(filename, 'r') as handler: + return yaml.safe_load(handler) # Find all "foo.exe" files on the PATH. def find_all_on_path(filename, extras=None): @@ -71,12 +135,12 @@ def copy_includes(makefile, suffix): os.makedirs(dir) except OSError: pass - copy_if_different = r'$(PERL) $(SRC_D)\util\copy-if-different.pl' with open(makefile) as fin: + copy_if_different = r'$(PERL) $(SRC_D)\util\copy-if-different.pl' for line in fin: if copy_if_different in line: perl, script, src, dest = line.split() - if not '$(INCO_D)' in dest: + if '$(INCO_D)' not in dest: continue # We're in the root of the source tree src = src.replace('$(SRC_D)', '.').strip('"')