From 0ca5ffeb5074c540f1b429e57a69de95f099059d Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 14 Mar 2014 13:02:57 -0400 Subject: [PATCH] Simplify package-template usage and updating by requiring fewer files to be edited. --- MANIFEST.in | 4 +- README.rst | 159 +++++++++-------------------- docs/conf.py | 52 ++++++---- licenses/LICENSE.rst | 15 ++- packagename/__init__.py | 137 ++----------------------- packagename/_astropy_init.py | 131 ++++++++++++++++++++++++ packagename/tests/coveragerc | 2 +- packagename/tests/setup_package.py | 2 +- setup.cfg | 11 ++ setup.py | 39 +++++-- 10 files changed, 271 insertions(+), 281 deletions(-) create mode 100644 packagename/_astropy_init.py diff --git a/MANIFEST.in b/MANIFEST.in index 044e2ac5a..0ef8f9448 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,14 +2,12 @@ include README.rst include ez_setup.py include setuptools_bootstrap.py -recursive-include packagename *.pyx *.c recursive-include docs * recursive-include licenses * recursive-include cextern * recursive-include scripts * -exclude *.pyc *.o +exclude *.pyc *.o prune docs/_build prune build - diff --git a/README.rst b/README.rst index 3b0fa31a3..f6b189330 100644 --- a/README.rst +++ b/README.rst @@ -30,57 +30,45 @@ will be clear from context what to do with your particular VCS. This will download the latest version of the template from `github`_ and place it in a directory named ``yourpkg``. -* Go into the directory you just created, and open the ``setup.py`` file - with your favorite text editor. Follow the steps below to update it for - your new package. - - 1. Change the ``PACKAGENAME`` variable to whatever you decide your package - should be named (for examples' sake, we will call it ``yourpkg``). By - tradition/very strong suggestion, python package names should be all - lower-case. - 2. Change the ``DESCRIPTION`` variable to a short (one or few sentence) - description of your package. - 3. Define a longer description as a string in the ``LONG_DESCRIPTION`` - variable. You may want this to be the docstring of your package itself - as Astropy does. In this case, simply add ``import yourpkg`` somewhere - above, and set ``LONG_DESCRIPTION = yourpkg.__doc__``. Alternatively, - you may omit the description by deleting the variable and deleting the - line where it is used in the ``setup()`` function further down. - 4. Add your name and email address by changing the ``AUTHOR`` and - ``AUTHOR_EMAIL`` variables. - 5. If your affiliated package has a website, change ``URL`` to point to that - site. Otherwise, you can leave it pointing to `Astropy`_ or just - delete it. - 6. Exit out of your text editor - -* Now tell git to remember the changes you just made:: - - git add setup.py - git commit -m "adjusted setup.py for new project yourpkg" - -* Decide what license you want to use to release your source code. If you - don't care and/or are fine with the Astropy license, just edit the file - ``licenses/LICENSE.rst`` with your name (or your collaboration's name) at - the top as the licensees. Otherwise, make sure to replace that file with - whatever license you prefer, and update the ``LICENSE`` variable in - ``setup.py`` to reflect your choice of license. You also may need to - update the comment at the top of ``packagename/__init__.py`` to reflect your - choice of license. Again, tell git about your changes:: - - git add licenses/LICENSE.rst - git add setup.py # if you changed the license and modified setup.py - git commit -m "updated license for new project yourpkg" +* Go into the directory you just created, and open the ``setup.cfg`` + file with your favorite text editor. Edit the settings in the + ``affiliated`` section. These values will be used to automatically + replace special placeholders in the affiliated package template. + + 1. Change the ``package_name`` variable to whatever you decide your + package should be named. By tradition/very strong suggestion, + python package names should be all lower-case. + 2. Change the ``description`` variable to a short (one or few + sentence) description of your package. + 3. Add your name and email address by changing the ``author`` and + ``author_email`` variables. + 4. If your affiliated package has a website, change ``url`` to point + to that site. Otherwise, you can leave it pointing to `Astropy`_ + or just delete it. + 5. Exit out of your text editor + +* Update the main package docstring in ``packagename/__init__.py``. + +* Decide what license you want to use to release your source code. If + you don't care and/or are fine with the Astropy license, just edit + the file ``licenses/LICENSE.rst`` with your name (or your + collaboration's name) at the top as the licensees. Otherwise, make + sure to replace that file with whatever license you prefer, and + update the ``license`` variable in ``setup.cfg`` to reflect your + choice of license. You also may need to update the comment at the + top of ``packagename/__init__.py`` to reflect your choice of + license. * Take a moment to look over the ``packagename/example_mod.py``, - ``packagename/tests/test_example.py``, ``scripts/script_example``, and - ``packagename/example_c.pyx`` files, as well as the + ``packagename/tests/test_example.py``, ``scripts/script_example``, + and ``packagename/example_c.pyx`` files, as well as the ``packagename/example_subpkg`` directory. These are examples of a pure-python module, a test script, an example command-line script, a - `Cython`_ module, and a sub-package, respectively. (`Cython`_ is a way to - compile python-like code to C to make it run faster - see the project's web - site for details). These are provided as examples of standard way to lay - these out. Once you understand these, though, you'll want to delete them - (and later replace with your own):: + `Cython`_ module, and a sub-package, respectively. (`Cython`_ is a + way to compile python-like code to C to make it run faster - see the + project's web site for details). These are provided as examples of + standard way to lay these out. Once you understand these, though, + you'll want to delete them (and later replace with your own):: git rm packagename/example_mod.py git rm scripts/script_example @@ -89,48 +77,17 @@ will be clear from context what to do with your particular VCS. git rm -r packagename/example_subpkg git commit -m "removed examples from package template" -* Now rename the source code directory to match your project's name:: - - git mv packagename yourpkg - git commit -m "renamed template package source to new project yourpkg" - -* Adjust the information in the documentation to match your new project by - editing the ``docs/conf.py`` file. - - 1. Change the ``project`` variable to your project's name (note that this - does not *need* to be exactly the same as the package name, but that's a - common convention). - 2. Update the ``author`` variable with your name or the name of your collaboration. - 3. Update the ``copyright`` variable for the current year. - 4. Change the following lines:: - - import packagename - # The short X.Y version. - version = packagename.__version__.split('-', 1)[0] - # The full version, including alpha/beta/rc tags. - release = packagename.__version__ - - to:: +* Optional: If you're hosting your source code on github, you can + enable a sphinx extension that will link documentation pages + directly to github's web site. To do this, set ``edit_on_github`` in + ``setup.cfg`` to ``True`` and set ``github_project`` to the name of + your project on github. - import yourpkg - # The short X.Y version. - version = yourpkg.__version__.split('-', 1)[0] - # The full version, including alpha/beta/rc tags. - release = yourpkg.__version__ +* Move the main source directory to reflect the name of your package. + To tell your DVCS about this move, you should use it, and not ``mv`` + directly, to make the move. For example, with git:: - where ``yourpkg`` is the name of your package. - 5. (optional) If you're hosting your source code on github, you can - enable a sphinx extension that will link documentation pages - directly to github's web site. To do this, uncomment the code in - the "edit_on_github" section at the bottom of ``docs/conf.py``, - and replace ``packagename`` and ``reponame`` in that section with - the name of your package and github repository. - - -* Pass these changes on to git:: - - git add docs/conf.py - git commit -m "updated documentation for new project yourpkg" + git mv packagename yourpkg * Update the names of the documentation files to match your package's name. First open ``docs/index.rst`` in a text editor and change the text @@ -138,33 +95,13 @@ will be clear from context what to do with your particular VCS. git add docs/index.rst git mv docs/packagename docs/yourpkg - git commit -m "Updated docs to reflect new project yourpkg" - -* (Optional) If you want integrated coverage testing, update the - coverage configuration. Open ``yourpkg/tests/coveragerc`` in a text - editor and change the ``source = packagename`` line to refer to the - name of your package. Any other project-specific settings for - ``coverage.py`` can be added here. Open - ``yourpkg/tests/setup_package.py`` and replace the package name - ``packages.tests`` with ``yourpkg.tests``. Then do:: - - git add yourpkg/tests/coveragerc - git add yourpkg/tests/setup_package.py - git commit -m "Update coveragerc settings" - -* Adjust the ``MANIFEST.in`` file to reflect your package's name by changing - the line 4 from ``recursive-include packagename *.pyx *.c`` to - ``recursive-include yourpkg *.pyx *.c`` and pass this onto git:: - - ... edit MANIFEST.in as described above... - git add MANIFEST.in - git commit -m "updated MANIFEST.in for new project yourpkg" * Edit this file (``README.rst``) and delete all of this content, and replace it - with a short description of your affiliated package. Inform git:: + with a short description of your affiliated package. + +* Now tell git to remember the changes you just made:: - git add README.rst - git commit -m "replaced README for new project yourpkg" + git commit -a -m "Adjusted for new project yourpkg" * (This step assumes your affiliated package is hosted as part of the astropy organization on Github. If it's instead hosted somewhere else, just adjust diff --git a/docs/conf.py b/docs/conf.py index bc95e4d2b..9a6b46e53 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,7 +8,7 @@ # Note that not all possible configuration values are present in this file. # # All configuration values have a default. Some values are defined in -# the global Astropy configuration which is loaded here before anything else. +# the global Astropy configuration which is loaded here before anything else. # See astropy.sphinx.conf for which values are set there. # If extensions (or modules to document with autodoc) are in another directory, @@ -25,9 +25,17 @@ # Thus, any C-extensions that are needed to build the documentation will *not* # be accessible, and the documentation will not build correctly. +import os +import sys + # Load all of the global Astropy configuration from astropy.sphinx.conf import * +# Get configuration information from setup.cfg +from distutils import config +conf = config.ConfigParser() +conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) +setup_cfg = dict(conf.items('affiliated')) # -- General configuration ---------------------------------------------------- @@ -46,19 +54,22 @@ # -- Project information ------------------------------------------------------ # This does not *have* to match the package name, but typically does -project = u'Packagename' -author = u'The Packagename Developers' -copyright = u'2012, ' + author +project = setup_cfg['package_name'] +author = setup_cfg['author'] +copyright = '{0}, {1}'.format( + datetime.datetime.now().year, setup_cfg['author']) # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -import packagename +__import__(setup_cfg['package_name']) +package = sys.modules[setup_cfg['package_name']) + # The short X.Y version. -version = packagename.__version__.split('-', 1)[0] +version = package.__version__.split('-', 1)[0] # The full version, including alpha/beta/rc tags. -release = packagename.__version__ +release = package.__version__ # -- Options for HTML output --------------------------------------------------- @@ -116,17 +127,16 @@ ## -- Options for the edit_on_github extension ---------------------------------------- -# -#extensions += ['astropy.sphinx.ext.edit_on_github'] -# -## Don't import the module as "version" or it will override the -## "version" configuration parameter -#from packagename import version as versionmod -#edit_on_github_project = "astropy/reponame" -#if versionmod.release: -# edit_on_github_branch = "v" + versionmod.version -#else: -# edit_on_github_branch = "master" -# -#edit_on_github_source_root = "" -#edit_on_github_doc_root = "docs" + +if eval(setup_cfg.get('edit_on_github')): + extensions += ['astropy.sphinx.ext.edit_on_github'] + + versionmod = __import__(setup_cfg['package_name'] + '.version') + edit_on_github_project = setup_cfg['github_project'] + if versionmod.release: + edit_on_github_branch = "v" + versionmod.version + else: + edit_on_github_branch = "master" + + edit_on_github_source_root = "" + edit_on_github_doc_root = "docs" diff --git a/licenses/LICENSE.rst b/licenses/LICENSE.rst index 2435abb44..655da3710 100644 --- a/licenses/LICENSE.rst +++ b/licenses/LICENSE.rst @@ -1,16 +1,16 @@ -Copyright (c) 2011, Astropy Developers +Copyright (c) year, author All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright notice, this +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or + list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -* Neither the name of the Astropy Team nor the names of its contributors may be - used to endorse or promote products derived from this software without +* Neither the name of the Astropy Team nor the names of its contributors may be + used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND @@ -18,9 +18,8 @@ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/packagename/__init__.py b/packagename/__init__.py index 14503c288..49990de99 100644 --- a/packagename/__init__.py +++ b/packagename/__init__.py @@ -1,130 +1,11 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -#this indicates whether or not we are in the package's setup.py -try: - _ASTROPY_SETUP_ -except NameError: - from sys import version_info - if version_info[0] >= 3: - import builtins - else: - import __builtin__ as builtins - builtins._ASTROPY_SETUP_ = False - del version_info - del builtins - -try: - from .version import version as __version__ -except ImportError: - __version__ = '' -try: - from .version import githash as __githash__ -except ImportError: - __githash__ = '' - -# set up the test command -def _get_test_runner(): - from astropy.tests.helper import TestRunner - return TestRunner(__path__[0]) - -def test(package=None, test_path=None, args=None, plugins=None, - verbose=False, pastebin=None, remote_data=False, pep8=False, - pdb=False, coverage=False, open_files=False, **kwargs): - """ - Run the tests using py.test. A proper set of arguments is constructed and - passed to `pytest.main`. - - Parameters - ---------- - package : str, optional - The name of a specific package to test, e.g. 'io.fits' or 'utils'. - If nothing is specified all default tests are run. - - test_path : str, optional - Specify location to test by path. May be a single file or - directory. Must be specified absolutely or relative to the - calling directory. - - args : str, optional - Additional arguments to be passed to `pytest.main` in the `args` - keyword argument. - - plugins : list, optional - Plugins to be passed to `pytest.main` in the `plugins` keyword - argument. - - verbose : bool, optional - Convenience option to turn on verbose output from py.test. Passing - True is the same as specifying `-v` in `args`. - - pastebin : {'failed','all',None}, optional - Convenience option for turning on py.test pastebin output. Set to - 'failed' to upload info for failed tests, or 'all' to upload info - for all tests. - - remote_data : bool, optional - Controls whether to run tests marked with @remote_data. These - tests use online data and are not run by default. Set to True to - run these tests. - - pep8 : bool, optional - Turn on PEP8 checking via the pytest-pep8 plugin and disable normal - tests. Same as specifying `--pep8 -k pep8` in `args`. - - pdb : bool, optional - Turn on PDB post-mortem analysis for failing tests. Same as - specifying `--pdb` in `args`. - - coverage : bool, optional - Generate a test coverage report. The result will be placed in - the directory htmlcov. - - open_files : bool, optional - Fail when any tests leave files open. Off by default, because - this adds extra run time to the test suite. Works only on - platforms with a working `lsof` command. - - parallel : int, optional - When provided, run the tests in parallel on the specified - number of CPUs. If parallel is negative, it will use the all - the cores on the machine. Requires the `pytest-xdist` plugin - is installed. Only available when using Astropy 0.3 or later. - - kwargs - Any additional keywords passed into this function will be passed - on to the astropy test runner. This allows use of test-related - functionality implemented in later versions of astropy without - explicitly updating the package template. - - See Also - -------- - pytest.main : py.test function wrapped by `run_tests`. - - """ - test_runner = _get_test_runner() - return test_runner.run_tests( - package=package, test_path=test_path, args=args, - plugins=plugins, verbose=verbose, pastebin=pastebin, - remote_data=remote_data, pep8=pep8, pdb=pdb, - coverage=coverage, open_files=open_files, **kwargs) - -if not _ASTROPY_SETUP_: - - import os - from warnings import warn - from astropy import config - - # add these here so we only need to cleanup the namespace at the end - config_dir = None - - if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False): - config_dir = os.path.dirname(__file__) - try: - config.configuration.update_default_config(__package__, config_dir) - except config.configuration.ConfigurationDefaultMissingError as e: - wmsg = (e.args[0] + " Cannot install default profile. If you are " - "importing from source, this is expected.") - warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg)) - del e - - del os, warn, config_dir # clean up namespace \ No newline at end of file +""" +This is an Astropy affiliated package. +""" + +# Affiliated packages may add whatever they like to this file, but +# should keep this content at the top. +# ---------------------------------------------------------------------------- +from ._astropy_init import * +# ---------------------------------------------------------------------------- diff --git a/packagename/_astropy_init.py b/packagename/_astropy_init.py new file mode 100644 index 000000000..f729eb4ad --- /dev/null +++ b/packagename/_astropy_init.py @@ -0,0 +1,131 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +#this indicates whether or not we are in the package's setup.py +try: + _ASTROPY_SETUP_ +except NameError: + from sys import version_info + if version_info[0] >= 3: + import builtins + else: + import __builtin__ as builtins + builtins._ASTROPY_SETUP_ = False + del version_info + del builtins + +try: + from .version import version as __version__ +except ImportError: + __version__ = '' +try: + from .version import githash as __githash__ +except ImportError: + __githash__ = '' + +# set up the test command +def _get_test_runner(): + import os + from astropy.tests.helper import TestRunner + return TestRunner(os.path.dirname(__file__)) + +def test(package=None, test_path=None, args=None, plugins=None, + verbose=False, pastebin=None, remote_data=False, pep8=False, + pdb=False, coverage=False, open_files=False, **kwargs): + """ + Run the tests using py.test. A proper set of arguments is constructed and + passed to `pytest.main`. + + Parameters + ---------- + package : str, optional + The name of a specific package to test, e.g. 'io.fits' or 'utils'. + If nothing is specified all default tests are run. + + test_path : str, optional + Specify location to test by path. May be a single file or + directory. Must be specified absolutely or relative to the + calling directory. + + args : str, optional + Additional arguments to be passed to `pytest.main` in the `args` + keyword argument. + + plugins : list, optional + Plugins to be passed to `pytest.main` in the `plugins` keyword + argument. + + verbose : bool, optional + Convenience option to turn on verbose output from py.test. Passing + True is the same as specifying `-v` in `args`. + + pastebin : {'failed','all',None}, optional + Convenience option for turning on py.test pastebin output. Set to + 'failed' to upload info for failed tests, or 'all' to upload info + for all tests. + + remote_data : bool, optional + Controls whether to run tests marked with @remote_data. These + tests use online data and are not run by default. Set to True to + run these tests. + + pep8 : bool, optional + Turn on PEP8 checking via the pytest-pep8 plugin and disable normal + tests. Same as specifying `--pep8 -k pep8` in `args`. + + pdb : bool, optional + Turn on PDB post-mortem analysis for failing tests. Same as + specifying `--pdb` in `args`. + + coverage : bool, optional + Generate a test coverage report. The result will be placed in + the directory htmlcov. + + open_files : bool, optional + Fail when any tests leave files open. Off by default, because + this adds extra run time to the test suite. Works only on + platforms with a working `lsof` command. + + parallel : int, optional + When provided, run the tests in parallel on the specified + number of CPUs. If parallel is negative, it will use the all + the cores on the machine. Requires the `pytest-xdist` plugin + is installed. Only available when using Astropy 0.3 or later. + + kwargs + Any additional keywords passed into this function will be passed + on to the astropy test runner. This allows use of test-related + functionality implemented in later versions of astropy without + explicitly updating the package template. + + See Also + -------- + pytest.main : py.test function wrapped by `run_tests`. + + """ + test_runner = _get_test_runner() + return test_runner.run_tests( + package=package, test_path=test_path, args=args, + plugins=plugins, verbose=verbose, pastebin=pastebin, + remote_data=remote_data, pep8=pep8, pdb=pdb, + coverage=coverage, open_files=open_files, **kwargs) + +if not _ASTROPY_SETUP_: + + import os + from warnings import warn + from astropy import config + + # add these here so we only need to cleanup the namespace at the end + config_dir = None + + if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False): + config_dir = os.path.dirname(__file__) + try: + config.configuration.update_default_config(__package__, config_dir) + except config.configuration.ConfigurationDefaultMissingError as e: + wmsg = (e.args[0] + " Cannot install default profile. If you are " + "importing from source, this is expected.") + warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg)) + del e + + del os, warn, config_dir # clean up namespace diff --git a/packagename/tests/coveragerc b/packagename/tests/coveragerc index afb65b93d..2a0c19c8a 100644 --- a/packagename/tests/coveragerc +++ b/packagename/tests/coveragerc @@ -1,5 +1,5 @@ [run] -source = packagename +source = {packagename} [report] exclude_lines = diff --git a/packagename/tests/setup_package.py b/packagename/tests/setup_package.py index aaeedd5b9..f2fd9ed48 100644 --- a/packagename/tests/setup_package.py +++ b/packagename/tests/setup_package.py @@ -1,3 +1,3 @@ def get_package_data(): return { - 'packagename.tests': ['coveragerc']} + _ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc']} diff --git a/setup.cfg b/setup.cfg index c04d0c841..96817ce20 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,3 +10,14 @@ show-response = 1 [pytest] minversion = 2.2 norecursedirs = build docs/_build + +[affiliated] +package_name = packagename +description = Astropy affiliated package +long_description = This is a package for doing X that relies on astropy +author = John Doe +author_email = johndoe@nowhere.com +license = BSD +url = http://astropy.org/ +edit_on_github = False +github_project = astropy/astropy \ No newline at end of file diff --git a/setup.py b/setup.py index ecac3a2e1..56b30c879 100755 --- a/setup.py +++ b/setup.py @@ -20,14 +20,27 @@ get_debug_option) from astropy.version_helpers import get_git_devstr, generate_version_py -# Set affiliated package-specific settings -PACKAGENAME = 'packagename' -DESCRIPTION = 'Astropy affiliated package' -LONG_DESCRIPTION = '' -AUTHOR = '' -AUTHOR_EMAIL = '' -LICENSE = 'BSD' -URL = 'http://astropy.org' +# Get some values from the setup.cfg +from distutils import config +conf = config.ConfigParser() +conf.read(['setup.cfg']) +affiliated = dict(conf.items('affiliated')) + +PACKAGENAME = affiliated.get('package_name', 'packagename') +DESCRIPTION = affiliated.get('description', 'Astropy affiliated package') +AUTHOR = affiliated.get('author', '') +AUTHOR_EMAIL = affiliated.get('author_email', '') +LICENSE = affiliated.get('license', 'unknown') +URL = affiliated.get('url', 'http://astropy.org') + +# Get the long description from the package's docstring +__import__(PACKAGENAME) +package = sys.modules[PACKAGENAME] +LONG_DESCRIPTION = package.__doc__ + +# Store the package name in a built-in variable so it's easy +# to get from other parts of the setup infrastructure +builtins._ASTROPY_PACKAGE_NAME_ = PACKAGENAME # VERSION should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386) VERSION = '0.0.dev' @@ -95,6 +108,16 @@ package_info['package_data'], package_info['packages'], package_info['package_dir']) +# Include all .c files, recursively +c_files = [] +for root, dirs, files in os.walk(PACKAGENAME): + for filename in files: + if filename.endswith('.c'): + c_files.append( + os.path.join( + os.path.relpath(root, PACKAGENAME), filename)) +package_info['package_data'][PACKAGENAME].extend(c_files) + setup(name=PACKAGENAME, version=VERSION, description=DESCRIPTION,