metalpoetza

pyKAN - Pure python CKAN client

Recommended Posts

pyKAN

PyKAN is a pure python alternative client for the CKAN utility to manage modules for Kerbal Space Program. It uses the original upstream CKAN data and repos directly and does not fragment the module repositories, it merely provides an alternate client to consume this data to manage, install and update modules.

All the logic is kept in libraries - so that writing a new interface is easy.

Version 0.1.0  First public stable release

Available on github:

Source

Version 0.1.0

Installation:

  1. Clone or Download the repository.
  2. Change to the directory where you downloaded
  3. Make sure you have python-requests and python-appdirs installed. The program will tell you if it cannot find these modules.
  4. ./pyKAN --help
  5. python pyKAN --help #On windows

Current features:

  1. Global settings holding list of known KSP installation directories
  2. Per KSPDir settings on top of that
  3. Fetch repository data from CKAN
  4. Ability to install incompatible mods. Settings contain minKSPversion and maxKSPversion per install. By default these are set to the KSP version. User can override to, for example, allow mods that are maxed at 1.0.0 to install in 1.1.0.
  5. List available modules. Module listing comes with numerous optional filters which can be combined in arbitrary combinations. Includes text-search, module version and KSP version compatibility. The same filters will be available for selecting mods to install.
  6. Detect manually installed mods
  7. Import list of modules installed by CKAN
  8. List installed modules, indicating how they were installed.
  9. Install modules (optional override support for manual mods) with optional download-retries
  10. Uninstall modules
  11. Upgrade modules
  12. Python3 - in master branch only.

Changes

0.1.2

  1. Multiple small bugfixes
  2. New commandline syntax with cleaner format and support for multiple modules in a single command.

0.1.0

  1. The installed modules listing is now also sorted alphabetically.
  2. Fixed a bug where calling upgrade would reinstall the same version as was there before
  3. Disabled strict mode JSON to deal with the bad json in .version files.
  4. Handling of 'file' mode install sections now work correctly.
  5. Fixed install destination for mods like firespittercore
  6. Use appdirs module to place main configuration file in a platform neutral manner

0.0.1-beta2

  1. Python3 support
  2. Lots of small bugfixes
  3. Improved mod installer, mod upgrades and mod uninstalls
  4. List_module now sorts alphabetically

0.0.1-beta1

  1. Initial public release

