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

[Documentation] Use entry_points to build static resources in fullrelease call #88

Open
idgserpro opened this issue May 31, 2021 · 0 comments

Comments

@idgserpro
Copy link
Member

idgserpro commented May 31, 2021

Usually when using this package (like collective.cover) you need to follow a different workflow if you're into just calling fullrelease:

    run longtest and fullrelease, as usually
    answer "no" when asked to upload to PyPI and continue normally
    do a checkout to the tag you're releasing
    run bin/build-cover to update static files
    create the distribution files using python setup.py sdist bdist_wheel as usual
    upload the files using twine upload dist/*

It's possible to use entry_points from zest.releaser and hooks to call the webpack compiling stage when creating the build, after the checkout. Take collective.cover, for example:

Edit your setup.cfg:

[zest.releaser]
extra-message = [skip ci]
hook_package_dir = src/collective/cover
releaser.after_checkout =
    entry_points.build_webpack

And add an entry_points.py:

import os
import time

OK_EXIT_CODE = 0
BUILD_CMD = 'build-cover'

def _run_cmd(cmd, exception_msg="Error when running cmd {0}"):
    exit_code = os.system(cmd)  # nosec
    if exit_code != OK_EXIT_CODE:
        raise OSError(exception_msg.format(cmd))

def build_webpack(data):
    tmpdir = data['tagworkingdir']
    print(tmpdir)  # NOQA
    time.sleep(3)
    bin_location = '{0}/bin'.format(tmpdir)
    _run_cmd('virtualenv {0}'.format(tmpdir))
    _run_cmd('{0}/pip install -r requirements.txt'.format(bin_location))
    _run_cmd('{0}/buildout'.format(bin_location))
    _run_cmd('{0}/{1}'.format(bin_location, BUILD_CMD))

If you want to check for virtualenv and another dependencies before doing the hook, you can add a prereleaser.before for example in entry_points.check_deps_to_build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant