Skip to content

Commit

Permalink
updated github workflow action to use python3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjeev Kumar committed Dec 8, 2023
1 parent 6423b79 commit d308962
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 170 deletions.
68 changes: 42 additions & 26 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,55 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package git maildiff

on:
release:
types: [published]
on: push

permissions:
contents: read

jobs:
deploy:

build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- uses: actions/checkout@master
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@master
python-version: 3.7

- name: remove old pip
run: sudo apt remove python-pip

- name: wget get-pip.py
run: wget https://bootstrap.pypa.io/get-pip.py

- name: install pip
run: python3 get-pip.py

- name: setuptools version
run: >-
python3 -c
"import setuptools; from setuptools import build_meta; print('Build meta: {}'.format(build_meta)); print(setuptools.__version__)"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python3 -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

32 changes: 17 additions & 15 deletions ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ def _validate_md5(egg_name, data):
if egg_name in md5_data:
digest = md5(data).hexdigest()
if digest != md5_data[egg_name]:
print >>sys.stderr, (
print(
"md5 validation of %s failed! (Possible download problem?)"
% egg_name
% egg_name,
file=sys.stderr
)
sys.exit(2)
return data
Expand Down Expand Up @@ -103,14 +104,14 @@ def do_download():
return do_download()
try:
pkg_resources.require("setuptools>="+version); return
except pkg_resources.VersionConflict, e:
except pkg_resources.VersionConflict as e:
if was_imported:
print >>sys.stderr, (
"The required version of setuptools (>=%s) is not available, and\n"
"can't be installed while this script is running. Please install\n"
" a more recent version first, using 'easy_install -U setuptools'."
"\n\n(Currently using %r)"
) % (version, e.args[0])
print((
"The required version of setuptools (>=%s) is not available, and\n"
"can't be installed while this script is running. Please install\n"
"a more recent version first, using 'easy_install -U setuptools'."
"\n\n(Currently using %r)"
) % (version, e.args[0]), file=sys.stderr)
sys.exit(2)
except pkg_resources.DistributionNotFound:
pass
Expand Down Expand Up @@ -159,7 +160,7 @@ def download_setuptools(
# Read/write all in one block, so we don't create a corrupt file
# if the download is interrupted.
data = _validate_md5(egg_name, src.read())
dst = open(saveto,"wb"); dst.write(data)
dst = open(saveto, "wb"); dst.write(data)
finally:
if src: src.close()
if dst: dst.close()
Expand Down Expand Up @@ -216,13 +217,14 @@ def main(argv, version=DEFAULT_VERSION):
os.unlink(egg)
else:
if setuptools.__version__ == '0.0.1':
print >>sys.stderr, (
msg = (
"You have an obsolete version of setuptools installed. Please\n"
"remove it from your system entirely before rerunning this script."
)
print(msg, file=sys.stderr)
sys.exit(2)

req = "setuptools>="+version
req = "setuptools>=" + version
import pkg_resources
try:
pkg_resources.require(req)
Expand All @@ -238,8 +240,8 @@ def main(argv, version=DEFAULT_VERSION):
from setuptools.command.easy_install import main
main(argv)
else:
print "Setuptools version",version,"or greater has been installed."
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
print("Setuptools version",version,"or greater has been installed.")
print('Run "ez_setup.py -U setuptools" to reinstall or upgrade.')

def update_md5(filenames):
"""Update our built-in md5 registry"""
Expand All @@ -262,7 +264,7 @@ def update_md5(filenames):

match = re.search("\nmd5_data = {\n([^}]+)}", src)
if not match:
print >>sys.stderr, "Internal error!"
print("Internal error!", file=sys.stderr)
sys.exit(2)

src = src[:match.start(1)] + repl + src[match.end(1):]
Expand Down
83 changes: 0 additions & 83 deletions maildiff.egg-info/PKG-INFO

This file was deleted.

16 changes: 0 additions & 16 deletions maildiff.egg-info/SOURCES.txt

This file was deleted.

1 change: 0 additions & 1 deletion maildiff.egg-info/dependency_links.txt

This file was deleted.

3 changes: 0 additions & 3 deletions maildiff.egg-info/entry_points.txt

This file was deleted.

2 changes: 0 additions & 2 deletions maildiff.egg-info/requires.txt

This file was deleted.

2 changes: 0 additions & 2 deletions maildiff.egg-info/top_level.txt

This file was deleted.

3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ all_files = 1
[upload_sphinx]
upload-dir = docs/build/html

[build-system]
requires = ["setuptools>=59.6.0"]
build-backend = "setuptools.build_meta"
30 changes: 8 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
import ez_setup
ez_setup.use_setuptools()
# help on python packaging: http://python-packaging.readthedocs.io/en/latest/index.html
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
import os
from setuptools import setup

from distutils.core import setup
from os import path
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

try: # for pip >= 10
from pip._internal.req import parse_requirements
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements
try:
from pip._internal.download import PipSession
except ImportError:
from pip.download import PipSession
reqs_path = os.path.join(os.path.dirname(__file__), 'requirements.txt')

install_reqs = list(parse_requirements("requirements.txt", session=PipSession()))

with open('requirements.txt', 'r') as reqh:
with open(reqs_path, 'r') as reqh:
install_reqs = reqh.readlines()


v = open(path.join(path.dirname(__file__), 'VERSION'))
v = open(os.path.join(os.path.dirname(__file__), 'VERSION'))
VERSION = v.readline().strip()
v.close()

Expand All @@ -41,6 +26,7 @@
description='Package to email color git diff',
long_description=(open('README.md').read()),
long_description_content_type='text/markdown',
setup_requires=["setuptools>=58.0.4"],
install_requires=install_reqs,
entry_points={
'console_scripts':
Expand Down

0 comments on commit d308962

Please sign in to comment.