Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish onediff on pypi automatically #560

Merged
merged 26 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/pub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish

on:
push:
branches:
- "pub/*"
schedule:
- cron: "0 1 * * *"

concurrency:
group: onediff-pub-${{ github.ref }}
cancel-in-progress: true

jobs:
publish:
if: github.repository == 'siliconflow/onediff'
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get current date
id: date
run: |
sed -i '1d' "src/onediff/__init__.py"
formatted_date=$(date +'%Y%m%d%H%M')
echo "__version__ = \"0.12.1.dev${formatted_date}\"" >> src/onediff/__init__.py
chengzeyi marked this conversation as resolved.
Show resolved Hide resolved
- run: cat src/onediff/__init__.py
- run: python3 -m pip install build
- run: python3 -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ python3 -m pip install "torch" "transformers==4.27.1" "diffusers[torch]==0.19.3"
```

#### 3. Install OneDiff

- From PyPI
```
python3 -m pip install --pre onediff
```
- From source
```
git clone https://github.com/siliconflow/onediff.git
cd onediff && python3 -m pip install -e .
chengzeyi marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -154,15 +160,20 @@ python3 -m pip install huggingface_hub
- bump version in these files:

```
setup.py
.github/workflows/pub.yml
src/onediff/__init__.py
```

- install build package
```bash
python3 -m pip install build
```

- build wheel

```
```bash
rm -rf dist
python3 setup.py bdist_wheel
python3 -m build
```

- upload to pypi
Expand Down
14 changes: 13 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
from setuptools import find_packages, setup


def get_version():
variables = {}
with open("src/onediff/__init__.py", "r") as f:
for line in f:
if line.startswith("__version__"):
exec(line, variables)
return variables["__version__"]


setup(
name="onediff",
version="0.12.1.dev",
version=get_version(),
description="an out-of-the-box acceleration library for diffusion models",
url="https://github.com/siliconflow/onediff",
author="OneDiff contributors",
Expand Down Expand Up @@ -30,4 +40,6 @@
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
)
2 changes: 1 addition & 1 deletion src/onediff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.12.1.dev"
__version__ = "0.12.1.dev1"
__author__ = "OneDiff"
__credits__ = "OneDiff contributors"
Loading