Skip to content
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

Packaging and distribution #349

Open
5 tasks
nocalla opened this issue May 11, 2020 · 7 comments
Open
5 tasks

Packaging and distribution #349

nocalla opened this issue May 11, 2020 · 7 comments
Labels
distribution meta packaging project automation Make the robots do the heavy lifting
Projects

Comments

@nocalla
Copy link
Member

nocalla commented May 11, 2020

Is your feature request related to a problem? Please describe.

As per #176 , ideally we could install our package by running pip install bank2ynab, but this requires proper packaging.

Describe the solution you'd like

  • Creation of a simple installation package using setup.py
  • Inclusion of correct package details in setup.py/MANIFEST.in
  • Testing package upload to PyPi
  • Actual creation of entry on PyPi
  • Automation of the publishing process using Github Actions

Additional context
Work in progress branch: https://github.com/bank2ynab/bank2ynab/tree/feature/349_Packaging_and_distribution

@nocalla nocalla added this to Candidates in 1.2.0 via automation May 11, 2020
@nocalla nocalla moved this from Candidates to In progress in 1.2.0 May 11, 2020
@nocalla nocalla added distribution meta packaging project automation Make the robots do the heavy lifting labels May 11, 2020
@chamini2
Copy link

chamini2 commented May 4, 2022

Hey, this seems very important to me, making users download a zip file is not ideal IMHO. Would you accept contributions to do this?

@nocalla
Copy link
Member Author

nocalla commented May 4, 2022

Yes please, this is totally beyond my expertise! Even a roadmap of what steps to take would be great.

@ExalDraen
Copy link
Contributor

How about using a something like nuitka (https://github.com/Nuitka/Nuitka) to package the whole application into a (OS-specific) executable, and then offer that for download?

That would be a lot simpler / easier for users, I would think

@nocalla
Copy link
Member Author

nocalla commented May 4, 2023

@ExalDraen that would be good if we can then offer the executable via Github. I haven't packaged before, so no idea on how to go about doing it!

@limdingwen
Copy link
Contributor

limdingwen commented Apr 29, 2024

I was working on this because it seems like this is blocking #457. I keep running into import errors whenever I try to use this as a package.

To recap what I've experimented with for the past month:

  • Using Pyodide to run it in a web app
  • Using PyInstaller to convert bank2ynab to an executable, then running it in an Electron app
  • Adding it as a git submodule, then importing it, as a Python GUI app

Every single time, I come up against this dreaded error:

  File "[SNIP]/bank2ynab/__main__.py", line 5, in <module>
    from bank_handler import BankHandler
ModuleNotFoundError: No module named 'bank_handler'

So I decided to upload it onto PyPI first; maybe that will provide some sort of standardisation so I don't keep running into import errors.

Uploading worked! I turned it into an executable, too, and fixed the dependencies issue in setup.py. But when I ran it...

  File "[SNIP]/bank2ynab/__main__.py", line 5, in <module>
    from bank_handler import BankHandler
ModuleNotFoundError: No module named 'bank_handler'

😢

I believe python ./bank2ynab is masking an issue with the code; right now, it's using absolute imports. But that should be import bank2ynab.bank_handler, shouldn't it? The alternative would be relative imports, like from . import bank_handler.

I decided to go with relative imports.

bank2ynab % pipx run --index-url https://test.pypi.org/simple/  --pip-args="--extra-index-url https://pypi.org/simple/" bank2ynab-limdingwen==1.2.2
NOTE: running app 'bank2ynab' from 'bank2ynab-limdingwen'
ERROR: Configuration file not found: /Users/[REDACTED]/Library/Caches/pipx/2b8957e5005ced9/lib/python3.12/site-packages/bank2ynab.conf
ERROR: No configuration file found, process aborted.

Close enough. It works!

Oh, and you need to use python -m bank2ynab to run it.

I'll put up a PR, specifically for the relative imports and the packaging-specific changes. This is important since it'll make it easier for my GUI app -- whether that be PWA or a desktop GUI, I'm not sure yet -- to keep up with the updates, since I don't need to keep changing it to relative imports. I think this should be enough for Pyodide (for PWA), or just plain Python importing (if I'm going with a Python GUI) to work properly...

Still needs fixing:

  • Configuration file issue when using pipx (unknown if it works when manually installed)
  • CI automation

@nocalla
Copy link
Member Author

nocalla commented Apr 30, 2024

That's pretty cool, thanks for reasoning this out! I know we had some import-related issues a while back with certain configurations, so maybe that explains it.

Oh, and you need to use python -m bank2ynab to run it.

Clicking the play button in VS Code no longer works! A sad day, but a small sacrifice.

@limdingwen
Copy link
Contributor

Clicking the play button in VS Code no longer works! A sad day, but a small sacrifice.

😆 Well, one could always use tasks.json!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distribution meta packaging project automation Make the robots do the heavy lifting
Projects
1.2.0
  
In progress
Development

Successfully merging a pull request may close this issue.

4 participants