p-hofmann / SMBEdit

StarMade Blueprint Editor
5 stars 1 forks source link

SMBEdit as a pip-installable package #17

Closed Septaris closed 7 years ago

Septaris commented 7 years ago

SMBEdit has become a very complete library and it would be interesting to be able to use it in other projects via pip (I'm currently using it for one of my projects :))

p-hofmann commented 7 years ago

I like it! I will check it out when I got some time to spare. The relative library paths worry me a little. I seem to have a vague memory of there being some issue, maybe not compatible with 2.7. I will know for sure when it is tested in circleci.

By the way, I made a file for reading sm template files in the gui_dev branch that might be interesting for you. https://github.com/p-hofmann/SMBEdit/blob/gui_dev/lib/smtpl.py I have not yet checked if I got the block positions backwards and there is still a metadata entry type that eludes me, but it should be able to read all other information from those files.

Septaris commented 7 years ago

from https://docs.python.org/2/tutorial/modules.html

Starting with Python 2.5, in addition to the implicit relative imports described above, you can write explicit relative imports with the from module import name form of import statement.

It will be useful to be able to use templates to manipulate small pieces rather than use the whole BP.

p-hofmann commented 7 years ago

The installation was successful, but I am getting an error when I try to call it with "smbedit -h"

https://circleci.com/gh/p-hofmann/SMBEdit/60

Any clue what the issue might be?

Septaris commented 7 years ago

I don't know, on my Windows (10) it's working. I will check anyway

Septaris commented 7 years ago

Rectification: With the last version on develop, the script is not working neither for debian or windows. I will check what is wrong and prepare a patch ;)

Septaris commented 7 years ago

If you install the package with pip install -e ., it's working. That's why I did not see the bug the first time.

Changing the setup like this seems to fix the bug:

setup(name='SMBEdit',
      version=version,
      description='StarMade Blueprint Editor',
      author='Peter Hofmann',
      author_email='',
      url='https://github.com/p-hofmann/SMBEdit',
      py_modules=['smlib', 'smbedit'], # <--- here are the changes
      packages=find_packages(exclude=('unittests',)),
      entry_points={
          'console_scripts': [
              'smbedit = smbedit:main',
              ],
          },
      )

Hope this will not create a new bug ^^

Do you want I submit a new merge request or can you change this directly ?

p-hofmann commented 7 years ago

Yes, seems to have done the trick. I just found a 'stackmirror' post pointing me in the same direction.

py_modules=['smbedit']

This seems to do it.

p-hofmann commented 7 years ago

Hm, now it works locally, but circleci test still fails. Odd. https://circleci.com/gh/p-hofmann/SMBEdit/62

pip install ./

Processing /home/ubuntu/SMBEdit
  Requirement already satisfied (use --upgrade to upgrade): SMBEdit==0.1.9 from file:///home/ubuntu/SMBEdit in /home/ubuntu/virtualenvs/venv-system/lib/python2.7/site-packages

That is very odd!

p-hofmann commented 7 years ago

Ok, seems circleci does not provide a clean build for every run. That is very good to know. I forced reinstall of the SMBEdit package, now it works. https://circleci.com/gh/p-hofmann/SMBEdit/65 I will probably release it together with the next starmade release.

Thanks a lot!

p-hofmann commented 7 years ago

Seems I have to add more tests :)

ERROR: Traceback (most recent call last):
  File "/usr/local/bin/smbedit", line 9, in <module>
    load_entry_point('SMBEdit==0.1.9', 'console_scripts', 'smbedit')()
  File "/usr/local/lib/python2.7/dist-packages/smbedit.py", line 302, in main
    sys.stderr.write(e.args[0])
TypeError: expected a character buffer object

Seems it crashes reporting that it crashed reading a blueprint. Great.

p-hofmann commented 7 years ago

IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/config.ini' That's what I was worried about. Seems I have to switch location of the 'config.ini' to ... the home folder?

Probably not an issue with Windows OS.