Skip to content

Commit

Permalink
Derive package name from setuptools fullname (#3)
Browse files Browse the repository at this point in the history
The value given by --name is the verbatim package name, while the
--fullname yields the normalized package name used by setuptools followed
by the version.

We can trim off the version part to get the normalized name so that the
proper package name is used when looking for the archives produced by
the wheel build process.
  • Loading branch information
cottsay authored Nov 23, 2024
1 parent fa5fa95 commit 8433314
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions publish_python/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ def get_package_name_and_version():
raise RuntimeError(
"Must be invoked in a directory containing a 'setup.py' file")
output = subprocess.check_output(
[sys.executable, 'setup.py', '--name', '--version'])
[sys.executable, 'setup.py', '--fullname', '--version'])
lines = output.decode('ascii').splitlines()
assert len(lines) == 2
Package = namedtuple('Package', ['name', 'version'])
return Package(lines[0], lines[1])
fullname = lines[0]
version = lines[1]
name = fullname[:-len(version) - 1]
return Package(name, version)

0 comments on commit 8433314

Please sign in to comment.