Skip to content

Initial packaging setup for PyPI with uv and pyproject.toml #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gemerson-g
Copy link

@gemerson-g gemerson-g commented Aug 1, 2025

This PR prepares the repository for use as a proper Python package installable via PyPI. It includes the following core changes:

Key Changes

  • Introduced pyproject.toml using uv as the project manager.
  • Dependencies and optional dependency groups are now defined in via pyproject.toml.
  • The build system is configured to include packages from the tinysa folder, which is now the main source package.
  • Removed older unstructured files (e.g., src/device_config/…, tinySA_python.py) in favor of a more structured layout.

PyPI Publishing Notes (@LC-Linkous)

To publish this to PyPI, you'll need to:

  1. Have a PyPI account.
  2. Ensure the project name is unique.
  3. Update the [project] section in pyproject.toml with the final name, author details, and version number.
  4. To publish:
    uv publish --token <your-pypi-token>

Suggestions for Improvement

  • Improve naming consistency across the codebase to reduce confusion and avoid unnecessary aliasing:
    • Example: Instead of:
      from tinysa.device_config.presets import config_tinysa_basic as tinyBasic

      Use consistent and simplified naming like:
      import tinybasic

    • Suggested file/module names:

      • tinybasic
      • tinyuzs405
      • tinyupzs406
      • tinyupzs407

Refactor model selection logic

Currently, the selection of device presets uses repeated if/elif statements and print statements:

if model == "BASIC":
    self.presetSelected = tinyBasic
elif model == "ZS405":
    self.presetSelected = tinyUZS405
# ...
else:
    self.presetSelected = None
    self.deviceModel = None
    print("ERROR: selected preset not in library")
    return False

self.deviceModel = model
print("Device set successfully")
return True

use a dictionary for mapping + logging for better structure and control:

 import logging

# Setup a logger for this module/class
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

# Mapping model names to preset objects
PRESET_MODELS = {
    "BASIC": tinyBasic,
    "ZS405": tinyUZS405,
    "ZS406": tinyUPZS406,
    "ZS407": tinyUPZS407,
}

self.presetSelected = PRESET_MODELS.get(model)

if not self.presetSelected:
    logger.error("Selected preset '%s' not found in library.", model)
    self.deviceModel = None
    return False

self.deviceModel = model
logger.info("Device model '%s' set successfully.", model)
return True

@LC-Linkous
Copy link
Owner

I'm going to take a look at this over the weekend.

re:

I’ve reached out to the current owner of tinysa to explore the possibility of releasing the name.

I appreciate the initiative, but I am not in any way affiliated with the tinySA brand, which is a registered trademark. Please do not reach out on my behalf (or the repo's behalf) to procure or setup related to the tinySA name or branding.

@gemerson-g
Copy link
Author

My bad. I checked now on @dead-guru repo and you are correct: https://github.com/dead-guru/tinySA?tab=readme-ov-file#note

I will retract my email with the other repo owner.

@LC-Linkous
Copy link
Owner

For anyone else that might stumble on this chain, the main reference for this product is at: https://www.tinysa.org/wiki/

I use it in my work, which is why I have so many disclaimers in my own documentation about the library being unofficial + linking back to the official documentation when possible.

@gemerson-g are you also GeGerardo, or are you working together? GeGerardo opened the issue, and both accounts have forks, but you're the one with the PR. This is not a problem, but I want to make sure I'm not watching for 2 PRs on the same topic.

@gemerson-g
Copy link
Author

Thanks for the clarification. Yes, I am the owner of both accounts. I decided to use this account because the global credentials were already set up on all my distros, and I was just a bit too lazy to change XD

@LC-Linkous
Copy link
Owner

Cool, then that's easy. I'll circle back in a couple days

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.

2 participants