[Scons-users] Fwd: Couple more feature ideas

RW garlicbready at googlemail.com
Mon Aug 7 20:45:31 EDT 2017


Just to follow on the below
For point 2 I've found the best way to search for plugins is probably via
the use of entrypoints within setup.py (since this is how mkdocs does it
for picking up theme plugins)

https://stackoverflow.com/questions/774824/explain-python-entry-points
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points

so I'm going to see if I can write a couple of tools in git repo's /
install them via pip into a virtual python environment / then see if I can
modify the tool loader within scons to pickup on the entrypoints the tools
have added in, as well as any tests.

Many Thanks
Richard




---------- Forwarded message ----------
From: RW <garlicbready at googlemail.com>
Date: 4 August 2017 at 09:25
Subject: Couple more feature ideas
To: SCons users mailing list <scons-users at scons.org>


Hi,
I've come up with a couple more ideas for features.
I'm not sure if these are good or bad ideas.

1. The first is a new convenience function called something like
PyPackageDir
This would search for a given python module name on sys.path and return
it's directory

random example:
path1 = PyPackageDir('somepackage.subpackage')
under windows would return a value something like - "C:\Python27\Lib\site-
packages\somepackage\subpackage"

Lets say I created a tool to override GCC located somewhere in a separately
installed python package
of somepackage.subpackage.GCC
currently I could use
env = Environment(tools=['somepackage.subpackage.GCC'], toolpath=[sys.path])

but this requires having a prefix in the toolname.
With this function I could do this instead
env = Environment(tools=['GCC'], toolpath=[PyPackageDir('
somepackage.subpackage')])

ultimatley the env.ToolName part is the same regardless so this is just
more of a convenience.
Basically it gives you the option to remove the prefix from the toolname
when referencing tools external to scons

I've put a pull request here:
https://bitbucket.org/scons/scons/pull-requests/496/additional-pypackagedir-
function-for-use/diff
and run some tests on both linux / windows
Let me know of any thoughts / if perhaps the name of the function should be
something different / if this is a bad idea etc.



2. The second idea is to setup a namespace package somewhere within Scons

https://stackoverflow.com/questions/8380381/the-way-to-
make-namespace-packages-in-python
https://packaging.python.org/guides/packaging-namespace-packages/

I've not written any code for this one yet
but as a rough example a package directory like Scons.Addons or
Scons.Plugins which is marked as a namespace package

It should be possible to update the tool loader to look for tools under
Scons.Plugins.Tools for example
this way you could install tools via pip and then have them autofound
without the need to add them into the toolpath at invocation.
The one thing to watch out for would be conficting or overriding tool names.
But if you wanted to it would then open the door for moving some of the
existing tools into seperate repositorys.
(I'm not saying you should but there would then be the option)
This could in theory be used to also expand scons in other ways later on
via other types of plugins.

Many Thanks
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170808/673b7548/attachment-0001.html>


More information about the Scons-users mailing list