Skip to content

Commit 3f4ff29

Browse files
authored
Merge pull request #10 from kozistr/feature/pip
[Feature] Setup workflow
2 parents 101ea53 + ebd2748 commit 3f4ff29

File tree

9 files changed

+761
-8
lines changed

9 files changed

+761
-8
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.7', '3.8']
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install dependencies
23+
run: |
24+
make init
25+
make requirements
26+
pip install -r requirements-dev.txt
27+
- name: Lint
28+
run: |
29+
make format
30+
make build
31+
deploy:
32+
name: Deploy
33+
needs: test
34+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Setup Python 3.8
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: 3.8
41+
- name: Upload PyPI
42+
env:
43+
TWINE_USERNAME: __token__
44+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
45+
run: |
46+
python -m pip install -U twine wheel
47+
python setup.py sdist bdist_wheel
48+
twine check dist/*
49+
twine upload dist/*

Makefile

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1-
.PHONY: init check format requirements
1+
.PHONY: init check format requirements build clean
22

33
init:
4-
python3 -m pip install -U pipenv setuptools
4+
python3 -m pip install -U pipenv setuptools wheel
55
python3 -m pipenv install --dev
66

77
check:
8-
isort --check-only --profile black pytorch_optimizer -l 79
9-
black -S -l 79 --check pytorch_optimizer
8+
isort --check-only --profile black -l 79 pytorch_optimizer setup.py
9+
black -S -l 79 --check pytorch_optimizer setup.py
1010
pylint pytorch_optimizer
1111

12+
build:
13+
python3 setup.py sdist bdist_wheel
14+
twine check dist/*
15+
16+
clean:
17+
rm -rf `find . -name __pycache__`
18+
rm -f `find . -type f -name '*.py[co]' `
19+
rm -f `find . -type f -name '*~' `
20+
rm -f `find . -type f -name '.*~' `
21+
rm -f `find . -type f -name '@*' `
22+
rm -f `find . -type f -name '#*#' `
23+
rm -f `find . -type f -name '*.orig' `
24+
rm -f `find . -type f -name '*.rej' `
25+
rm -rf build
26+
rm -rf dist
27+
1228
format:
13-
isort --profile black pytorch_optimizer -l 79
14-
black -S -l 79 pytorch_optimizer
29+
isort --profile black -l 79 pytorch_optimizer setup.py
30+
black -S -l 79 pytorch_optimizer setup.py
1531

1632
requirements:
1733
python3 -m pipenv lock -r > requirements.txt

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ verify_ssl = false
77
isort = "==5.9.3"
88
black = "==21.9b0"
99
pylint = "==2.11.1"
10+
twine = "==3.4.2"
1011

1112
[packages]
1213
numpy = "==1.21.2"
14+
torch = "==1.9.0"
1315

1416
[requires]
1517
python_version = "3"

Pipfile.lock

Lines changed: 532 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# pytorch_optimizer
1+
# pytorch-optimizer
22

3-
Bunch of optimizer implementations in PyTorch with clean-code, strict types.
3+
Bunch of optimizer implementations in PyTorch with clean-code, strict types. Inspired by [pytorch-optimizer](https://github.com/jettify/pytorch-optimizer).
44

55
## Usage
66

pytorch_optimizer/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__VERSION__ = '0.0.1'

requirements-dev.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# These requirements were autogenerated by pipenv
3+
# To regenerate from the project's Pipfile, run:
4+
#
5+
# pipenv lock --requirements --dev
6+
#
7+
8+
# Note: in pipenv 2020.x, "--dev" changed to emit both default and development
9+
# requirements. To emit only development requirements, pass "--dev-only".
10+
11+
-i https://pypi.org/simple
12+
--trusted-host pypi.org
13+
astroid==2.8.0; python_version ~= '3.6'
14+
black==21.9b0
15+
bleach==4.1.0; python_version >= '3.6'
16+
certifi==2021.5.30
17+
cffi==1.14.6
18+
charset-normalizer==2.0.6; python_version >= '3'
19+
click==8.0.1; python_version >= '3.6'
20+
colorama==0.4.4; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
21+
cryptography==3.4.8; python_version >= '3.6'
22+
docutils==0.17.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
23+
idna==3.2; python_version >= '3'
24+
importlib-metadata==4.8.1; python_version >= '3.6'
25+
isort==5.9.3
26+
jeepney==0.7.1; sys_platform == 'linux'
27+
keyring==23.2.1; python_version >= '3.6'
28+
lazy-object-proxy==1.6.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
29+
mccabe==0.6.1
30+
mypy-extensions==0.4.3
31+
numpy==1.21.2
32+
packaging==21.0; python_version >= '3.6'
33+
pathspec==0.9.0
34+
pkginfo==1.7.1
35+
platformdirs==2.3.0; python_version >= '3.6'
36+
pycparser==2.20; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
37+
pygments==2.10.0; python_version >= '3.5'
38+
pylint==2.11.1
39+
pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
40+
readme-renderer==29.0
41+
regex==2021.8.28
42+
requests-toolbelt==0.9.1
43+
requests==2.26.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
44+
rfc3986==1.5.0
45+
secretstorage==3.3.1; sys_platform == 'linux'
46+
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
47+
toml==0.10.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
48+
tomli==1.2.1; python_version >= '3.6'
49+
torch==1.9.0
50+
tqdm==4.62.3; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
51+
twine==3.4.2
52+
typing-extensions==3.10.0.2
53+
urllib3==1.26.6; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
54+
webencodings==0.5.1
55+
wrapt==1.12.1
56+
zipp==3.5.0; python_version >= '3.6'

requirements.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# These requirements were autogenerated by pipenv
3+
# To regenerate from the project's Pipfile, run:
4+
#
5+
# pipenv lock --requirements
6+
#
7+
8+
-i https://pypi.org/simple
9+
--trusted-host pypi.org
10+
numpy==1.21.2
11+
torch==1.9.0
12+
typing-extensions==3.10.0.2

setup.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import os
2+
import re
3+
from typing import Dict, List
4+
5+
from setuptools import find_packages, setup
6+
7+
8+
def read_file(filename: str) -> str:
9+
with open(os.path.join(os.path.dirname(__file__), filename)) as f:
10+
return f.read().strip()
11+
12+
13+
def read_version() -> str:
14+
regexp = re.compile(r"^__VERSION__\W*=\W*'([\d.abrc]+)'")
15+
16+
with open(
17+
os.path.join(
18+
os.path.dirname(__file__), 'pytorch_optimizer', '__init__.py'
19+
)
20+
) as f:
21+
for line in f:
22+
match = regexp.match(line)
23+
if match is not None:
24+
return match.group(1)
25+
26+
raise RuntimeError('Cannot find version in pytorch_optimizer/__init__.py')
27+
28+
29+
INSTALL_REQUIRES: List[str] = ['torch>=1.5.0']
30+
31+
32+
CLASSIFIERS: List[str] = [
33+
'License :: OSI Approved :: Apache Software License',
34+
'Intended Audience :: Developers',
35+
'Intended Audience :: Science/Research',
36+
'Programming Language :: Python :: 3',
37+
'Programming Language :: Python :: 3.6',
38+
'Programming Language :: Python :: 3.7',
39+
'Programming Language :: Python :: 3.8',
40+
'Operating System :: OS Independent',
41+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
42+
]
43+
44+
KEYWORDS: List[str] = sorted(
45+
[
46+
'pytorch-optimizer',
47+
'pytorch',
48+
'adamp',
49+
'sgdp',
50+
'ranger',
51+
'ranger21',
52+
'agc',
53+
'gc',
54+
'chebyshev_schedule',
55+
'lookahead',
56+
'radam',
57+
]
58+
)
59+
60+
PROJECT_URLS: Dict[str, str] = {
61+
'Website': 'https://github.com/kozistr/pytorch_optimizer',
62+
'Issues': 'https://github.com/kozistr/pytorch_optimizer/issues',
63+
}
64+
65+
setup(
66+
name='pytorch-optimizer',
67+
version=read_version(),
68+
description='pytorch-optimizer',
69+
long_description=read_file('README.md'),
70+
long_description_content_type='text/markdown',
71+
classifiers=CLASSIFIERS,
72+
platforms=['Linux', 'Windows'],
73+
author='kozistr',
74+
author_email='[email protected]',
75+
url='https://github.com/kozistr/pytorch_optimizer',
76+
download_url='https://pypi.org/project/pytorch-optimizer/',
77+
license='Apache 2',
78+
packages=find_packages(),
79+
install_requires=INSTALL_REQUIRES,
80+
keywords=KEYWORDS,
81+
zip_safe=True,
82+
include_package_data=True,
83+
project_urls=PROJECT_URLS,
84+
python_requires='>=3.6.0',
85+
)

0 commit comments

Comments
 (0)