is_click_predictor / upload_package.py
chkp-talexm
update
4c6a68b
import os
import subprocess
import sys
def run_command(command):
"""Run a shell command and check for errors."""
result = subprocess.run(command, shell=True, check=True, text=True)
return result
def main():
print("πŸš€ Starting the PIP package build & upload process...\n")
# Step 1: Ensure dependencies are installed
print("βœ… Installing required dependencies (setuptools, wheel, twine)...")
run_command(f"{sys.executable} -m pip install --upgrade setuptools wheel twine")
# Step 2: Remove old build directories if they exist
print("πŸ—‘οΈ Removing old `dist/`, `build/`, and `*.egg-info` files...")
run_command("rm -rf dist build *.egg-info")
# Step 3: Build the package
print("πŸ“¦ Building the package...")
run_command(f"{sys.executable} setup.py sdist bdist_wheel")
# Step 4: Upload the package to PyPI (or TestPyPI)
upload_option = input("Upload to (1) PyPI or (2) TestPyPI? [1/2]: ").strip()
if upload_option == "2":
print("πŸš€ Uploading package to TestPyPI...")
run_command("twine upload --repository testpypi dist/*")
print("βœ… Package uploaded to TestPyPI!")
else:
print("πŸš€ Uploading package to PyPI...")
run_command("twine upload dist/*")
print("βœ… Package uploaded to PyPI!")
print("\nπŸŽ‰ Done! Your package is now available online.")
if __name__ == "__main__":
try:
main()
except subprocess.CalledProcessError as e:
print(f"\n❌ Error: {e}")
print("⚠️ Make sure you are logged in with `twine` before uploading.")