To package the photometry-sans-frustration project according to modern Python standards, we’ll follow the structure outlined by the Python Packaging Authority (PyPa). This involves creating necessary files that define the package metadata, structure, and dependencies. Below are the steps and required files to properly package the project.
Step 1: Project Structure
First, we will organize the project into a standard structure. Here’s a suggested directory layout:
code
photometry-sans-frustration/
│
├── photometry_sans_frustration/
│ ├── __init__.py
│ ├── psf.py
│ ├── get_psf_output.py
│ ├── queryPS1.py
│ ├── reduce_fits_image.py
│ └── other_modules.py # Any additional modules can be added here
│
├── tests/
│ ├── __init__.py
│ └── test_psf.py # Example test file
│
├── examples/
│ └── example_script.py # Example usage script
│
├── README.md
├── setup.py
├── pyproject.toml
├── requirements.txt
└── .gitignore
Step 2: Code Amendments
You may need to make a few amendments to the code:
Change relative imports to absolute imports where necessary.
Ensure that all scripts can be accessed through the main package (photometry_sans_frustration).
Step 3: Required Files
1. setup.py
This file contains metadata about the package and configuration for installation.
python
from setuptools import setup, find_packages
setup(
name='photometry-sans-frustration',
version='1.0.0', # Update version as needed
author='[Redacted Person]',
[Redacted Email]', # Replace with actual email
description='Interactive Python wrapper for point-spread fitting (PSF) photometry using Astropy/photutils.',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
url='https://github.com/username/photometry-sans-frustration', # Replace with actual repo URL
packages=find_packages(), # Automatically find packages in the directory
install_requires=[
'numpy',
'astropy',
'photutils',
'matplotlib',
'scikit-image',
'requests',
'astroquery',
'astroalign',
'ccdproc',
],
classifiers=[
'Programming Language [Redacted IPAddress] Python [Redacted IPAddress] 3',
'License [Redacted IPAddress] OSI Approved [Redacted IPAddress] MIT License',
'Operating System [Redacted IPAddress] OS Independent',
],
python_requires='>=3.6',
)
This file should be updated to provide an overview of the project, installation instructions, usage, etc. Here’s an example template:
markdown
# Photometry Sans Frustration (PSF)
Interactive Python wrapper for point-spread fitting (PSF) photometry using Astropy/photutils.
## Installation
To install this package, clone the repository and run:
```bash
pip install .
or
bash
python setup.py install
Requirements
Python 3.6 or higher
Required Python packages listed in requirements.txt
Usage
To run the PSF photometry script:
bash
python -m photometry_sans_frustration.psf --help
License
MIT License
code
#### 5. `__init__.py`
Make sure to create an `__init__.py` file in the main package directory `photometry_sans_frustration/` to define it as a package.
```python
# photometry_sans_frustration/__init__.py
__version__ = "1.0.0" # Define the package version
Step 4: Testing
You can include a simple test within the tests/ directory using unittest or pytest. For example, create a file named test_psf.py:
python
import unittest
class TestPSFMethods(unittest.TestCase):
def test_example(self):
self.assertEqual(1 + 1, 2)
if __name__ == '__main__':
unittest.main()
Final Steps
Add Version Control: Initialize a Git repository if not already done and add a .gitignore file to ignore unnecessary files.
Documentation: Consider creating detailed documentation using Sphinx or similar tools if the project grows.
Distribution: You can build and distribute your package using:
bash
python setup.py sdist bdist_wheel
And upload to PyPI using twine:
bash
twine upload dist/*
Testing: Ensure all functionalities are working correctly after the restructuring by running your test suite.
By following these steps, you will have a well-structured, modern Python package that adheres to current best practices.