Skip to content

Modifications prior to PyPI release#15

Open
vhaasteren wants to merge 1 commit intonanograv:mainfrom
vhaasteren:pypi
Open

Modifications prior to PyPI release#15
vhaasteren wants to merge 1 commit intonanograv:mainfrom
vhaasteren:pypi

Conversation

@vhaasteren
Copy link
Member

PyPI Release

This PR makes QuickCW publish-ready for PyPI

Changes overview

  1. Updated setup.py with metadata, and license consistency

  2. Created requirements.txt with all dependencies

Publishing to PyPI

While I could do the PyPI release myself, it's better if Bence does it so he owns the PyPI release. Therefore, this is a short guide on how to release:

1. Test the Package Build Locally

Before uploading to PyPI, test that the package builds correctly:

# Install build tools
python -m pip install --upgrade build twine

# Build the package
python -m build

# Check the built package for errors
python -m twine check dist/*

This will create distribution files in the dist/ directory and verify they're valid.

2. Add Version Constraints to Dependencies (RECOMMENDED)

Currently, setup.py and requirements.txt list dependencies without version constraints. It's strongly recommended to add minimum version requirements to ensure compatibility. For example:

install_requires=[
    'numpy>=1.19.0',  # or whatever minimum version you've tested with
    'enterprise>=3.0.0',  # check what version is actually needed
    'enterprise_extensions>=3.0.0',
    'numba>=0.50.0',
    'h5py>=2.10.0',
],

Action needed: Determine the minimum versions of each dependency that QuickCW requires and update both setup.py and requirements.txt.

3. Create PyPI Account (if not already done)

4. Create API Token for Upload

  • Go to https://pypi.org/manage/account/
  • Scroll to "API tokens" section
  • Create a new token with scope "Entire account" (or project-specific if preferred)
  • Save the token securely (it starts with pypi-)

5. Upload to PyPI

For Test PyPI (recommended first step):

# Upload to test PyPI first to verify everything works
python -m twine upload --repository testpypi dist/*

# Test installation from test PyPI
python -m pip install --index-url https://test.pypi.org/simple/ QuickCW

For Production PyPI:

# Upload to production PyPI
python -m twine upload dist/*

You'll be prompted for:

  • Username: __token__
  • Password: Your API token (the one starting with pypi-)

6. Verify Installation

After uploading, verify the package can be installed:

# Create a fresh virtual environment
python -m venv test_env
source test_env/bin/activate  # On Windows: test_env\Scripts\activate

# Install from PyPI
pip install QuickCW

# Test that it works
python -c "import QuickCW; print('Success!')"

7. Update Documentation (Optional but Recommended)

  • Update README.md with installation instructions: pip install QuickCW
  • Consider adding a "Installation" section to the documentation
  • Update any installation guides to mention PyPI

8. Create a GitHub Release

After successful PyPI upload:

  • Create a new release on GitHub (e.g., v1.1.0)
  • Tag the release
  • Add release notes

Additional Recommendations

  1. Version Management: Consider using semantic versioning and updating the version in setup.py for each release.

  2. CI/CD: Consider setting up GitHub Actions to automatically build and upload to PyPI on tagged releases.

  3. Documentation: Ensure the README.md renders correctly on PyPI (it should, as it's already in Markdown format).

  4. Testing: Consider adding automated tests that can be run before releases.

Summary Checklist

  • Test package build locally (python -m build)
  • Add version constraints to dependencies (recommended)
  • Create/verify PyPI account
  • Create API token
  • Upload to test PyPI and verify
  • Upload to production PyPI
  • Verify installation from PyPI
  • Create GitHub release
  • Update documentation with PyPI installation instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant