loot / libloot-python

A Python module that wraps libloot.
GNU General Public License v3.0
6 stars 1 forks source link

Create a pip-installable python package #11

Closed GandaG closed 4 years ago

GandaG commented 4 years ago

Having the releases be installed directly with pip would be infinitely more useful (not to mention easier). This can be achieved by placing setup.py and loot_api_fake in the archived folder.

Building the package into a wheel is unfortunately not an option since we need setup.py to auto-install msvc if needed.

Last thing, it must be a .zip file and not .7z since pip can't read those.

Will definitely need help with this since I have almost no experience with c++ and certainly none with cmake.

Ortham commented 4 years ago

This sounds like a good idea, I've got no idea about what's involved, but I guess we can figure it out between us.

GandaG commented 4 years ago

This would be the goal for the final archive structure:

loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.zip
└── loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32
    ├── loot_api_fake
    |   └── __init__.py
    ├── loot.dll
    ├── loot_api.pyd
    ├── loot_api_python.pdb
    ├── README.md
    └── setup.py

And I forgot to mention before, but maybe you'll want to update the version number on setup.py (line 69), which shouldn't be too hard.

I could give it a shot and learn cmake, but you'll have to eli5 the project setup, no idea what a "solution" is :/

Ortham commented 4 years ago

@GandaG I found a template for integrating setup.py with CMake, so I'm going to close this PR and open another one that builds off that template.

Ortham commented 4 years ago

@GandaG Do these archives work as you expect? I made a few more changes on top of yours in e7944efd29dae06762646df182a736846ca7a210.

GandaG commented 4 years ago

I thought .tar.xz would be fine but

Seems pip really wants zip files.

Doesn't seem like the version is being updated from CMake - although that is not required it would be helpful.

Otherwise works great!

Ortham commented 4 years ago

What version of pip are you using? pip 19.3.1 on Python 3.7 (x64) accepted tar.xz archives for me.

GandaG commented 4 years ago

It fails on that version on both py3 and 2 so it must be me using the wrong download links. What url did you use?

Ortham commented 4 years ago

I was testing locally, now that I try it I see the same as you when I give pip a Bintray link...

GandaG commented 4 years ago

Locally py3 installs just fine while py2...

... I hate python 2.

Ortham commented 4 years ago

OK, I've updated the CMake config to write the version number in setup.py, and switched to packing zip files, since it looks like that's the only real option. Can you check that these links work for you?

GandaG commented 4 years ago

Can you check that these links work for you?

Everything seems to be working now, thanks for the help!

Ortham commented 4 years ago

OK, I want to tweak the version a bit to add the git commit hash like in the archive filename, I'll do that tonight then merge that branch and close this PR.

Ortham commented 4 years ago

After reading up on how pip handles version metadata, I've decided not to include the commit hash in the version and have merged our combined changes in ffd62f9e0c7a9bf6c353d998395362aea52d3097, so I'm closing this. Thanks!