astropy / package-template

Template for packages that use Astropy. Maintainer: @astrofrog
http://docs.astropy.org/projects/package-template/en/latest/
Other
60 stars 63 forks source link

No such file or directory: readthedocs.yml #429

Closed matteobachetti closed 4 years ago

matteobachetti commented 4 years ago

I'm creating a new package from the template using cookiecutter. If I answer 'n' to the question use_read_the_docs [y]:, the package creation fails with

Traceback (most recent call last):
  File "/tmp/tmp7k_e0rii.py", line 48, in <module>
    remove_file('readthedocs.yml')
  File "/tmp/tmp7k_e0rii.py", line 9, in remove_file
    os.remove(os.path.join(PROJECT_DIRECTORY, filepath))
FileNotFoundError: [Errno 2] No such file or directory: '/home/mbachett/software/IXPE/ixpehealth/readthedocs.yml'
ERROR: Stopping generation because post_gen_project hook script didn't exit successfully
pllim commented 4 years ago

I don't have time to open PR right now but something like this might fix the problem in post_gen_project.py:

def remove_file(filepath):
    if os.path.exists(filepath):
        os.remove(os.path.join(PROJECT_DIRECTORY, filepath))

def remove_dir(filepath):
    if os.path.exists(filepath):
        shutil.rmtree(os.path.join(PROJECT_DIRECTORY, filepath))

def copy_file(original_filepath, new_filepath):
    if os.path.exists(original_filepath):
        shutil.copyfile(os.path.join(PROJECT_DIRECTORY, original_filepath),
                        os.path.join(PROJECT_DIRECTORY, new_filepath))
Cadair commented 4 years ago

I would assume it's related to this: https://github.com/astropy/package-template/blob/cookiecutter/hooks/post_gen_project.py#L46

pllim commented 4 years ago

Looking at this again, I think it is a typo in the code. It is supposed to be looking for .readthedocs.yml, not readthedocs.yml.

pllim commented 4 years ago

Fixed in #438