trevi-software / trevi-misc

Miscellaneous public Odoo addons not in any other repository.
GNU Affero General Public License v3.0
4 stars 13 forks source link

Publish modules in PyPi.org #40

Open oyale opened 1 year ago

oyale commented 1 year ago

Hi!

I just wanted to ask you if you would consider publishing the modules from this repository on pypi.org. I've looked for it, but haven't found anything. As I'm sure you know, PyPI is a central repository for Python packages, and it's the standard way we - at @coopdevs - install modules for Odoo deployments. (Specifically, we use this Ansible role)

We have found some modules in this repository to be really nice, and we thought it would be even easier for others to use and benefit from them if they were published in PyPI. In addition, it would increase the visibility of your project within the Python community.

If you need help with the publishing process, don't hesitate to let us know. We will be happy to assist you in any way we can. Just in case, here are our internal docs on how to publish Odoo modules in PyPI.

Thank you very much for all the work and effort you have shared here. They are very much appreciated.

Best regards, Pelayo.

mtelahun commented 1 year ago

Thanks for the suggestion. I would love to publish them to pypi, but I haven't had the incentive to figure out how to do it. I will look at the documents you've pointed to and I'll let you know how it goes (or if I need help).

Thanks.

On 05/01/2023 19:00, Pelayo García wrote:

Hi!

I just wanted to ask you if you would consider publishing the modules from this repository on pypi.org. I've looked for it, but haven't found anything. As I'm sure you know, PyPI is a central repository for Python packages, and it's the standard way we - at @coopdevs https://github.com/coopdevs/ - install modules for Odoo deployments. (Specifically, we use this Ansible role https://github.com/coopdevs/odoo-role)

We have found some modules in this repository to be really nice, and we thought it would be even easier for others to use and benefit from them if they were published in PyPI. In addition, it would increase the visibility of your project within the Python community.

If you need help with the publishing process, don't hesitate to let us know. We will be happy to assist you in any way we can. Just in case, here are our internal docs on how to publish Odoo modules in PyPI https://handbook.coopdevs.org/ca/Odoo/Sysadmin/Packaging-Odoo-Addons.

Thank you very much for all the work and effort you have shared here. They are very much appreciated.

Best regards, Pelayo.

— Reply to this email directly, view it on GitHub https://github.com/trevi-software/trevi-misc/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4YOHEWA2AF3TNHYINFGMDWQ3V27ANCNFSM6AAAAAATSDOZ4U. You are receiving this because you are subscribed to this thread.Message ID: @.***>

oyale commented 1 year ago

Probably, the most tedious part is to create the account on pypi.org (and test.pypi.org/). Otherwise, I'd say it's pretty much straightforward.

I leave below the specific instructions.

Install tools

You can create and activate a venv:

python -m venv venv
source venv/bin/activate

And install the tools

pip install twine wheel setuptools-odoo

Prepare a new repo for pypi

Assuming no previous work on pypi has been done, we need to check for the file structure. Odoo community has its own standards. It can be a single repo module, or more frequently, a multi-module repo. In any case, we will need a certain folder structure and a __manifest__.py for each addon.

Some manifest data that caused problem in the past

Execute

Place yourself at the root of the repo:

ls .
addon1/
addon2/

And then run

setuptools-odoo-make-default -d .

Expected results:

A new setup/ folder with this structure:

...
setup/addon1/odoo/addons/<addon1_name> -> ../../../../<addon1_name>
setup/addon2/setup.py
...

This must be only once if no addons are added. Removed addons should remove too their setup/ symlinks.

Commit the changes in setup/ directory

Since setuptools-odoo relies on what's committed to your Git repository, you need to commit the changes occurred in the setup/ directory before executing the next steps.

If you don't do that, setuptools will create an empty build/ directory and your package will be broken and not recognized by Odoo. More details here.

Build wheel

This is the first half of cyclical packaging process. For each addon, do:

cd setup/addon_name
python setup.py bdist_wheel --universal sdist
cd ../..

Checks

You can inspect the generated dir setup/addon_name/odooXX_addon_addon_name.egg-info/:

This whole process is git-dependand. Both versions and sources depend on git: version to decide the devXX number, and sources to ignore untracked files.

For any doubt of what's inside, you can unzip the whl file in dist/ to see what's in.

Upload to pypi

If you are testing, you can use the test pypi instance just by inserting --repository-url https://test.pypi.org/legacy/ to the next command, just after upload:

Otherwise, just do for each addon to upload:

cd setup/addon_name
twine upload dist/*
# fill in credentials
# wait for the upload
cd ../..