Todo:

  1. PyQT GUI for graphical usage
  2. Manual install by link. User can copy a download link and have the app download and install from within. User could add/edit mod information.
  3. Optimize the O(N) and O(n*x) algorithms.
  4. Improve the argument code for the commandline version. Some of it is a bit cumbersome.
  5. Import of CKAN installed list should also import filelist. Done
  6. Consider using a Linter for your source (I'd recommend flake8)
  7. Consider using the logging module rather than a DEBUG flag
  8. Consider documenting at all levels (package, module, class, function) using a known doc style (Plain, Epytext, restructuredText, Numpy, Google, etc.)
  9. [very optional] Consider using type hints (a.k.a PEP 484) or even the typing module (see also PEP 526) if you switch to python3.

Written By

  1. A.J. Venter (metalpoetza on reddit).
  2. SYZYGY - Python3 support
Edited by metalpoetza
New release

Share this post


Link to post
Share on other sites

I’m not a CKAN user, and I run mainly Python 3.4 these days, but that surely looks interesting and like a labor of love. Very impressive!

Share this post


Link to post
Share on other sites

This sounds like CKAN... without all the things that annoy me about the CKAN client. :D.

 

Share this post


Link to post
Share on other sites
1 hour ago, steve_v said:

This sounds like CKAN... without all the things that annoy me about the CKAN client. :D.

 

I guess we were annoyed by the same things :P

Share this post


Link to post
Share on other sites
52 minutes ago, bananashavings said:

I'd love to try this out, but I'm on python 3. Any idea when you will make it compatible?

The current beta is already compatible. 

Share this post


Link to post
Share on other sites

Should we include instructions for people using that clunky conventional CP/M derived Operating System from Microsoft?  :D

Share this post


Link to post
Share on other sites
Just now, Ruedii said:

Should we include instructions for people using that clunky conventional CP/M derived Operating System from Microsoft?  :D

Heh - probably, but since I'm not one of them and don't have any copies I can't even test it on that thing. I was rather hoping somebody would volunteer to maintain an exe-packaged version for them.

Share this post


Link to post
Share on other sites

I believe MinGW32 can build nice exe prepackaged, and I know you can test it on wine.
If you package the exe as an ironpython program, it will run from mono.  (Good choice here.)

Share this post


Link to post
Share on other sites
24 minutes ago, Ruedii said:

I believe MinGW32 can build nice exe prepackaged, and I know you can test it on wine.
If you package the exe as an ironpython program, it will run from mono.  (Good choice here.)

There are other tools which can do so as well, and package in the module deps and such - but I'd be nervous about shipping something I only tested in wine. I really would rather that somebody else volunteer. 

I'm not sold on the mono thing - part of the whole idea of pyKAN is to remove the mono dependency which CKAN enforces.

Share this post


Link to post
Share on other sites
1 hour ago, metalpoetza said:

There are other tools which can do so as well, and package in the module deps and such - but I'd be nervous about shipping something I only tested in wine. I really would rather that somebody else volunteer. 

I'm not sold on the mono thing - part of the whole idea of pyKAN is to remove the mono dependency which CKAN enforces.

Well, the point of the mono build is that it runs under .net  Hence you can have both a mono and a pure python build.

Share this post


Link to post
Share on other sites

I'm not super familiar with python, and I cannot get it to work properly. What I have done so far is download the beta, locate to the folder and open a command prompt there and use the commands, it just says "NameError: name 'pyKAN' is not defined". Sorry if its a super obvious fix :P

Share this post


Link to post
Share on other sites
2 hours ago, bananashavings said:

I'm not super familiar with python, and I cannot get it to work properly. What I have done so far is download the beta, locate to the folder and open a command prompt there and use the commands, it just says "NameError: name 'pyKAN' is not defined". Sorry if its a super obvious fix :P

That's odd, I've never seen that happening. What OS are you on ? Are you sure you got beta-2c ? Any other information you can give me to help me work out why this is happening ?

Share this post


Link to post
Share on other sites
Just now, metalpoetza said:

That's odd, I've never seen that happening. What OS are you on ? Are you sure you got beta-2c ? Any other information you can give me to help me work out why this is happening ?

I am on Windows which may explain why its not working correctly as you said you don't have access to any Windows machines right? Other than that, all I am doing if going INTO the pyKAN 0.0.1-Beta 2c folder and shift-right clicking to open a command promt window in that directory. From there, I have tried many things. I have tried typing 'py' and then typing './pyKAN --help', '/pyKAN --help', 'pyKAN --help', and lastly 'pyKAN'. I have also tried just typeing those before entering 'py'. Again, I'm pretty unfamiliar with python so I may be doing something super incorrectly.

Share this post


Link to post
Share on other sites

I'm just guessing here - but have you tried:

python pykan --help

or perhaps:

python3 pykan --help

It's also possible that python3 is not in your path - so you may need to give a full path to where it is installed. Probably somewhere under Program Files (no idea really). On UNIX the bangpath will conveniently read that out of the environment variables, but I don't think windows understands bangpaths and even if it did - it wouldn't know what /usr/bin/env means.

The ./ notation is a Unix/Linux convention. By default the current directory on those is not in your path - ./ means "run from here" - but in windows that shouldn't be needed since the current drectory is in your PATH by default.

Edited by metalpoetza

Share this post


Link to post
Share on other sites
3 minutes ago, metalpoetza said:

I'm just guessing here - but have you tried:


python pykan --help

It's also possible that python3 is not in your path - so you may need to give a full path to where it is installed. Probably somewhere under Program Files (no idea really). On UNIX the bangpath will conveniently read that out of the environment variables, but I don't think windows understands bangpaths and even if it did - it wouldn't know what /usr/bin/env means.

Ayyyyy, that worked. By the way, I had to install appdirs. Might wanna mention it in your readme just for any other users on windows like me. Thanks!

Share this post


Link to post
Share on other sites
3 minutes ago, bananashavings said:

Ayyyyy, that worked. By the way, I had to install appdirs. Might wanna mention it in your readme just for any other users on windows like me. Thanks!

Awesome. I've added a note about both to the readme.

Share this post


Link to post
Share on other sites

Interesting, I've been searching for something that isn't CKAN too!

I happen to be on Windows 10 Pro x64, just installing py 3.6b2.

Using python versions 3.3.2 or 3.5.2 I get a syntax error for line 11:
 

File "pyKAN", line 11
    print "WARNING ! Many upstream download servers required SNI verification."
                                                                              ^
SyntaxError: Missing parentheses in call to 'print'

I'm guessing that maybe python on windows is a little less forgiving than on linux?

Also, for windows users, you might want to utilise a simple batch file like
( pyKAN.bat )

python pyKAN %1

(Assuming python is setup to be in their PATH)

Share this post


Link to post
Share on other sites
2 hours ago, fronbow said:

Interesting, I've been searching for something that isn't CKAN too!

I happen to be on Windows 10 Pro x64, just installing py 3.6b2.

Using python versions 3.3.2 or 3.5.2 I get a syntax error for line 11:
 


File "pyKAN", line 11
    print "WARNING ! Many upstream download servers required SNI verification."
                                                                              ^
SyntaxError: Missing parentheses in call to 'print'

I'm guessing that maybe python on windows is a little less forgiving than on linux?

You appear to be using the first beta - that version was still written for python2 - and that the print statement syntax is altered in python3.

Please use the latest beta or the master branch instead, it is python3 compatible and a great deal more stable.

Share this post


Link to post
Share on other sites

Yes that cured it, cheers (I'm using the release version rather than the source repo).

For Windows users, so long as they installed python rather than downloading and extracting, python and pip should be in their path. But they will need to install the dependencies:

pip install appdirs
pip install requests

(which could live in the simple batch file)

It might also be worth saying, to get it started on windows:

python pyKAN addkspdir --kspdir "DRIVE_LETTER:\PATH TO KSP"

 

Share this post


Link to post
Share on other sites
16 minutes ago, fronbow said:

Yes that cured it, cheers (I'm using the release version rather than the source repo).

Which is of course viable since, as of this morning, there is a stable release version.

 

17 minutes ago, fronbow said:

For Windows users, so long as they installed python rather than downloading and extracting, python and pip should be in their path. But they will need to nstall the dependencies:


pip install appdirs
pip install requests

It might also be worth saying, to get it started on windows:


python pyKAN addkspdir --kspdir "DRIVE_LETTER:\PATH TO KSP"

I purposely didn't specify how to install the dependencies (even in the error messages) because the best way to do so varies by platform. Pip will work universally but on a system with decent package management it's better to use the OS-native packages (i.e. apt or rpm). I have no idea if pip is the only/best way to install modules on Windows :P

Share this post


Link to post
Share on other sites
Just now, metalpoetza said:

I purposely didn't specify how to install the dependencies (even in the error messages) because the best way to do so varies by platform. Pip will work universally but on a system with decent package management it's better to use the OS-native packages (i.e. apt or rpm). I have no idea if pip is the only/best way to install modules on Windows :P

Unless they're a developer, then the average windows user won't understand that!! But yes, that is the best way to get them. There might be a way with npm in Visual Studio, but again that would mean they're a developer so I would assume they know what they are doing. I just created a PR for that simple batch file :wink:

If there's anything you want testing/trying out in Windows gimme a nudge, I'd be more than happy to give you insights from this OS!

Share this post


Link to post
Share on other sites

Honestly ? I don't much care about windows. I'm happy that it works for you - but this is a labour of love for me, and I'm a Linux fan - so I'm not really willing to put in any significant effort into supporting it. I didn't mind adding AppDirs to fix an obvious platform-compatiblity issue, and I'm happy to merge pull requests like yours that make things easier but doesn't not otherwise interfere with the code but I'm not really willing to do any work on that. I'd rather focus on new features and bugfixes.

This is an open-source project though - and I really would like to see people adding what they want, and if people want windows support made simpler - then I am happy to let those who have the skill and desire add that for them.  I'll stick to caring about stability and functionality :P

I've merged your PR by the way. 

 

Share this post


Link to post
Share on other sites

Cheers for the merge!

I completely understand, and I am a linux fan too, but I'm also a gamer (and a developer!), so I play around/do serious stuff in a VM :( and run my paid software in Windows.

I'm happy to contribute anything that means us windows users get another alternative to CKAN. You're doing well with the "heavy lifting" so far!

Cheers

Share this post


Link to post
Share on other sites

Something like this may well be the ultimately best way to approach it. But I'll leave it to you see if it's feasible and what it would take to maintain,

https://pypi.python.org/pypi/py2exe/0.9.2.0

It may require a distutils setup.py to be written - which goes against the "self contained in one directory" approach I took, but wouldn't be harmful to add as an alternative either.

As an aside - I'm a gamer too - but between wine and steam I haven't missed windows in that regard. Waiting a few months for a new game doesn't bother me much, it just means I can buy it on sale :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now