Skip to content

Commit 8f720a6

Browse files
committed
Merge remote-tracking branch 'origin/master' into sadhiin/python-linkedlist
Hacktoberfest2024 contribution with updated/solved issue with github action.
2 parents 5634198 + d2430f8 commit 8f720a6

File tree

6 files changed

+238
-12
lines changed

6 files changed

+238
-12
lines changed

.github/workflows/publish-to-test-pypi.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ jobs:
99
steps:
1010
- uses: actions/checkout@master
1111
- name: Set up Python 3.9
12-
uses: actions/setup-python@v1
12+
uses: actions/setup-python@v3
1313
with:
1414
python-version: "3.9"
15+
- name: Update pip
16+
run: python -m pip install --upgrade pip
17+
- name: Install dependencies
18+
run: |
19+
pip install -r requirements.txt
20+
pip install .
1521
- name: Install pypa/build
1622
run: >-
1723
python -m

.github/workflows/run_black_and_isort.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ jobs:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install dependencies
2222
run: |
23+
pip install --upgrade pip
24+
pip install -r requirements.txt
2325
pip install .
2426
pip install black isort
2527
- name: Run black and isort
2628
run: |
2729
python -m black easyPythonpi/*
2830
python -m isort easyPythonpi/*
29-
31+

.github/workflows/run_tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
14+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
1515
os: [ubuntu-latest, macos-latest]
1616
steps:
1717
- uses: actions/checkout@v3
@@ -21,6 +21,8 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies
2323
run: |
24+
pip install --upgrade pip
25+
pip install -r requirements.txt
2426
pip install .
2527
pip install regex
2628
- name: Run tests

.gitignore

Lines changed: 164 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,168 @@
1-
# prevents all pycaches from being added
1+
# prevents all pycaches from being added
22
__pycache__
33
easyPythonpi/__pycache__
44
build
55
dist
6-
easyPythonpi.egg.info
6+
easyPythonpi.egg.info
7+
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
12+
# C extensions
13+
*.so
14+
15+
# Distribution / packaging
16+
.Python
17+
build/
18+
develop-eggs/
19+
dist/
20+
downloads/
21+
eggs/
22+
.eggs/
23+
lib/
24+
lib64/
25+
parts/
26+
sdist/
27+
var/
28+
wheels/
29+
share/python-wheels/
30+
*.egg-info/
31+
.installed.cfg
32+
*.egg
33+
MANIFEST
34+
35+
# PyInstaller
36+
# Usually these files are written by a python script from a template
37+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
38+
*.manifest
39+
*.spec
40+
41+
# Installer logs
42+
pip-log.txt
43+
pip-delete-this-directory.txt
44+
45+
# Unit test / coverage reports
46+
htmlcov/
47+
.tox/
48+
.nox/
49+
.coverage
50+
.coverage.*
51+
.cache
52+
nosetests.xml
53+
coverage.xml
54+
*.cover
55+
*.py,cover
56+
.hypothesis/
57+
.pytest_cache/
58+
cover/
59+
60+
# Translations
61+
*.mo
62+
*.pot
63+
64+
# Django stuff:
65+
*.log
66+
local_settings.py
67+
db.sqlite3
68+
db.sqlite3-journal
69+
70+
# Flask stuff:
71+
instance/
72+
.webassets-cache
73+
74+
# Scrapy stuff:
75+
.scrapy
76+
77+
# Sphinx documentation
78+
docs/_build/
79+
80+
# PyBuilder
81+
.pybuilder/
82+
target/
83+
84+
# Jupyter Notebook
85+
.ipynb_checkpoints
86+
87+
# IPython
88+
profile_default/
89+
ipython_config.py
90+
91+
# pyenv
92+
# For a library or package, you might want to ignore these files since the code is
93+
# intended to run in multiple environments; otherwise, check them in:
94+
# .python-version
95+
96+
# pipenv
97+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
98+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
99+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
100+
# install all needed dependencies.
101+
#Pipfile.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy >= 1.19.5
2+
requests >= 2.25.1

setup.py

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,65 @@
33
import codecs
44
import os
55

6+
try:
7+
import requests
8+
requests_installed = True
9+
except ImportError:
10+
requests_installed = False
11+
612
#VERSION = '0.0.1'
7-
VERSION = (
8-
subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE)
9-
.stdout.decode("utf-8")
10-
.strip()
11-
)
13+
# VERSION = (
14+
# subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE)
15+
# .stdout.decode("utf-8")
16+
# .strip()
17+
# )
18+
19+
def get_pypi_version():
20+
if not requests_installed:
21+
print("Warning: 'requests' module is not installed. Using default version.")
22+
return "0.0.1"
23+
try:
24+
response = requests.get("https://pypi.org/pypi/easyPythonpi/json")
25+
data = response.json()
26+
return str(data["info"]["version"])
27+
except Exception as e:
28+
print(f"Error fetching version from PyPI: {e}")
29+
return "0.0.1"
30+
31+
def increment_version(version):
32+
major, minor, patch = map(int, version.split('.'))
33+
patch += 1
34+
if patch > 9:
35+
patch = 0
36+
minor += 1
37+
if minor > 9:
38+
minor = 0
39+
major += 1
40+
return f"{major}.{minor}.{patch}"
41+
42+
def get_version():
43+
pypi_version = get_pypi_version()
44+
new_version = increment_version(pypi_version)
45+
46+
try:
47+
git_describe = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
48+
git_version = git_describe.stdout.decode("utf-8").strip()
49+
50+
if "-" in git_version:
51+
v, i, s = git_version.split("-")
52+
git_version = f"{new_version}+{i}.git.{s}"
53+
else:
54+
git_version = new_version
55+
except subprocess.CalledProcessError:
56+
git_version = new_version
57+
58+
return git_version
59+
60+
VERSION = get_version()
61+
62+
print("Version: ", VERSION)
1263

13-
if "-" in VERSION:
64+
if VERSION and "-" in VERSION:
1465
# when not on tag, git describe outputs: "1.3.3-22-gdf81228"
1566
# pip has gotten strict with version numbers
1667
# so change it to: "1.3.3+22.git.gdf81228"
@@ -39,7 +90,8 @@
3990
description=DESCRIPTION,
4091
long_description_content_type="text/markdown",
4192
packages=find_packages(),
42-
install_requires=["numpy >= 1.19.5"],
93+
install_requires=["numpy >= 1.19.5"] + (["requests >= 2.25.1"] if not requests_installed else []),
94+
setup_requires=["requests >= 2.25.1"],
4395
keywords=['python', 'sorting', 'beginners', 'sockets'],
4496
classifiers=[
4597
"Development Status :: 1 - Planning",

0 commit comments

Comments
 (0)