Skip to content

Barebones Copra Project Structure#1

Closed
CheeksTheGeek wants to merge 4 commits into
cocotb:mainfrom
CheeksTheGeek:main
Closed

Barebones Copra Project Structure#1
CheeksTheGeek wants to merge 4 commits into
cocotb:mainfrom
CheeksTheGeek:main

Conversation

@CheeksTheGeek
Copy link
Copy Markdown
Collaborator

Overview

This PR introduces the initial project structure for Copra, a new project under the cocotb organization. This barebones setup includes the essential configuration files and directory structure to get started with development.

Changes Included

Core Configuration

  • Added pyproject.toml with project metadata and build configuration
  • Included .pre-commit-config.yaml for code quality checks
  • Added basic .gitignore for Python projects
  • Included BSD-3 LICENSE file

Project Structure

/src - Main source code directory
/tests - Test directory
/examples - Example implementations
/docs - Documentation

Development Setup

  • requirements.txt for development dependencies
  • setup_dev.sh for quick environment setup
  • noxfile.py for automated testing and development tasks

Next Steps

Set up CI/CD pipelines
Add comprehensive documentation
Implement core functionality

Testing

The project includes a basic test structure. Run nox to execute the test suite.

Documentation

Initial documentation structure is in place in the /docs directory. More comprehensive documentation will be added in subsequent PRs.

@CheeksTheGeek CheeksTheGeek requested review from imphil and ktbarrett May 20, 2025 18:50
@CheeksTheGeek CheeksTheGeek self-assigned this May 20, 2025
Comment thread pyproject.toml Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using sphinx-book-theme in cocotb master since a while, you might want to follow that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, added it here

Comment thread requirements.txt Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant with pyproject.toml?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the redundancy by composing a better pyproject.toml file here

Comment thread src/copra.egg-info/PKG-INFO Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated directory?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is something for .gitignore:

Typical Python project gitignore will have.

*.egg-info/
__pycache__/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a better .gitignore here

Comment thread src/copra/stubgen.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should align on a copyright header early on (if any).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need copyright headers, just a single license file in the repo is sufficient.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread LICENSE Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Copyright (c) 2024, cocotb
Copyright (c) 2024, cocotb contributors

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And "2025" I guess?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it here

Comment thread README.md Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 🚀 Generate Python type stubs from Verilog/SystemVerilog DUTs
- 🚀 Generate Python type stubs from VHDL and Verilog/SystemVerilog DUTs

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified it here

Comment thread README.md Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What made you decide on 1.8 or later?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to make it cross compatible across 1.8, and only later realized that's too much of a breadth. Also, got a bit more confused because it wasn't working with 2.0.0 in the pyproject.toml version specifier for cocotb, only realizing it later that it's because it's getting the wheel from pypi.

Comment thread README.md Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this internal tests or cocotb test with the Python runner? If so we should support both the runner and Makefiles. This might fall into the dev additional dependencies below and doesn't need a mention here.

Comment thread docs/source/api.rst Outdated
Comment on lines 30 to 38
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to not document private modules. Here I'd re-export the __version__ in copra.__init__.py and ensure that is called out .. autodata:: copra.__version__ here.

Comment thread setup_dev.sh Outdated
Comment on lines 19 to 47
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nox?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, got confused between their purposes, now the setup_dev is just running a nice order of nox sessions, here and here

Comment thread src/copra.egg-info/PKG-INFO Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is something for .gitignore:

Typical Python project gitignore will have.

*.egg-info/
__pycache__/

Comment thread src/copra/stubgen.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HierarchyObjectIterator?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/copra/stubgen.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the canonical import location for Range.

Comment thread src/copra/utils.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only names that start with _ are not public. Names that end with _ are often used to avoid collisions with keywords, such as operator.or_.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here

Copy link
Copy Markdown

@cmarqu cmarqu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't be discouraged by all our nitpicky comments, this is a very good start!

Comment thread docs/source/api.rst Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
============
=============

Comment thread docs/source/api.rst Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
------------------
-------------------

Comment thread docs/source/index.rst Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
================================
=================================

Comment thread docs/source/index.rst Outdated
Comment on lines 1 to 5
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. copra documentation master file, created by
sphinx-quickstart on Wed May 15 15:30:00 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Comment thread docs/source/quickstart.rst Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
------------------------
-------------------------

Comment thread docs/source/quickstart.rst Outdated
Copy link
Copy Markdown

@cmarqu cmarqu May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This will generate a `dut.pyi` file with type information for your DUT.
This will generate a :file:`dut.pyi` file with type information for your DUT.

https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-file

Comment thread docs/source/quickstart.rst Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For example, in VS Code, add this to your `settings.json`:
For example, in VS Code, add this to your :file:`settings.json`:

Comment thread pyproject.toml Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"License :: OSI Approved :: BSD License",

Disrecommended these days.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. The recommendation is to use license and/or license-file field. However, those fields don't work in Python 3.8 for some reason, so either leave them out or move that part of the config to setup.cfg.

Comment thread pyproject.toml Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might go up to 3.13 or 3.14.

Comment thread examples/minimal/dut.pyi Outdated
Copy link
Copy Markdown

@cmarqu cmarqu May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, ruff check would be happy with the generated files (which it currently wouldn't be).

Comment thread src/copra/stubgen.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I'd think instead of appending lines and building the whole file in memory you can just file.write lines.

@ktbarrett
Copy link
Copy Markdown
Member

Is there a reason to close it?

@CheeksTheGeek
Copy link
Copy Markdown
Collaborator Author

@ktbarrett
Hi, I was trying to remove the egg-info files and accidentally force pushed, reverted it instantly but apparently GitHub permanently closes the PR if someone does this, and doesn't allow re-opening. isaacs/github#361

I'm going to resolve all the reviews on this PR and also refer to them on a new one, in which I'll push all new changes.

Really sorry for causing the trouble and inconvenience, I'll make sure to document this mistake well so as to make sure people can track it properly too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants