Skip to content

Commit e23e154

Browse files
yike5460yanbasic
andauthored
chore: publish to pypi (#30)
* chore: publish to pypi * docs: update the installation url * docs: update the package & entry name * chore: tweak on the version name * chore: tweak on the version name * Update pyproject.toml * Update releaseToPypi.sh * Update releaseToPypi.sh * Update pyproject.toml * Update pyproject.toml * Update releaseToPypi.sh * Update pyproject.toml --------- Co-authored-by: Mike Yan <yanbasic@users.noreply.github.com>
1 parent 9f572b3 commit e23e154

File tree

2 files changed

+77
-8
lines changed

2 files changed

+77
-8
lines changed

pyproject.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "emd"
2+
name = "easy-model-deployer"
33
description = "Easy Model Deployer"
44
version = "0.0.0"
55
authors = [
@@ -8,14 +8,21 @@ authors = [
88
{name="Xuan Zhou",email="<zhouxss@amazon.com>"}
99
]
1010
readme = "README.md"
11-
12-
[tool.poetry]
1311
packages = [
1412
{ include = "**/*", from = "src/emd", to = "emd" },
1513
{ include = "pipeline", from = "src", to = "emd" },
1614
{ include = "s5cmd", from = "assets", to = "emd/pipeline" }
1715
]
1816
exclude = [".venv"]
17+
classifiers = [
18+
"Programming Language :: Python :: 3",
19+
"License :: OSI Approved :: MIT License",
20+
"Operating System :: OS Independent",
21+
]
22+
23+
[build-system]
24+
requires = ["poetry-core"]
25+
build-backend = "poetry.core.masonry.api"
1926

2027
[tool.poetry.dependencies]
2128
python = "^3.9"
@@ -42,10 +49,6 @@ modelscope = "^1.21.1"
4249

4350
[tool.poetry.group.dev.dependencies]
4451
pytest = "^8.0.0"
45-
[build-system]
46-
requires = ["poetry-core"]
47-
build-backend = "poetry.core.masonry.api"
52+
4853
[tool.poetry.scripts]
4954
emd = "emd.cli:app"
50-
[project.scripts]
51-
emd = "emd.cli:app"

releaseToPypi.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Exit on any error
4+
set -e
5+
6+
# Function to increment minor version
7+
increment_version() {
8+
local version=$1
9+
local major=$(echo $version | cut -d. -f1)
10+
local minor=$(echo $version | cut -d. -f2)
11+
local patch=$(echo $version | cut -d. -f3)
12+
13+
# Increment minor version
14+
patch=$((patch + 1))
15+
echo "${major}.${minor}.${patch}"
16+
}
17+
18+
# Check if PYPI_TOKEN environment variable exists
19+
if [ -z "$PYPI_TOKEN" ]; then
20+
echo "Error: PYPI_TOKEN environment variable is not set"
21+
echo "Please set it first:"
22+
echo "export PYPI_TOKEN=your_token_here"
23+
exit 1
24+
fi
25+
26+
# Get current version from pyproject.toml
27+
current_version=$(grep "^version = " pyproject.toml | cut -d'"' -f2)
28+
echo "Current version: $current_version"
29+
30+
# Calculate new version
31+
new_version=$(increment_version $current_version)
32+
echo "New version: $new_version"
33+
34+
# Update version in pyproject.toml
35+
sed -i.bak "s/^version = \"${current_version}\"/version = \"${new_version}\"/" pyproject.toml
36+
rm pyproject.toml.bak
37+
38+
# Clean up old builds
39+
echo "Cleaning up old builds..."
40+
rm -rf dist/ build/ *.egg-info/
41+
42+
# Configure Poetry with PyPI token
43+
echo "Configuring Poetry with PyPI token..."
44+
poetry config pypi-token.pypi "${PYPI_TOKEN}"
45+
46+
# Build the package
47+
echo "Building package..."
48+
poetry build
49+
50+
# List built files
51+
echo "Built files:"
52+
ls -l dist/
53+
54+
# Publish to PyPI
55+
echo "Publishing to PyPI..."
56+
poetry publish
57+
58+
echo "Successfully published version ${new_version} to PyPI!"
59+
60+
# Waitting 30 seconds for verification
61+
echo "Verifying installation..."
62+
sleep 30
63+
pip install --no-cache-dir easy-model-deployer==${new_version}
64+
65+
echo "Done! Try running: emd --help"
66+
echo "Note to push the latest version in pyproject.toml as ${new_version}, please update it manually."

0 commit comments

Comments
 (0)