Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: try to get setuptools scm to work with src #9

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ __pycache__/
**/.DS_Store

**/_build

**/examplePy/_version_generated.py


# Distribution / packaging
Expand Down
17 changes: 11 additions & 6 deletions example1b_build_setuptools_scm/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# examplePy - setuptools example

This directory illustrates how to create a Python package using setuptools.
This directory illustrates how to create a Python package using the
`Build` front end and `setuptools` back-end.

Optionally you can use `setuptools_scm` for versioning which is also shown here.
### Dynamic versioning

Here you also use `setuptools_scm` for versioning.

Your build requirements for this setup should include:

Expand All @@ -13,8 +16,8 @@ build
twine
```

Because setuptools is listed in your pyproject.toml file it will be installed
when your package is build. It will also install Wheel for you which you need
Because `setuptools` is listed in your **pyproject.toml** file it will be installed
when your package is build. It will also install `Wheel` for you which you need
to create your package's wheel.

## Src Layout
Expand All @@ -26,8 +29,10 @@ about why, here <TODO: link to packaging guide when current pr is merged>.

### Build System specs

The build system here is setuptools which is your build backend. Because setuptools
does not have a default front end, you will use the [Build frontend](https://pypa-build.readthedocs.io/en/stable/) to build your package in this example.
The build system here is

- **Front end:** [Build frontend](https://pypa-build.readthedocs.io/en/stable/). `Build` is a simple front end that just runs setuptools on the back end to create your SDist and Wheel files.
- **Back end:** `setuptools` is your backend.

```
[build-system]
Expand Down
9 changes: 5 additions & 4 deletions example1b_build_setuptools_scm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
requires = ["setuptools>=61.0.0", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"


# LookupError: setuptools-scm was unable to detect version for

# To adopt the src/ layout you'll need the following section
# If you are using a flat layout you can likely remove this!
[tool.setuptools.packages.find]
where = ["src"]

# How do i specify the root correctly to help setuptools find the version?
# LookupError: setuptools-scm was unable to detect version for
# This is optional if you wish to use scm for versioning
[tool.setuptools_scm]
Copy link
Member Author

Choose a reason for hiding this comment

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

hey there @RonnyPfannschmidt ! i was wondering if you could help be debug this by chance? I'm trying to get setuptools_scm to find the version. i know this is a complex repo as we're using it as examples for the community. but i'm not sure how or where setuptools scm looks for version information if it's not just looking at git tags. many thanks for any direction. (and please say the word if you'd like me to submit an issue somewhere / it's is not appropriate to ask here)

Choose a reason for hiding this comment

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

Sorry for the delay, I'm preoccupied

The root option is needed when under use in a subdirectory, as otherwise a number of upstream packaging schemes break things

The root option sets the scm root relative to the pyproject.toml file

# This root setting allows it to find the root where the .git file is
root = "../"
version_scheme = "post-release"
local_scheme = "node-and-date" # what does this do?
write_to = "src/examplePy/_version_generated.py"
# FileNotFoundError: [Errno 2] No such file or directory: '../examplePy/_version_generated.py'
write_to = "example1b_build_setuptools_scm/src/examplePy/_version_generated.py"

# https://packaging.python.org/en/latest/tutorials/packaging-projects/#configuring-metadata
# How do we know how much metadata to include?
Expand Down