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

Merged
merged 2 commits into from
Aug 3, 2025

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

@LC-Linkous LC-Linkous self-assigned this Aug 3, 2025
@LC-Linkous LC-Linkous changed the base branch from main to dev August 3, 2025 16:54
@LC-Linkous
Copy link
Owner

Updated the pull request to merge into a new 'dev' branch. I'm going to go ahead and merge this so I can make edits when connecting to PyPi and keep everything transparent (also so gemerson-g is getting credit for work done. thank you!).

I'm going to swap out the package name in this PR to respect the trademark (not a big deal on this end), and finish up some edits to function calls. To simplify a first launch, I'm going to remove the device configs classes, and have some hard coded limits for error checking (e.g., no device goes up to 24 GHz, which might be an oops when trying to target 2.4 GHz and adding an extra 0). Documentation also needs an update in the README + prep for the PyPi page

@LC-Linkous LC-Linkous merged commit d4a7143 into LC-Linkous:dev Aug 3, 2025
@gemerson-g
Copy link
Author

@LC-Linkous if you need any help, just ping me 👍

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