Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate .pyc files from .hy files on install #2299

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dist
build/
/.cache
/.pytest_cache
/.eggs
1 change: 1 addition & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Bug Fixes
in string and bytes literals.
* ``defmacro`` no longer allows arguments after ``#* args``
* Tracebacks from code parsed with `hy.read` now show source positions.
* Hy now pre-compiles .hy files during setup/installation.

New Features
------------------------------
Expand Down
39 changes: 30 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import fastentrypoints # Monkey-patches setuptools.
from get_version import __version__
from setuptools import find_packages, setup
from setuptools.command.install import install

os.chdir(os.path.split(os.path.abspath(__file__))[0])

Expand All @@ -14,14 +15,34 @@
make things work nicer, and lets Python and the Hy lisp variant play
nice together. """


class install(install):
def run(self):
super().run()
import py_compile
from glob import glob

import hy # for compile hooks

for path in glob(os.path.join(self.install_lib, "**/*.hy"), recursive=True):
py_compile.compile(
path, invalidation_mode=py_compile.PycInvalidationMode.CHECKED_HASH
)


# both setup_requires and install_requires
# since we need to compile .hy files during setup
requires = [
"funcparserlib ~= 1.0",
"colorama",
'astor>=0.8 ; python_version < "3.9"',
]

setup(
name=PKG,
version=__version__,
install_requires=[
"funcparserlib ~= 1.0",
"colorama",
'astor>=0.8 ; python_version < "3.9"',
],
setup_requires=requires,
install_requires=requires,
python_requires=">= 3.7, < 3.11",
entry_points={
"console_scripts": [
Expand All @@ -35,10 +56,7 @@
},
packages=find_packages(exclude=["tests*"]),
package_data={
"hy": ["*.hy", "__pycache__/*"],
"hy.contrib": ["*.hy", "__pycache__/*"],
"hy.core": ["*.hy", "__pycache__/*"],
"hy.extra": ["*.hy", "__pycache__/*"],
"": ["*.hy"],
},
data_files=[("get_version", ["get_version.py"])],
author="Paul Tagliamonte",
Expand Down Expand Up @@ -69,4 +87,7 @@
"Documentation": "https://docs.hylang.org/",
"Source": "https://github.com/hylang/hy",
},
cmdclass={
"install": install,
},
)