Skip to content

Commit fe1481a

Browse files
committed
merged pull request #5 from eteq/pkg-layout
2 parents a350d17 + 5360fcc commit fe1481a

19 files changed

Lines changed: 889 additions & 6 deletions

File tree

‎.gitignore‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
#compiled files
2+
*.py[co]
3+
*.a
4+
*.o
5+
*.so
6+
7+
#sphinx
18
_build
2-
*.pyc
9+
10+
# Packages/installer info
11+
*.egg
12+
*.egg-info
13+
dist
14+
build
15+
eggs
16+
parts
17+
bin
18+
var
19+
sdist
20+
develop-eggs
21+
.installed.cfg
22+
23+
# other
324
.*.swp

‎MANIFEST.in‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include README.rst
2+
3+
include distribute_setup.py
4+
recursive-include astropy/data *
5+
recursive-include astropy *.pyx *.c
6+
7+
recursive-include docs *
8+
recursive-include licenses *
9+
recursive-include tests *
10+
recursive-include extern *
11+
12+
exclude *.pyc *.o
13+
prune docs/_build
14+
prune build
15+

‎astropy/__init__.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python
2+
from __future__ import division
3+
from astropy.version import version as __version__
4+
#the version number can be found in the "version" variable of version.py
5+
6+
"""_Astropy is a package intended to contain core functionality and some
7+
common tools needed for performing astronomy and astrophysics research with
8+
Python. It also provides an index for other astronomy packages and tools for
9+
managing them.
10+
11+
"""

‎astropy/config/__init__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
from __future__ import division
3+
4+
"""This module contains configuration and setup utilities for the `astropy`
5+
project. This includes all functionality related to the affiliated package
6+
index.
7+
8+
"""

‎astropy/data/README.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Data directory
2+
==============
3+
4+
This directory contains data files included with the astropy source code
5+
distribution. Note that this is intended only for relatively small files -
6+
large files should be externally hosted and downloaded as needed.
7+

‎astropy/extern/__init__.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
from __future__ import division
3+
4+
"""This packages contains python packages that are bundled with Astropy but
5+
are external to Astropy, and hence are developed in a separate source tree.
6+
Note that this package is distinct from the /cextern directory of the source
7+
code distribution, as that directory only contains C extension code.
8+
9+
"""

‎astropy/utils/__init__.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python
2+
from __future__ import division
3+
4+
"""This package contains utilities of general use in the `astropy` package and
5+
affiliated packages.
6+
7+
"""

‎astropy/version.py‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env python
2+
from __future__ import division
3+
4+
"""
5+
Version numbering for astropy. The `major`, `minor`, and `bugfix` varaibles hold
6+
the respective parts of the version number (bugfix is '0' if absent). The
7+
`release` variable is True if this is a release, and False if this is a
8+
development version of astropy. For the actual version string, use::
9+
10+
from astropy.version import version
11+
12+
or::
13+
14+
from astropy import __version__
15+
16+
"""
17+
18+
version = '0.0dev'
19+
20+
21+
_versplit = version.replace('dev','').split('.')
22+
major = int(_versplit[0])
23+
minor = int(_versplit[1])
24+
bugfix = 0 if len(_versplit)<3 else int(_versplit[2])
25+
del _versplit
26+
27+
release = not version.endswith('dev')
28+
29+
30+
def _get_git_devstr(sha=False):
31+
r"""Determines the number of revisions in this repository.
32+
33+
These
34+
35+
Parameters
36+
----------
37+
sha : bool
38+
If True, the full SHA1 hash will be at the end of the devstr. Otherwise,
39+
the total count of commits in the repository will be used as a "revision
40+
number".
41+
42+
Returns
43+
-------
44+
devstr : str
45+
A string that begins with 'dev' to be appended to the astropy version
46+
number string.
47+
48+
"""
49+
from os import path
50+
from subprocess import Popen,PIPE
51+
from warnings import warn
52+
53+
if release:
54+
raise ValueError('revsion devstring should not be used in a release version')
55+
56+
currdir = path.abspath(path.split(__file__)[0])
57+
58+
p = Popen(['git','rev-list','HEAD'],cwd=currdir,
59+
stdout=PIPE,stderr=PIPE,stdin=PIPE)
60+
stdout,stderr = p.communicate()
61+
62+
if p.returncode == 128:
63+
warn('No git repository present! Using default dev version.')
64+
return ''
65+
elif p.returncode != 0:
66+
warn('Git failed while determining revision count: '+stderr)
67+
return ''
68+
69+
if sha:
70+
return '-git-'+stdout[:40]
71+
else:
72+
nrev = stdout.count('\n')
73+
return '-r%i'%nrev
74+
75+
if not release:
76+
version = version+_get_git_devstr(False)
77+
78+
#This is used by setup.py to create a new version.py - see that file for details
79+
_frozen_version_py_template = """
80+
#Autogenerated by astropy's setup.py on {timestamp}
81+
version = '{verstr}'
82+
83+
major = {maj}
84+
minor = {min}
85+
bugfix = {bugfix}
86+
87+
release = {rel}
88+
"""[1:]
89+
90+
def _get_version_py_str(self):
91+
import datetime
92+
93+
timestamp = str(datetime.datetime.now())
94+
return _frozen_version_py_template.format(timestamp=timestamp,
95+
verstr=version,
96+
maj=major,
97+
minor=minor,
98+
bugfix=bugfix,
99+
rel=release)

‎cextern/README.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
External Packages/Libraries
2+
===========================
3+
4+
This directory contains C extensions included with Astropy. Note that only C
5+
extensions should be included in this directory - pure Cython code should
6+
be placed in the Astropy source tree, and wrapper Cython code for C libraries
7+
included here should be in the astropy/wrappers directory.
8+

0 commit comments

Comments
 (0)