Skip to content

Commit 8f00958

Browse files
authored
Merge pull request #3 from ByteInternet/add-setup-py
add setup.py for PyPI
2 parents 1ec72c9 + a17b9ee commit 8f00958

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

.github/workflows/publish.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Set up Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: '3.x'
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install build
20+
- name: Build package
21+
run: python setup.py sdist
22+
- name: Publish package
23+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
24+
with:
25+
user: __token__
26+
password: ${{ secrets.PYPI_API_TOKEN }}

setup.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
#!/usr/bin/env python
2-
from setuptools import setup
3-
from os.path import abspath, dirname, join
2+
import os
3+
from pathlib import Path
44

5+
from setuptools import find_packages, setup
56

6-
def readfile(filename):
7-
path = join(dirname(abspath(__file__)), filename)
8-
with open(path, "rt") as filehandle:
9-
return filehandle.read()
7+
# allow setup.py to be run from any path
8+
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
9+
10+
11+
this_directory = Path(__file__).parent
12+
long_description = (this_directory / "README.md").read_text()
13+
requirements = """
14+
pip
15+
requests
16+
"""
1017

1118

1219
setup(
1320
name="hypernode_api_python",
1421
version="0.0.1",
1522
description='"Hypernode API Client for Python"',
16-
long_description=readfile("README.md"),
17-
long_description_content_type="text/markdown",
18-
author="Hypernode",
23+
url="https://github.com/ByteInternet/hypernode_api_python",
24+
packages=find_packages(
25+
include=["hypernode_api_python", "requirements/base.txt"], exclude=["tests"]
26+
),
27+
author="Hypernode Team",
1928
author_email="[email protected]",
29+
install_requires=requirements.split("\n"),
30+
python_requires=">=3.7",
31+
long_description=long_description,
32+
long_description_content_type="text/markdown",
2033
license="MIT",
21-
url="https://github.com/ByteInternet/hypernode_api_python",
22-
packages=["hypernode_api_python"],
23-
install_requires=["pip"],
24-
entry_points={"console_scripts": []},
2534
)

0 commit comments

Comments
 (0)