Skip to content

Errors when running .initialize_new_project.sh #538

Closed

Description

@drewoldag

Got errors when running .initialize_new_project.sh

(ext_hyrax) drew@triceratops:~/code/ext-hyrax-example$ bash .initialize_new_project.sh
<standard install stuff>
Installing pre-commit
Committing initial files
[INFO] Initializing environment for https://github.com/abravalheri/validate-pyproject.
[INFO] Initializing environment for https://github.com/abravalheri/validate-pyproject:.[all].
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Installing environment for https://github.com/abravalheri/validate-pyproject.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check template version...................................................Passed
- hook id: check-lincc-frameworks-template-version
- duration: 0.53s
Clear output from Jupyter notebooks......................................Passed
Prevent main branch commits.............................................Skipped
Check for large files....................................................Passed
Validate pyproject.toml..................................................Passed
Validate GitHub Workflows................................................Passed
Lint code using ruff; sort and organize imports..........................Failed
- hook id: ruff
- files were modified by this hook

Found 2 errors (2 fixed, 0 remaining).

Format code using ruff...................................................Passed
Build documentation with Sphinx..........................................Passed
Run unit tests...........................................................Failed
- hook id: pytest-check
- exit code: 1

tests/external_hyrax_example/test_packaging.py: 1

============================= test session starts ==============================
platform linux -- Python 3.13.7, pytest-8.4.2, pluggy-1.6.0
rootdir: /home/drew/code/ext-hyrax-example
configfile: pyproject.toml
testpaths: tests, src, docs
plugins: cov-7.0.0, anyio-4.11.0
collected 1 item

tests/external_hyrax_example/test_packaging.py F                         [100%]

=================================== FAILURES ===================================
_________________________________ test_version _________________________________

    def test_version():
        """Check to see that we can get the package version"""
>       assert external_hyrax_example.__version__ is not None
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       AttributeError: module 'external_hyrax_example' has no attribute '__version__'. Did you mean: '_version'?

tests/external_hyrax_example/test_packaging.py:6: AttributeError
================================ tests coverage ================================
_______________ coverage: platform linux, python 3.13.7-final-0 ________________

Coverage HTML written to dir htmlcov
=========================== short test summary info ============================
FAILED tests/external_hyrax_example/test_packaging.py::test_version - AttributeError: module 'external_hyrax_example' has no attribute '__version...
============================== 1 failed in 0.05s ===============================

.initialize_new_project.sh: Error on line 62: SKIP="no-commit-to-branch" git commit -m "Initial commit"
(ext_hyrax) drew@triceratops:~/code/ext-hyrax-example$ git diff
diff --git a/src/external_hyrax_example/__init__.py b/src/external_hyrax_example/__init__.py
index 8dee4bf..e69de29 100644
--- a/src/external_hyrax_example/__init__.py
+++ b/src/external_hyrax_example/__init__.py
@@ -1 +0,0 @@
-from ._version import __version__
diff --git a/tests/external_hyrax_example/test_packaging.py b/tests/external_hyrax_example/test_packaging.py
index c4ccbc6..5d12525 100644
--- a/tests/external_hyrax_example/test_packaging.py
+++ b/tests/external_hyrax_example/test_packaging.py
@@ -3,4 +3,4 @@ import external_hyrax_example

 def test_version():
     """Check to see that we can get the package version"""
-    assert external_hyrax_example.__version__ is not None
\ No newline at end of file
+    assert external_hyrax_example.__version__ is not None
(ext_hyrax) drew@triceratops:~/code/ext-hyrax-example$

Using these copier answers

Changes here will be overwritten by Copier
_commit: v2.0.8
_src_path: gh:lincc-frameworks/python-project-template
author_email: awoldag@uw.edu
author_name: Drew Oldag
create_example_module: false
custom_install: true
enforce_style:
- ruff_lint
- ruff_format
failure_notification: []
include_benchmarks: false
include_docs: true
include_notebooks: true
mypy_type_checking: none
package_name: external_hyrax_example
project_license: MIT
project_name: external_hyrax_example
project_organization: lincc-frameworks
python_versions:
- '3.11'
- '3.12'
- '3.13'
test_lowest_version: none

Activity

  1. drewoldag commented on Oct 1, 2025

    @drewoldag
    CollaboratorAuthor

    @delucchi-cmu you added this test, right? I'm curious if there's something strange about the setup on my system that would have created a _version.py file instead of a __version__.py file. I'm running into this on WSL (Ubuntu), haven't tried it on a mac yet.

  2. delucchi-cmu commented on Oct 1, 2025

    @delucchi-cmu
    Contributor

    Hm. Interesting.

    I would expect to have

    src/
      _ external_hyrax_example/
        _ __init__.py 
          CONTAINS
          from ._version import __version__
    

    and once you run pip install -e ., which the .initialize_new_project.sh command should do, then setuptools will create a src/external_hyrax_example/_version.py with the __version__ attribute.

    This is how we've been adding a user-accessible version attribute for LSDB-related packages (e.g. lsdb.__version__).

    Sounds like something is going haywire in the pip portion.

    As for the failure in pre-commit, that should be addressed with #537

  3. delucchi-cmu commented on Oct 8, 2025

    @delucchi-cmu
    Contributor

    I know a little bit more about ruff now, and know that it will remove the contents of the __init__.py file if the imports are not included in the "all" attribute. Currently working on a fix.

  4. self-assigned this
    on Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions