Skip to content

More setup.py/version fixes - #32

Merged
eteq merged 3 commits into
astropy:masterfrom
embray:setup-fixes
Oct 26, 2011
Merged

eteq merged 3 commits into
astropy:masterfrom
embray:setup-fixes

Conversation

@embray

@embray embray commented Oct 24, 2011

Copy link
Copy Markdown
Member

These are two fixes that resulted from an exchange I had with @eteq earlier.

The first is the get rid of a BUILD variable in setup.py that was an artifact of PyWCS's setup.py. Instead it uses astropy.version.release which has in effect the same semantics (theoretically one might want to do a 'release' build while still under development, but in that remote case the developer may manually remove 'dev' from the version).

The second is another fix to the version.py template. It's now much simpler than before and does not rely on any obscure (and unreliable) machinery in pkg_resources. Instead it just checks if astropy is being imported from within a git working copy, and if so it updates the version string if necessary. If astropy is not being imported from within a git working dir then the version is left "frozen".

…ny setuptools/distribute-specific machinery to determine whether or not to update the git revision at import-time. Instead it just does so whenever astropy is being imported from withing a git working dir.
@mdboom

mdboom commented Oct 24, 2011

Copy link
Copy Markdown
Contributor

On Mon, Oct 24, 2011 at 3:31 PM, Erik Bray <
[email protected]>wrote:

These are two fixes that resulted from an exchange I had with @eteq
earlier.

The first is the get rid of a BUILD variable in setup.py that was an
artifact of PyWCS's setup.py. Instead it uses astropy.version.release
which has in effect the same semantics (theoretically one might want to do a
'release' build while still under development, but in that remote case the
developer may manually remove 'dev' from the version).

This flag is used to turn on and off debugging asserts (range checking and
the like). It's quite common that the developer (i.e. me) wants to have
them on to verify for correctness and then off for benchmarking. It
actually has little to do with whether it's a tagged release or not. In
fact, a user may want to build in debug mode from a released tarball. So I
think it needs to be completely disconnected from astropy.version.release.
Ideally, it would be a distutils build parameter, I just haven't gotten
around to implementing it in that way.

@embray

embray commented Oct 24, 2011

Copy link
Copy Markdown
Member Author

In that case we could add a debug variable and a --debug command line switch for the build command. I'm certainly not against that. I guess as implemented it seemed redundant since it was using 'release' as one of the possible values. I know that in its original context it wasn't redundant at all.

I'll go ahead and add that here.

Comment thread astropy/version_helper.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if instead of using show_warning, we should send the warning to distutils.log.warn?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I seem to recall thinking that at one point to, but decided against it for reasons I can no longer recall.

But even so, if I used log.warn these warnings will still always show unless the default log level is set higher than 'warn'. Maybe that's not such a bad thing. But as I've learned recently with PyFITS too many "warnings" scare users.

@eteq

eteq commented Oct 25, 2011

Copy link
Copy Markdown
Member

+1 for the idea of a debug option. Perhaps we should even call it --cdebug to make it clear that it's for debugging in a C/Cython context?

I'm also glad for getting rid of the distribution stuff in version.py - it was causing a variety of strange problems for me.

@embray

embray commented Oct 25, 2011

Copy link
Copy Markdown
Member Author

Right, like I said in my e-mail the approach I was using isn't even reliable anymore (It used to be, but apparently hasn't been for a long time). So better to dispense with it.

As for the --debug option, the build and build_ext commands already have a --debug command line option (that's only used by build_ext currently). The patch I'm working on adds a debug variable to version.py so that an easily accessible record is left in place as to whether or not the last build was a "debug" build. This is still used primarily by C extensions but it could theoretically be used by pure Python code too.

Another nice advantage of my patch (which adds a custom build command) is that it rebuilds the C code if the "debug" status changes from the last build. The normal build command doesn't do this (you have to manually rm -rf build/) since it has no way of knowing what type of build was last performed.

@mdboom

mdboom commented Oct 25, 2011

Copy link
Copy Markdown
Contributor

@iguananaut: That sounds like it perfectly meets astropy.wcs' needs. Thanks.

…sing the

`--debug` option to `./setup.py build` (note: this is not supported by
`./setup.py install` install, so you must manually run `build` to create a
debug build).  If `./setup.py build` is run without `--debug` then the debug
flag is set to `False`.  If the debug value changes from the previous build, a
rebuild of all C extensions is forced.

There are at least two advantages to having `debug` in version.py.  The first
is informational: Whether or not the package was built with debug enabled is
frozen with the source code.  The other advantage is that the flag becomes
globally available to modules that need to configure C extensions, and it could
even be used by pure Python code, for example, to enable debug logging
globally.

This patch went through several iterations before I was happy with it.  The
Cython changes are mostly incidental at this point, though in an earlier
version of the patch they were more necessary.  This is because the `build` and
`build_ext` commands were being subclassed.

However, I eventually realized that in order for that approach to work
consistently it would also be necessary to subclass all of the other `build_`
commands.  And the more you start overriding things in distutils the further
you start going down the `numpy.distutils` path, which is a direction best
avoided.

This version of the patch still uses the distutils machinery to get the value
of the --debug option.  This has the advantage that it can also take the debug
option from one's setup.cfg file.  For example, adding

 [build]
 debug = True

to setup.cfg during development ensures that debug mode is always turned on,
for example.
eteq added a commit that referenced this pull request Oct 26, 2011
Adjusts setup.py version version freezing to be more stable and additional associated clarification in setup.py
@eteq
eteq merged commit 27dcbdc into astropy:master Oct 26, 2011
astrofrog added a commit that referenced this pull request Oct 26, 2011
keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
Adjusts setup.py version version freezing to be more stable and additional associated clarification in setup.py
keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
jeffjennings pushed a commit to jeffjennings/astropy that referenced this pull request Jul 2, 2025
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.

3 participants