Skip to content

Commit

Permalink
Allow specifying a dist-name that doesn't match the module name
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Mar 31, 2015
1 parent 08c772e commit b3ba5bf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
5 changes: 4 additions & 1 deletion doc/pkg_ini.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The flit.ini config file
========================

This file lives next to the module or package at :file:`{modulename}-pkg.ini`.
This file lives next to the module or package.

Metadata section
----------------
Expand Down Expand Up @@ -43,6 +43,9 @@ classifiers
requires-python
A version specifier for the versions of Python this requires, e.g. ``3`` or
``>=3.3``.
dist-name
If you want your package's name on PyPI to be different from the importable
module name, set this to the PyPI name.
keywords
Space separated list of words to help with searching for your package.
license
Expand Down
7 changes: 6 additions & 1 deletion flit/inifile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class ConfigError(ValueError):
'home-page',
'license',
'keywords',
'requires-python'
'requires-python',
'dist-name',
} | metadata_list_fields

metadata_required_fields = {
Expand Down Expand Up @@ -73,6 +74,10 @@ def read_pkg_ini(path):
if 'requires' in md_dict:
md_dict['requires_dist'] = md_dict.pop('requires')

# And what we call dist-name is name in the metadata
if 'dist_name' in md_dict:
md_dict['name'] = md_dict.pop('dist_name')

if cp.has_section('scripts'):
scripts_dict = {k: common.parse_entry_point(v) for k, v in cp['scripts'].items()}
else:
Expand Down
6 changes: 6 additions & 0 deletions tests/samples/altdistname.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[metadata]
module=package1
author=Sir Robin
author-email=robin@camelot.uk
home-page=http://github.com/sirrobin/package1
dist-name=packagedist1
14 changes: 14 additions & 0 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import pathlib
import shutil

from testpath import assert_isfile

from flit.wheel import WheelBuilder

samples_dir = pathlib.Path(__file__).parent / 'samples'

def clear_samples_dist():
try:
shutil.rmtree(str(samples_dir / 'dist'))
except FileNotFoundError:
pass

def test_wheel_module():
clear_samples_dist()
WheelBuilder(samples_dir / 'module1-pkg.ini').build()
assert_isfile(str(samples_dir / 'dist/module1-0.1-py2.py3-none-any.whl'))

def test_wheel_package():
clear_samples_dist()
WheelBuilder(samples_dir / 'package1-pkg.ini').build()
assert_isfile(str(samples_dir / 'dist/package1-0.1-py2.py3-none-any.whl'))

def test_dist_name():
clear_samples_dist()
WheelBuilder(samples_dir / 'altdistname.ini').build()
assert_isfile(str(samples_dir / 'dist/packagedist1-0.1-py2.py3-none-any.whl'))

0 comments on commit b3ba5bf

Please sign in to comment.