rixwew / darts-clone-python

Darts-clone python binding
Apache License 2.0
20 stars 12 forks source link

Use 'bdist_wheel' to make distribution archives for PyPI #7

Closed hiroshi-matsuda-rit closed 4 years ago

hiroshi-matsuda-rit commented 4 years ago

Hi there, I'm a developer of GiNZA NLP Library and planning to improve installing procedure of darts-clone-python on both Windows and Mac OS environments. We need to install C++ compiler before installing darts-clone-python to compile the Cython part of it. I think this prerequisite is a big hurdle for beginners and would like to skip the C++ compilation step by using wheel-based binary distribution instead of egg. I'd like to try to solve the errors below and share the solution how to distribute the wheel archives from PyPI in this issue.

$ python setup.py bdist_wheel
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/dartsclone
copying dartsclone/__init__.py -> build/lib.linux-x86_64-3.8/dartsclone
running build_ext
cythoning dartsclone/_dartsclone.pyx to dartsclone/_dartsclone.cpp
/home/matsuda/git/darts-clone-python/.eggs/Cython-0.29.14-py3.8-linux-x86_64.egg/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/matsuda/git/darts-clone-python/dartsclone/_dartsclone.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
warning: dartsclone/_dartsclone.pyx:125:49: local variable 'result' referenced before assignment
warning: dartsclone/_dartsclone.pyx:126:15: local variable 'result' referenced before assignment
building 'dartsclone._dartsclone' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/dartsclone
creating build/temp.linux-x86_64-3.8/csrc
creating build/temp.linux-x86_64-3.8/csrc/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I./csrc/include -I/home/matsuda/git/tweet-search/venv/include -I/home/matsuda/.pyenv/versions/3.8.1/include/python3.8 -c dartsclone/_dartsclone.cpp -o build/temp.linux-x86_64-3.8/dartsclone/_dartsclone.o
dartsclone/_dartsclone.cpp:614:10: fatal error: darts.h: No such file or directory
 #include "darts.h"
          ^~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
rixwew commented 4 years ago

Thanks for your suggestion for improvements. It seems you does not clone the submodule. Could you try git submodule init and git submodule update? @hiroshi-matsuda-rit

hiroshi-matsuda commented 4 years ago

I could create some binary wheel archives of darts-clone-python on windows 10 64bit, mac os 10.14, and ubuntu 19.10 for python 3.6, 3.7, and 3.8. But actually, there are too many combinations among the OSs and the python versions to handle by hands. We should find some automated ways. I'd like to try to use explosion's solution with Azure Pipelines. https://github.com/explosion/wheelwright It will take few weeks.

hiroshi-matsuda-rit commented 4 years ago

Hi @rixwew ,

We just succeeded to generate wheel archives for almost all of the OSs with python 3.6, 3.7, and 3.8 by using GitHub actions. Please see following PR of our fork repository of darts-clone-python. https://github.com/megagonlabs/darts-clone-python/pull/1/files

We can implement and add auto deploy to PyPI function if you need.

Please let me know your thoughts about this GitHub action based apporach.

rixwew commented 4 years ago

Thank you, @hiroshi-matsuda-rit. Your codes look great to me.

We can implement and add auto deploy to PyPI function if you need.

I want to auto-deploy the PyPI dartsclone package to avoid mistakes, And I think the GitHub actions based approach is good. If you can implement the deploy function, I'd like to merge it after testing at test.pypi.org repo.

hiroshi-matsuda-rit commented 4 years ago

We'd like to add an auto-deploy function to the PR of our fork. I just invited @rixwew to our fork repository. Would you write your user name of test.pypi.org to our PR, and also create a new Secret entry containing the password for test.pypi.org (github would protect it but please use unique one to make sure) on our fork repository by like the blog post below? https://github.com/megagonlabs/darts-clone-python/pull/1 https://github.com/megagonlabs/darts-clone-python/settings/secrets https://qiita.com/ykhirao/items/65fee829ee0478187027#3-%E3%83%AC%E3%83%9D%E3%82%B8%E3%83%88%E3%83%AA%E3%81%AB%E3%83%91%E3%82%B9%E3%83%AF%E3%83%BC%E3%83%89%E3%82%92%E5%9F%8B%E3%82%81%E8%BE%BC%E3%82%80

rixwew commented 4 years ago

It seems I do not have the privilege to edit secrets settings, because https://github.com/megagonlabs/darts-clone-python/settings/secrets is 404 not found.

Could you grant me the privilege to edit the page? Or If you don’t mind, you can push the codes to this repository. I added TEST_PYPI_PASSWORD and invited @hiroshi-matsuda-rit and @toshi-saito.

hiroshi-matsuda-rit commented 4 years ago

@rixwew Oh, sorry. Actually, the admin privilege were required to edit Secret tab. I've changed your permission to admin. We think that it is safer to test our new GitHub action tasks on our fork repo. Could you please set TEST_PYPI_PASSWORD for our repo's Secret tab again?

rixwew commented 4 years ago

I added TEST_PYPI_PASSWORD and TEST_PYPI_USER on your repository. Thank you! @hiroshi-matsuda-rit

hiroshi-matsuda-rit commented 4 years ago

I just submitted a PR below. Please read the description and comment. https://github.com/rixwew/darts-clone-python/pull/8

rixwew commented 4 years ago

Hi @hiroshi-matsuda-rit I uploaded the packages to pypi repository using github actions. https://pypi.org/project/dartsclone/

Thank you so much for your contribution.