This is a memorandum of trial and error when I made this.
** Only the parts of setup.py
and the file structure that are different from normal Python are described. ** **
File structure
.
├── hoge
│ ├── __init__.hy
│ ├── fuga
│ │ ├── __init__.hy
│ │ └── fugafuga.hy
│ └── hogehoge.hy
└── setup.py
1 directories, 5 files
setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup
config = {
'install_requires': ['hy'],
'packages': ['fuga', 'fuga.hoge'],
# __init__.find because there is no py_packages are useless
'package_data': {
'fuga': ['*.hy'],
'fuga.hoge': ['*.hy'],
},
#Normally.Because it only contains py files.I'll specify that hy is included
}
if __name__ == '__main__':
setup(**config)
Click here to set the entry point with setup.py
File structure
.
├── hoge
│ ├── __init__.py #Top level only.not hy.To py
│ ├── fuga
│ │ ├── __init__.hy
│ │ └── fugafuga.hy
│ └── hogehoge.hy
└── setup.py # setup.py is the same and OK
1 directories, 5 files
hoge/__init__.py
import hy as _hy
#Of course import hy is fine
#Import hy with import hook.You will be able to import hy
Obviously, it's exactly the same as in Python. By the way, use twine instead of python setup.py register
. The method of using setup.py
is active in TestPyPI, but is currently used in Production PyPI. can not.
Of course you need __init__.py
wherever you have the Python source. By the way, __init__.py
is also required when using the extension written in C together.
Recommended Posts