-
Notifications
You must be signed in to change notification settings - Fork 32
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
Editable install no longer runs nodejs build step #249
Comments
I made some progress on this. Working with the info from the linked docs, I was able to get editable installs to use a setuptools from pathlib import Path
import subprocess
from setuptools import setup, Command
from setuptools.command.build_py import build_py
from setuptools.command.sdist import sdist
from setuptools.command.build import SubCommand
pkg_root = Path(__file__).parent / "src"
class SrcDistCommand(sdist):
"""Custom build command."""
def run(self):
self.run_command("bundle-icons")
super().run()
class BuildPyCommand(build_py):
"""Custom build command."""
def run(self):
self.run_command("bundle-icons")
super().run()
class BundleCommand(Command, SubCommand):
"""A custom command to run svgo (via nox) on all bundled SVG icons."""
description = "Copy and optimize SVG files from npm modules."
user_options = [
# The format is (long option, short option, description).
("dirty", None, "skip bundling icons if they already exist in pkg src"),
]
def initialize_options(self):
"""Set default values for options."""
# Each user option must be listed here with their default value.
self.dirty = False
def finalize_options(self):
"""Post-process options."""
if (
self.dirty
and not Path(pkg_root, "my_pkg", ".icons", "tabler").exists()
):
raise OSError("Building package 'dirty', but no generated SVG files exist!")
def run(self):
"""Run command."""
if not self.dirty:
self.announce("Running nox session: bundle_icons", level=2)
subprocess.run(["nox", "-s", "bundle_icons"], check=True, shell=True)
# all install info is located in pyproject.toml
setup(
cmdclass={
"bundle-icons": BundleCommand,
"build_py": BuildPyCommand,
"sdist": SrcDistCommand,
},
) The inheriting from both |
I think you can't pass options when using This is how I fixed this issue for a different project: google/neuroglancer@dbd8ead#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7 |
will pass the TBH, I don't fully follow all the changes in that diff's setup.py file. But I haven't really explored the setuptools internals enough. I do like this tactic: # If building from an sdist, `package.json` won't be present but the
# bundled files will. Seems useful if using pypa/build to make dists. |
I just found out that setuptools v64.0.2+ will ignore any exceptions raised by custom commands during editable installs: pypa/setuptools@048633a 👎🏼 |
Looks like the issue is that
pip install -e .
no longer runs thedevelop
command, which is what we were relying on in setup.py to do the nodejs build. It looks like there is a new mechanism that can be used to handle editable builds, but it is not clear to me exactly how to use it:https://setuptools.pypa.io/en/latest/userguide/extension.html#supporting-sdists-and-editable-installs-in-build-sub-commands
Originally posted by @jbms in #247 (comment)
The text was updated successfully, but these errors were encountered: