Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Dep refactor #2360

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

Closed
wants to merge 14 commits into from
Closed

Dep refactor #2360

wants to merge 14 commits into from

Conversation

mrterry
Copy link
Contributor

@mrterry mrterry commented Aug 30, 2013

It would be nice to have a more configurable (robust?) way to discover and configure extensions/dependencies. Please regard this as a prototype (it is not py26 compliant, for starters), but close enough to start the discussion.

This does a couple things:

  • creates a master OrderedDict of SetupPackage objects
  • makes SetupPackage objects explicity declare their dependencies on construction
  • refactors the pkg_config logic into its own class
  • introduces a FTConfig class to use freetype_config

I've seen bugs where extensions can get inconsistent headers and libs because Freetype.check() and Freetype.add_flags() don't duplicate the needed freetype_config logic. This is my attempt to make that class of bugs go away.

It may introduce another class of more obnoxious bugs, so please let me know your opinions.

@mdboom
Copy link
Member

mdboom commented Sep 3, 2013

This looks like a valuable improvement -- only testing in lots of different environments will tell whether it's introducing new obnoxious bugs ;)

One immediate problem:

› python setup.py build
Traceback (most recent call last):
  File "setup.py", line 88, in <module>
    mpl_packages['libAgg'],
KeyError: 'libAgg'

One concern: There seems to be a lot of code duplication between the PkgConfig and FreetypeConfig classes. The intent of the PkgConfig class was to be useful for pkg-config and "pkg-config-based" tools, like "freetype-config" -- I see now that had some bugs, but I wonder if we couldn't fix that by inheriting from PkgConfig and reusing the common functionality, rather than copy-and-pasting it. Certain methods, like PkgConfig.setup_extension were hard to get right and I suspect it will need to be updated in the future... better to do that only in one place. Also, I only recently became aware of libpng-config, which maybe should be used for finding png instead of pkg-config directly as well -- so we have at least three of these things now.

Speaking from experience, this sort of configuration stuff is always deceptively fiddly, so thanks for taking the time with it.

@mdboom
Copy link
Member

mdboom commented Sep 3, 2013

Note #2331 will probably force a bit of a refactor over here. #2331 is likely to go on the maintenance branch, but I don't think this (which cuts deeper) necessarily should.

@mrterry
Copy link
Contributor Author

mrterry commented Sep 3, 2013

Thanks for taking a look at this. Good point on removing code duplication. PkgConfig and FreetypeConfig (probably LibpngConfig eventually), should try to share as much of the same implementation as possible. This should wait for the next version to get as much testing abuse as possible before being released into the wild. I'll rebase off of master after #2331 lands.

Is there a decision for when MPL drops python 2.6 support? I like the OrderedDict interface, but it showed up in 2.7. Assuming 2.6 support is sticking around, is there any issue with packaging the OrderedDict recipe?

This deserves another another discussion, but I think this PR starts laying the infrastructure to download/build/statically-link libpng/freetype if they are not found on the system. At least on *nix-like platforms.

@mdboom
Copy link
Member

mdboom commented Sep 3, 2013

I think Python 2.6 is still reasonably important -- 24% of our users responded they were using it in our survey. The complication here is that the ordered dict would have to be available during build time, and I'm not crazy about increasing the size of the build code by too much. You could go back to using a list, and just creating local references to the entries that matter that are used multiple times (agg, cxx, freetype etc).

And yes, having auto download/build/link of freetype and png would be great -- it's the biggest barrier to entry when building from source.

@mrterry
Copy link
Contributor Author

mrterry commented Sep 11, 2013

Is #2331 merged into master? I saw it land in the maintenance branch.

@mdboom
Copy link
Member

mdboom commented Sep 11, 2013

I just merged it now.


def setup_extension(self, ext, package, default_include_dirs=[],
default_library_dirs=[], default_libraries=[],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutable default arguments are dangerous. Unless I hear otherwise, I'm going to assume this is a lurking bug and clean it up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Luckily this only gets run once, but even so I agree - this was a mistake.

@pelson
Copy link
Member

pelson commented Jan 9, 2014

@mrterry - would you mind rebasing, and we can get on and merge this.

Cheers,

@tacaswell
Copy link
Member

@mrterry Seems to have gone quiet, you want to adopt this @pelson ?

@tacaswell
Copy link
Member

@pelson Unless you want to adopt this, I am going to punt this to 1.4.x

@tacaswell tacaswell modified the milestones: v1.4.x, v1.4.0 Mar 8, 2014
@tacaswell
Copy link
Member

@mrterry I am closing this as it is over a year old and there have been a good number of other changes to setup.py between now and then. I suspect re-basing this branch would be more work than just re-doing it.

@tacaswell tacaswell closed this Oct 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants