raelgc / scudcloud

ScudCloud - Slack for Linux
https://launchpad.net/~rael-gc/+archive/ubuntu/scudcloud
MIT License
1.22k stars 99 forks source link

Removed minified JS files and added custom build step to generate them #583

Closed onitake closed 7 years ago

onitake commented 7 years ago

This patch addresses one aspect of issue #512 .

It removes the two minified JavaScript files in scudcloud/resources/ and adds a custom setuptools build step to generate them on the fly.

The resulting Debian package works as intended. There is one caveat, however: As the minified JS files are removed from the source tree, it will not be possible to run scudcloud directly during development. A workaround is needed so they can be loaded from sources/ instead.

raelgc commented 7 years ago

@onitake, while trying to build the package locally, I'm facing this error message:

I: pybuild base:184: python3.5 setup.py clean 

Note: Bypassing https://pypi.python.org/simple/jsmin/ (disallowed host; see http://bit.ly/1dg9ijs for details).

Couldn't find index page for 'jsmin' (maybe misspelled?)

Note: Bypassing https://pypi.python.org/simple/ (disallowed host; see http://bit.ly/1dg9ijs for details).

No local packages or download links found for jsmin

Appears that I need to put a --allow-hosts in some place of the setup.py. Can you help with that?

raelgc commented 7 years ago

Ok, I've created a setup.cfg allowing hosts from python.org.

But, for some reason, setup cannot download files:

Download error on https://pypi.python.org/simple/jsmin/: [Errno 111] Connection refused -- Some packages may not be found!
Couldn't find index page for 'jsmin' (maybe misspelled?)
onitake commented 7 years ago

Ok, this is interesting. It seems I got away fine because I already had jsmin installed on my system.

Why does it say simple/jsmin? The correct URL should be: https://pypi.python.org/pypi/jsmin/

If I run setup.py on my system without jsmin installed, I get this:

$ python3.5 setup.py clean 
zip_safe flag not set; analyzing archive contents...

Installed /tmp/scudcloud/.eggs/jsmin-2.2.2-py3.5.egg
running clean
onitake commented 7 years ago

simple/... seems to be correct, this is just a simple interface on the pypi package server.

Since you're getting connection errors, it must be something in pybuild (or which built tool you're using). Maybe an incorrect proxy?

raelgc commented 7 years ago

I'm trying create the source package for Canonical Launchpad PPA, running debuild -S -sa.

I think setup is trying to install a package globally, to I've changed my setup.cfg to try to use the user option:

[easy_install]
allow_hosts = *.python.org
user=1

And then I face this error:

Download error on https://pypi.python.org/simple/jsmin/: [Errno 111] Connection refused -- Some packages may not be found!
Couldn't find index page for 'jsmin' (maybe misspelled?)
Download error on https://pypi.python.org/simple/: [Errno 111] Connection refused -- Some packages may not be found!
No local packages or download links found for jsmin
Traceback (most recent call last):
  File "setup.py", line 71, in <module>
    'build_py': MinifyJsBuildCommand,
  File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 269, in __init__
    self.fetch_build_eggs(attrs['setup_requires'])
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 313, in fetch_build_eggs
    replace_conflicting=True,
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 826, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1092, in best_match
    return self.obtain(req, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1104, in obtain
    return installer(requirement)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 380, in fetch_build_egg
    return cmd.easy_install(req)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 657, in easy_install
    raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('jsmin')
E: pybuild pybuild:274: clean: plugin distutils failed with: exit code=1: python3.5 setup.py clean 
onitake commented 7 years ago

This is very strange indeed! When Debian package python3-jsmin is installed, setuptools will not try to download the egg for jsmin.

When I run debuild locally, this works fine. Let me check what happens without internet.

raelgc commented 7 years ago

If I remove the [easy_install] from the setup.cfg, I get this:

$ debuild -S -sa
 dpkg-buildpackage -rfakeroot -d -us -uc -S -sa
dpkg-buildpackage: source package scudcloud
dpkg-buildpackage: source version 1.61-1
dpkg-buildpackage: source distribution xenial
dpkg-buildpackage: source changed by Rael Gugelmin Cunha <rael.gc@gmail.com>
 dpkg-source --before-build scudcloud
 fakeroot debian/rules clean
dh clean --with python3 --buildsystem=pybuild
   dh_testdir -O--buildsystem=pybuild
   dh_auto_clean -O--buildsystem=pybuild
I: pybuild base:184: python3.5 setup.py clean 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 353, in fetch_build_egg
    cmd = self._egg_fetcher
AttributeError: 'Distribution' object has no attribute '_egg_fetcher'
onitake commented 7 years ago

When I run debuild -S, it doesn't even execute the install script. Why is it trying to download the jsmin egg in your case?

Can you try installing python3-jsmin and see if you still get the error?

onitake commented 7 years ago

What versions are your python3 and python3-jsmin packages?

raelgc commented 7 years ago

My python3 is 3.5.2. python3-jsmin is not installed (I think this will be the same case as for users).

onitake commented 7 years ago

Ok, that is strange. This is exactly why I added a Build-Depends on python3-jsmin to debian/control.

debuild should throw an error if the package is not installed.

onitake commented 7 years ago

This should never affect end users - Build-Depends is only used during package building.

raelgc commented 7 years ago

Well, let me install it.

raelgc commented 7 years ago

It worked! :)

onitake commented 7 years ago

Ah, that's what I guessed!

It's still strange that you didn't get an error when running debuild. When a build dependency isn't available, it will complain and tell you to install it. Wtf?

raelgc commented 7 years ago

To be honest, I cannot remember the last time debuild complained about a missing dependency here (of course, I face this a lot of times).

Anyway, thank you for your time and patience!